mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +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
6 changed files with 15 additions and 1 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue