mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +00:00
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.
This commit is contained in:
parent
2ba66a9941
commit
3a31f37b3d
BIN
Base/res/graphics/mouse-button-left.png
Normal file
BIN
Base/res/graphics/mouse-button-left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 341 B |
BIN
Base/res/graphics/mouse-button-right.png
Normal file
BIN
Base/res/graphics/mouse-button-right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 338 B |
Binary file not shown.
Before Width: | Height: | Size: 410 B |
|
@ -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 {
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue