summaryrefslogtreecommitdiff
path: root/Userland/Applications/DisplaySettings
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-11-20 15:20:42 +0000
committerLinus Groh <mail@linusgroh.de>2021-11-20 21:05:20 +0000
commita4af8b2a6487161320fcaae02a195093498b05b0 (patch)
tree44ee42effc316bdd8f895634171810b325e804b2 /Userland/Applications/DisplaySettings
parent9fc53017c6c815bbf97ce31b91415dae77774c2b (diff)
downloadserenity-a4af8b2a6487161320fcaae02a195093498b05b0.zip
DisplaySettings: Move screen number show/hide logic into widget
This is functionally the same as before, as selecting a tab fires Show and HideEvents. But this way, we don't need to directly access the TabWidget, which will make using SettingsWindow simpler.
Diffstat (limited to 'Userland/Applications/DisplaySettings')
-rw-r--r--Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp10
-rw-r--r--Userland/Applications/DisplaySettings/MonitorSettingsWidget.h4
-rw-r--r--Userland/Applications/DisplaySettings/main.cpp3
3 files changed, 14 insertions, 3 deletions
diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp
index 88b2d8afae..afdca487ea 100644
--- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp
+++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp
@@ -179,4 +179,14 @@ void MonitorSettingsWidget::show_screen_numbers(bool show)
GUI::WindowServerConnection::the().async_show_screen_numbers(show);
}
+void MonitorSettingsWidget::show_event(GUI::ShowEvent&)
+{
+ show_screen_numbers(true);
+}
+
+void MonitorSettingsWidget::hide_event(GUI::HideEvent&)
+{
+ show_screen_numbers(false);
+}
+
}
diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.h b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.h
index 28144bd4e2..4b5e609318 100644
--- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.h
+++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.h
@@ -28,6 +28,10 @@ public:
void apply_settings();
void show_screen_numbers(bool);
+protected:
+ void show_event(GUI::ShowEvent& event) override;
+ void hide_event(GUI::HideEvent& event) override;
+
private:
MonitorSettingsWidget();
diff --git a/Userland/Applications/DisplaySettings/main.cpp b/Userland/Applications/DisplaySettings/main.cpp
index ea14405669..5f88de9c96 100644
--- a/Userland/Applications/DisplaySettings/main.cpp
+++ b/Userland/Applications/DisplaySettings/main.cpp
@@ -50,9 +50,6 @@ int main(int argc, char** argv)
auto& font_settings_widget = tab_widget.add_tab<DisplaySettings::FontSettingsWidget>("Fonts");
auto& monitor_settings_widget = tab_widget.add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor");
auto& desktop_settings_widget = tab_widget.add_tab<DisplaySettings::DesktopSettingsWidget>("Workspaces");
- tab_widget.on_change = [&](auto& widget) {
- monitor_settings_widget.show_screen_numbers(&widget == &monitor_settings_widget);
- };
auto& button_container = main_widget.add<GUI::Widget>();
button_container.set_shrink_to_fit(true);