diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-04-21 15:34:53 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-04-21 17:24:42 +0200 |
commit | 5702f016f008109c8807ed0be4d93e1fa12be938 (patch) | |
tree | 57a7b539ea7a1b71c3b646f55ddcae3ba0c4218d /Userland/Libraries/LibGUI | |
parent | ded5ba1f8764e95e2c2b51e3e09200059a26c6c6 (diff) | |
download | serenity-5702f016f008109c8807ed0be4d93e1fa12be938.zip |
LibGUI+Applications: Add --open-tab option to FooSettings applications
Similar to SystemMonitor's option of the same name, this allows you to
launch the given application with the specific tab open.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/SettingsWindow.cpp | 14 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/SettingsWindow.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/SettingsWindow.cpp b/Userland/Libraries/LibGUI/SettingsWindow.cpp index 2a416872a4..deaa478468 100644 --- a/Userland/Libraries/LibGUI/SettingsWindow.cpp +++ b/Userland/Libraries/LibGUI/SettingsWindow.cpp @@ -76,4 +76,18 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(String title, Show return window; } +Optional<NonnullRefPtr<SettingsWindow::Tab>> SettingsWindow::get_tab(StringView id) const +{ + auto tab = m_tabs.find(id); + if (tab == m_tabs.end()) + return {}; + return tab->value; +} + +void SettingsWindow::set_active_tab(StringView id) +{ + if (auto tab = get_tab(id); tab.has_value()) + m_tab_widget->set_active_widget(tab.value()); +} + } diff --git a/Userland/Libraries/LibGUI/SettingsWindow.h b/Userland/Libraries/LibGUI/SettingsWindow.h index 4232396efc..05b9a4748d 100644 --- a/Userland/Libraries/LibGUI/SettingsWindow.h +++ b/Userland/Libraries/LibGUI/SettingsWindow.h @@ -42,6 +42,9 @@ public: return tab; } + Optional<NonnullRefPtr<Tab>> get_tab(StringView id) const; + void set_active_tab(StringView id); + private: SettingsWindow() = default; |