mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
LibGUI: Make GUI::SettingsWindow::add_tab() return ErrorOr
This allows us to use TRY() when creating settings UI.
This commit is contained in:
parent
7c19e86a50
commit
45844f9338
Notes:
sideshowbarker
2024-07-18 00:36:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/45844f93384
@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
|
|
||||||
auto window = TRY(GUI::SettingsWindow::try_create("Browser Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
|
auto window = TRY(GUI::SettingsWindow::try_create("Browser Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
window->add_tab<BrowserSettingsWidget>("Browser");
|
TRY(window->add_tab<BrowserSettingsWidget>("Browser"));
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
return app->exec();
|
return app->exec();
|
||||||
|
@ -27,10 +27,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
auto app_icon = GUI::Icon::default_icon("app-display-settings");
|
auto app_icon = GUI::Icon::default_icon("app-display-settings");
|
||||||
|
|
||||||
auto window = TRY(GUI::SettingsWindow::try_create("Display Settings"));
|
auto window = TRY(GUI::SettingsWindow::try_create("Display Settings"));
|
||||||
window->add_tab<DisplaySettings::BackgroundSettingsWidget>("Background");
|
TRY(window->add_tab<DisplaySettings::BackgroundSettingsWidget>("Background"));
|
||||||
window->add_tab<DisplaySettings::FontSettingsWidget>("Fonts");
|
TRY(window->add_tab<DisplaySettings::FontSettingsWidget>("Fonts"));
|
||||||
window->add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor");
|
TRY(window->add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor"));
|
||||||
window->add_tab<DisplaySettings::DesktopSettingsWidget>("Workspaces");
|
TRY(window->add_tab<DisplaySettings::DesktopSettingsWidget>("Workspaces"));
|
||||||
|
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
|
|
||||||
auto window = TRY(GUI::SettingsWindow::try_create("Keyboard Settings"));
|
auto window = TRY(GUI::SettingsWindow::try_create("Keyboard Settings"));
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
window->add_tab<KeyboardSettingsWidget>("Keyboard");
|
TRY(window->add_tab<KeyboardSettingsWidget>("Keyboard"));
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
return app->exec();
|
return app->exec();
|
||||||
|
@ -28,7 +28,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
auto app_icon = GUI::Icon::default_icon("app-mail");
|
auto app_icon = GUI::Icon::default_icon("app-mail");
|
||||||
|
|
||||||
auto window = GUI::SettingsWindow::construct("Mail Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes);
|
auto window = GUI::SettingsWindow::construct("Mail Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes);
|
||||||
window->add_tab<MailSettingsWidget>("Mail");
|
TRY(window->add_tab<MailSettingsWidget>("Mail"));
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
@ -26,8 +26,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
auto app_icon = GUI::Icon::default_icon("app-mouse");
|
auto app_icon = GUI::Icon::default_icon("app-mouse");
|
||||||
|
|
||||||
auto window = TRY(GUI::SettingsWindow::try_create("Mouse Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
|
auto window = TRY(GUI::SettingsWindow::try_create("Mouse Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
|
||||||
window->add_tab<MouseWidget>("Mouse");
|
TRY(window->add_tab<MouseWidget>("Mouse"));
|
||||||
window->add_tab<ThemeWidget>("Cursor Theme");
|
TRY(window->add_tab<ThemeWidget>("Cursor Theme"));
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
@ -28,8 +28,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
|
|
||||||
auto window = TRY(GUI::SettingsWindow::try_create("Terminal Settings"));
|
auto window = TRY(GUI::SettingsWindow::try_create("Terminal Settings"));
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
window->add_tab<TerminalSettingsMainWidget>("Terminal");
|
TRY(window->add_tab<TerminalSettingsMainWidget>("Terminal"));
|
||||||
window->add_tab<TerminalSettingsViewWidget>("View");
|
TRY(window->add_tab<TerminalSettingsViewWidget>("View"));
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
return app->exec();
|
return app->exec();
|
||||||
|
@ -32,11 +32,11 @@ public:
|
|||||||
virtual ~SettingsWindow() override;
|
virtual ~SettingsWindow() override;
|
||||||
|
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
T& add_tab(StringView const& title, Args&&... args)
|
ErrorOr<NonnullRefPtr<T>> add_tab(String title, Args&&... args)
|
||||||
{
|
{
|
||||||
auto& t = m_tab_widget->add_tab<T>(title, forward<Args>(args)...);
|
auto tab = TRY(m_tab_widget->try_add_tab<T>(move(title), forward<Args>(args)...));
|
||||||
m_tabs.append(t);
|
TRY(m_tabs.try_append(tab));
|
||||||
return t;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user