2021-04-02 11:08:18 -03:00
|
|
|
/*
|
2021-04-22 17:40:43 -03:00
|
|
|
* Copyright (c) 2020, Idan Horowitz <idan.horowitz@serenityos.org>
|
2021-04-28 17:46:44 -03:00
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
2021-07-20 16:35:00 -03:00
|
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
2021-04-02 11:08:18 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-02 11:08:18 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MouseSettingsWindow.h"
|
2021-08-02 07:14:52 -03:00
|
|
|
#include "MouseWidget.h"
|
|
|
|
|
#include "ThemeWidget.h"
|
2021-04-02 11:08:18 -03:00
|
|
|
#include <LibGUI/Application.h>
|
2021-07-20 16:35:00 -03:00
|
|
|
#include <LibGUI/BoxLayout.h>
|
2021-04-02 11:08:18 -03:00
|
|
|
#include <LibGUI/Button.h>
|
2021-07-20 16:35:00 -03:00
|
|
|
#include <LibGUI/TabWidget.h>
|
2021-04-02 11:08:18 -03:00
|
|
|
#include <LibGUI/Widget.h>
|
|
|
|
|
|
|
|
|
|
MouseSettingsWindow::MouseSettingsWindow()
|
|
|
|
|
{
|
|
|
|
|
auto& main_widget = set_main_widget<GUI::Widget>();
|
2021-07-20 16:35:00 -03:00
|
|
|
main_widget.set_fill_with_background_color(true);
|
|
|
|
|
main_widget.set_layout<GUI::VerticalBoxLayout>();
|
Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:
- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
the top margin, the second argument to the left and right margins,
and the third argument to the bottom margin.
2021-08-16 21:11:38 -03:00
|
|
|
main_widget.layout()->set_margins(4);
|
2021-07-20 16:35:00 -03:00
|
|
|
main_widget.layout()->set_spacing(6);
|
|
|
|
|
|
|
|
|
|
auto& tab_widget = main_widget.add<GUI::TabWidget>();
|
2021-04-02 11:08:18 -03:00
|
|
|
|
2021-08-02 07:14:52 -03:00
|
|
|
auto& mouse_widget = tab_widget.add_tab<MouseWidget>("Mouse");
|
|
|
|
|
auto& theme_widget = tab_widget.add_tab<ThemeWidget>("Cursor Theme");
|
2021-04-02 11:08:18 -03:00
|
|
|
|
2021-07-20 16:35:00 -03:00
|
|
|
auto& button_container = main_widget.add<GUI::Widget>();
|
|
|
|
|
button_container.set_shrink_to_fit(true);
|
|
|
|
|
button_container.set_layout<GUI::HorizontalBoxLayout>();
|
|
|
|
|
button_container.layout()->set_spacing(6);
|
|
|
|
|
|
|
|
|
|
m_reset_button = button_container.add<GUI::Button>("Defaults");
|
2021-08-02 07:14:52 -03:00
|
|
|
m_reset_button->on_click = [&](auto) {
|
|
|
|
|
mouse_widget.reset_default_values();
|
|
|
|
|
theme_widget.reset_default_values();
|
2021-07-20 16:35:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
button_container.layout()->add_spacer();
|
|
|
|
|
|
|
|
|
|
m_ok_button = button_container.add<GUI::Button>("OK");
|
|
|
|
|
m_ok_button->set_fixed_width(75);
|
|
|
|
|
m_ok_button->on_click = [&](auto) {
|
2021-08-02 07:14:52 -03:00
|
|
|
mouse_widget.update_window_server();
|
|
|
|
|
theme_widget.update_window_server();
|
2021-04-02 11:08:18 -03:00
|
|
|
GUI::Application::the()->quit();
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-20 16:35:00 -03:00
|
|
|
m_cancel_button = button_container.add<GUI::Button>("Cancel");
|
|
|
|
|
m_cancel_button->set_fixed_width(75);
|
|
|
|
|
m_cancel_button->on_click = [&](auto) {
|
|
|
|
|
GUI::Application::the()->quit();
|
2021-04-02 11:08:18 -03:00
|
|
|
};
|
|
|
|
|
|
2021-07-20 16:35:00 -03:00
|
|
|
m_apply_button = button_container.add<GUI::Button>("Apply");
|
|
|
|
|
m_apply_button->set_fixed_width(75);
|
|
|
|
|
m_apply_button->on_click = [&](auto) {
|
2021-08-02 07:14:52 -03:00
|
|
|
mouse_widget.update_window_server();
|
|
|
|
|
theme_widget.update_window_server();
|
2021-04-02 11:08:18 -03:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseSettingsWindow::~MouseSettingsWindow()
|
|
|
|
|
{
|
|
|
|
|
}
|