diff options
author | Ravi J <ravi@101011010.com> | 2022-12-30 02:05:38 -0500 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2022-12-30 09:20:42 -0500 |
commit | 3a31f37b3d726be1c2ef0936df8e8f9d3d4b8b61 (patch) | |
tree | 7536b896816986e0b257c4b1ed17c3263ff8aa67 /Userland/Applications/MouseSettings | |
parent | 2ba66a994190ae5bdce44e962ebce0ded1549dcc (diff) | |
download | serenity-3a31f37b3d726be1c2ef0936df8e8f9d3d4b8b61.zip |
MouseSettings: Update "switch buttons" icon to reflect checkbox state
Using an additional "right button" variant of the graphic, it now
updates the icon based on the user's preference of primary button.
Diffstat (limited to 'Userland/Applications/MouseSettings')
-rw-r--r-- | Userland/Applications/MouseSettings/Mouse.gml | 2 | ||||
-rw-r--r-- | Userland/Applications/MouseSettings/MouseWidget.cpp | 12 | ||||
-rw-r--r-- | Userland/Applications/MouseSettings/MouseWidget.h | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/Userland/Applications/MouseSettings/Mouse.gml b/Userland/Applications/MouseSettings/Mouse.gml index a2d77b59ee..7e66c29d84 100644 --- a/Userland/Applications/MouseSettings/Mouse.gml +++ b/Userland/Applications/MouseSettings/Mouse.gml @@ -178,7 +178,7 @@ @GUI::Label { fixed_width: 32 fixed_height: 32 - icon: "/res/graphics/switch-mouse-buttons.png" + name: "switch_buttons_image_label" } @GUI::CheckBox { diff --git a/Userland/Applications/MouseSettings/MouseWidget.cpp b/Userland/Applications/MouseSettings/MouseWidget.cpp index 64d84e9db6..8841a7cf3a 100644 --- a/Userland/Applications/MouseSettings/MouseWidget.cpp +++ b/Userland/Applications/MouseSettings/MouseWidget.cpp @@ -51,9 +51,11 @@ MouseWidget::MouseWidget() set_modified(true); }; + m_switch_buttons_image_label = *find_descendant_of_type_named<GUI::Label>("switch_buttons_image_label"); m_switch_buttons_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("switch_buttons_checkbox"); m_switch_buttons_checkbox->set_checked(GUI::ConnectionToWindowServer::the().are_mouse_buttons_switched(), GUI::AllowCallback::No); m_switch_buttons_checkbox->on_checked = [&](auto) { + update_switch_buttons_image_label(); set_modified(true); }; @@ -65,6 +67,7 @@ MouseWidget::MouseWidget() update_speed_label(); update_double_click_speed_label(); + update_switch_buttons_image_label(); m_double_click_arrow_widget->set_double_click_speed(m_double_click_speed_slider->value()); } @@ -96,3 +99,12 @@ void MouseWidget::update_double_click_speed_label() { m_double_click_speed_label->set_text(DeprecatedString::formatted("{} ms", m_double_click_speed_slider->value())); } + +void MouseWidget::update_switch_buttons_image_label() +{ + if (m_switch_buttons_checkbox->is_checked()) { + m_switch_buttons_image_label->set_icon_from_path("/res/graphics/mouse-button-right.png"); + } else { + m_switch_buttons_image_label->set_icon_from_path("/res/graphics/mouse-button-left.png"); + } +} diff --git a/Userland/Applications/MouseSettings/MouseWidget.h b/Userland/Applications/MouseSettings/MouseWidget.h index d4cc6e9ac7..c4e3835fcc 100644 --- a/Userland/Applications/MouseSettings/MouseWidget.h +++ b/Userland/Applications/MouseSettings/MouseWidget.h @@ -24,6 +24,7 @@ private: void update_speed_label(); void update_double_click_speed_label(); + void update_switch_buttons_image_label(); RefPtr<GUI::HorizontalSlider> m_speed_slider; RefPtr<GUI::Label> m_speed_label; @@ -31,6 +32,7 @@ private: RefPtr<GUI::HorizontalSlider> m_double_click_speed_slider; RefPtr<GUI::Label> m_double_click_speed_label; RefPtr<GUI::CheckBox> m_switch_buttons_checkbox; + RefPtr<GUI::Label> m_switch_buttons_image_label; RefPtr<GUI::CheckBox> m_natural_scroll_checkbox; RefPtr<MouseSettings::DoubleClickArrowWidget> m_double_click_arrow_widget; }; |