summaryrefslogtreecommitdiff
path: root/Applications/DisplayProperties
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-23 12:23:48 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-23 12:27:53 +0100
commit6c5100b644d6f1f9581ae69943be0e5072e5b420 (patch)
tree9ea295a061cb15f16a5a4d38ad549ec1ec95c996 /Applications/DisplayProperties
parentbbc02af0903a3515ac3cd8fed058d9f7b52128cb (diff)
downloadserenity-6c5100b644d6f1f9581ae69943be0e5072e5b420.zip
LibGUI: Add helper for constructing new TabWidget tabs
This patch adds the following convenience helper: auto tab_widget = GUI::TabWidget::construct(); auto my_widget = tab_widget->add_tab<GUI::Widget>("My tab", ...); The above is equivalent to: auto tab_widget = GUI::TabWidget::construct(); auto my_widget = GUI::Widget::construct(...); tab_widget->add_widget("My tab", my_widget);
Diffstat (limited to 'Applications/DisplayProperties')
-rw-r--r--Applications/DisplayProperties/DisplayProperties.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/Applications/DisplayProperties/DisplayProperties.cpp b/Applications/DisplayProperties/DisplayProperties.cpp
index 1760dfd47f..da6c96f499 100644
--- a/Applications/DisplayProperties/DisplayProperties.cpp
+++ b/Applications/DisplayProperties/DisplayProperties.cpp
@@ -124,17 +124,15 @@ void DisplayPropertiesWidget::create_frame()
{
auto tab_widget = m_root_widget->add<GUI::TabWidget>();
- // First, let's create the "Background" tab
- auto background_splitter = GUI::VerticalSplitter::construct();
- tab_widget->add_widget("Wallpaper", background_splitter);
+ auto wallpaper_splitter = tab_widget->add_tab<GUI::VerticalSplitter>("Wallpaper");
- auto background_content = background_splitter->add<GUI::Widget>();
- background_content->set_layout(make<GUI::VerticalBoxLayout>());
- background_content->layout()->set_margins({ 4, 4, 4, 4 });
+ auto wallpaper_content = wallpaper_splitter->add<GUI::Widget>();
+ wallpaper_content->set_layout(make<GUI::VerticalBoxLayout>());
+ wallpaper_content->layout()->set_margins({ 4, 4, 4, 4 });
- m_wallpaper_preview = background_splitter->add<GUI::Label>();
+ m_wallpaper_preview = wallpaper_splitter->add<GUI::Label>();
- auto wallpaper_list = background_content->add<GUI::ListView>();
+ auto wallpaper_list = wallpaper_content->add<GUI::ListView>();
wallpaper_list->set_background_color(Color::White);
wallpaper_list->set_model(*ItemListModel<AK::String>::create(m_wallpapers));
@@ -154,9 +152,7 @@ void DisplayPropertiesWidget::create_frame()
m_wallpaper_preview->set_should_stretch_icon(true);
};
- // Let's add the settings tab
- auto settings_splitter = GUI::VerticalSplitter::construct();
- tab_widget->add_widget("Settings", settings_splitter);
+ auto settings_splitter = tab_widget->add_tab<GUI::VerticalSplitter>("Settings");
auto settings_content = settings_splitter->add<GUI::Widget>();
settings_content->set_layout(make<GUI::VerticalBoxLayout>());