LibGUI+Applications: Port SettingsWindow::add_tab() to the new string

This commit is contained in:
Karol Kosek 2023-03-10 19:04:13 +01:00 committed by Andreas Kling
parent 797968c310
commit 446c600d09
11 changed files with 25 additions and 25 deletions

View file

@ -34,8 +34,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = TRY(GUI::SettingsWindow::create("Browser Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
window->set_icon(app_icon.bitmap_for_size(16));
(void)TRY(window->add_tab<BrowserSettingsWidget>("Browser"sv, "browser"sv));
(void)TRY(window->add_tab<ContentFilterSettingsWidget>("Content Filtering"sv, "content-filtering"sv));
(void)TRY(window->add_tab<BrowserSettingsWidget>("Browser"_short_string, "browser"sv));
(void)TRY(window->add_tab<ContentFilterSettingsWidget>(TRY("Content Filtering"_string), "content-filtering"sv));
window->set_active_tab(selected_tab);
window->show();

View file

@ -33,7 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = GUI::Icon::default_icon("app-calendar"sv);
auto window = TRY(GUI::SettingsWindow::create("Calendar Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
(void)TRY(window->add_tab<CalendarSettingsWidget>("Calendar"sv, "Calendar"sv));
(void)TRY(window->add_tab<CalendarSettingsWidget>(TRY("Calendar"_string), "Calendar"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->set_active_tab(selected_tab);

View file

@ -36,9 +36,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = GUI::Icon::default_icon("app-analog-clock"sv); // FIXME: Create a ClockSettings icon.
auto window = TRY(GUI::SettingsWindow::create("Clock Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
(void)TRY(window->add_tab<ClockSettingsWidget>("Clock"sv, "clock"sv));
(void)TRY(window->add_tab<ClockSettingsWidget>("Clock"_short_string, "clock"sv));
auto timezonesettings_widget = TRY(TimeZoneSettingsWidget::create());
TRY(window->add_tab(timezonesettings_widget, "Time Zone"sv, "time-zone"sv));
TRY(window->add_tab(timezonesettings_widget, TRY("Time Zone"_string), "time-zone"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->resize(540, 570);

View file

@ -37,12 +37,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool background_settings_changed = false;
auto window = TRY(GUI::SettingsWindow::create("Display Settings"));
(void)TRY(window->add_tab<DisplaySettings::BackgroundSettingsWidget>("Background"sv, "background"sv, background_settings_changed));
(void)TRY(window->add_tab<DisplaySettings::ThemesSettingsWidget>("Themes"sv, "themes"sv, background_settings_changed));
(void)TRY(window->add_tab<DisplaySettings::FontSettingsWidget>("Fonts"sv, "fonts"sv));
(void)TRY(window->add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor"sv, "monitor"sv));
(void)TRY(window->add_tab<DisplaySettings::DesktopSettingsWidget>("Workspaces"sv, "workspaces"sv));
(void)TRY(window->add_tab<GUI::DisplaySettings::EffectsSettingsWidget>("Effects"sv, "effects"sv));
(void)TRY(window->add_tab<DisplaySettings::BackgroundSettingsWidget>(TRY("Background"_string), "background"sv, background_settings_changed));
(void)TRY(window->add_tab<DisplaySettings::ThemesSettingsWidget>("Themes"_short_string, "themes"sv, background_settings_changed));
(void)TRY(window->add_tab<DisplaySettings::FontSettingsWidget>("Fonts"_short_string, "fonts"sv));
(void)TRY(window->add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor"_short_string, "monitor"sv));
(void)TRY(window->add_tab<DisplaySettings::DesktopSettingsWidget>(TRY("Workspaces"_string), "workspaces"sv));
(void)TRY(window->add_tab<GUI::DisplaySettings::EffectsSettingsWidget>("Effects"_short_string, "effects"sv));
window->set_active_tab(selected_tab);
window->set_icon(app_icon.bitmap_for_size(16));

View file

@ -35,8 +35,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = TRY(GUI::SettingsWindow::create("Games Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
window->set_icon(app_icon.bitmap_for_size(16));
(void)TRY(window->add_tab<GamesSettings::CardSettingsWidget>("Cards"sv, "cards"sv));
(void)TRY(window->add_tab<GamesSettings::ChessSettingsWidget>("Chess"sv, "chess"sv));
(void)TRY(window->add_tab<GamesSettings::CardSettingsWidget>("Cards"_short_string, "cards"sv));
(void)TRY(window->add_tab<GamesSettings::ChessSettingsWidget>("Chess"_short_string, "chess"sv));
window->set_active_tab(selected_tab);
window->show();

View file

@ -35,7 +35,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = TRY(GUI::SettingsWindow::create("Keyboard Settings"));
window->set_icon(app_icon.bitmap_for_size(16));
auto keyboard_settings_widget = TRY(window->add_tab<KeyboardSettingsWidget>("Keyboard"sv, "keyboard"sv));
auto keyboard_settings_widget = TRY(window->add_tab<KeyboardSettingsWidget>(TRY("Keyboard"_string), "keyboard"sv));
window->set_active_tab(selected_tab);
window->on_active_window_change = [&](bool is_active_window) {

View file

@ -34,7 +34,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = GUI::Icon::default_icon("app-mail"sv);
auto window = TRY(GUI::SettingsWindow::create("Mail Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
(void)TRY(window->add_tab<MailSettingsWidget>("Mail"sv, "mail"sv));
(void)TRY(window->add_tab<MailSettingsWidget>("Mail"_short_string, "mail"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->set_active_tab(selected_tab);

View file

@ -34,9 +34,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = GUI::Icon::default_icon("app-mouse"sv);
auto window = TRY(GUI::SettingsWindow::create("Mouse Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
(void)TRY(window->add_tab<MouseWidget>("Mouse"sv, "mouse"sv));
(void)TRY(window->add_tab<ThemeWidget>("Cursor Theme"sv, "cursor-theme"sv));
(void)TRY(window->add_tab<HighlightWidget>("Cursor Highlight"sv, "cursor-highlight"sv));
(void)TRY(window->add_tab<MouseWidget>("Mouse"_short_string, "mouse"sv));
(void)TRY(window->add_tab<ThemeWidget>(TRY("Cursor Theme"_string), "cursor-theme"sv));
(void)TRY(window->add_tab<HighlightWidget>(TRY("Cursor Highlight"_string), "cursor-highlight"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->set_active_tab(selected_tab);

View file

@ -44,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
auto app_icon = GUI::Icon::default_icon("network"sv);
auto window = TRY(GUI::SettingsWindow::create("Network Settings", GUI::SettingsWindow::ShowDefaultsButton::No));
auto network_settings_widget = TRY(window->add_tab<NetworkSettings::NetworkSettingsWidget>("Network"sv, "network"sv));
auto network_settings_widget = TRY(window->add_tab<NetworkSettings::NetworkSettingsWidget>("Network"_short_string, "network"sv));
if (!adapter.is_null()) {
network_settings_widget->switch_adapter(adapter);
}

View file

@ -32,8 +32,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = TRY(GUI::SettingsWindow::create("Terminal Settings"));
window->set_icon(app_icon.bitmap_for_size(16));
(void)TRY(window->add_tab<TerminalSettingsViewWidget>("View"sv, "view"sv));
(void)TRY(window->add_tab<TerminalSettingsMainWidget>("Terminal"sv, "terminal"sv));
(void)TRY(window->add_tab<TerminalSettingsViewWidget>("View"_short_string, "view"sv));
(void)TRY(window->add_tab<TerminalSettingsMainWidget>(TRY("Terminal"_string), "terminal"sv));
window->set_active_tab(selected_tab);
window->show();

View file

@ -47,17 +47,17 @@ public:
virtual ~SettingsWindow() override = default;
template<class T, class... Args>
ErrorOr<NonnullRefPtr<T>> add_tab(DeprecatedString title, StringView id, Args&&... args)
ErrorOr<NonnullRefPtr<T>> add_tab(String title, StringView id, Args&&... args)
{
auto tab = TRY(m_tab_widget->try_add_tab<T>(TRY(String::from_deprecated_string(title)), forward<Args>(args)...));
auto tab = TRY(m_tab_widget->try_add_tab<T>(move(title), forward<Args>(args)...));
TRY(m_tabs.try_set(id, tab));
tab->set_settings_window(*this);
return tab;
}
ErrorOr<void> add_tab(NonnullRefPtr<Tab> const& tab, DeprecatedString title, StringView id)
ErrorOr<void> add_tab(NonnullRefPtr<Tab> const& tab, String title, StringView id)
{
tab->set_title(TRY(String::from_deprecated_string(title)));
tab->set_title(move(title));
TRY(m_tab_widget->try_add_widget(*tab));
TRY(m_tabs.try_set(id, tab));
tab->set_settings_window(*this);