diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-23 12:23:48 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-23 12:27:53 +0100 |
commit | 6c5100b644d6f1f9581ae69943be0e5072e5b420 (patch) | |
tree | 9ea295a061cb15f16a5a4d38ad549ec1ec95c996 /Applications/SystemMonitor/main.cpp | |
parent | bbc02af0903a3515ac3cd8fed058d9f7b52128cb (diff) | |
download | serenity-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/SystemMonitor/main.cpp')
-rw-r--r-- | Applications/SystemMonitor/main.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 12d1803588..8c00fba9de 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -70,9 +70,9 @@ static String human_readable_size(u32 size) return String::format("%u GB", size / GB); } -static RefPtr<GUI::Widget> build_file_systems_tab(); -static RefPtr<GUI::Widget> build_pci_devices_tab(); -static RefPtr<GUI::Widget> build_devices_tab(); +static NonnullRefPtr<GUI::Widget> build_file_systems_tab(); +static NonnullRefPtr<GUI::Widget> build_pci_devices_tab(); +static NonnullRefPtr<GUI::Widget> build_devices_tab(); static NonnullRefPtr<GUI::Widget> build_graphs_tab(); int main(int argc, char** argv) @@ -123,8 +123,7 @@ int main(int argc, char** argv) auto tabwidget = keeper->add<GUI::TabWidget>(); - auto process_container_splitter = GUI::VerticalSplitter::construct(); - tabwidget->add_widget("Processes", process_container_splitter); + auto process_container_splitter = tabwidget->add_tab<GUI::VerticalSplitter>("Processes"); auto process_table_container = process_container_splitter->add<GUI::Widget>(); @@ -232,17 +231,10 @@ int main(int argc, char** argv) auto process_tab_widget = process_container_splitter->add<GUI::TabWidget>(); - auto memory_map_widget = ProcessMemoryMapWidget::construct(); - process_tab_widget->add_widget("Memory map", memory_map_widget); - - auto open_files_widget = ProcessFileDescriptorMapWidget::construct(); - process_tab_widget->add_widget("Open files", open_files_widget); - - auto unveiled_paths_widget = ProcessUnveiledPathsWidget::construct(); - process_tab_widget->add_widget("Unveiled paths", unveiled_paths_widget); - - auto stacks_widget = ProcessStacksWidget::construct(); - process_tab_widget->add_widget("Stacks", stacks_widget); + auto memory_map_widget = process_tab_widget->add_tab<ProcessMemoryMapWidget>("Memory map"); + auto open_files_widget = process_tab_widget->add_tab<ProcessFileDescriptorMapWidget>("Open files"); + auto unveiled_paths_widget = process_tab_widget->add_tab<ProcessUnveiledPathsWidget>("Unveiled paths"); + auto stacks_widget = process_tab_widget->add_tab<ProcessStacksWidget>("Stacks"); process_table_view->on_process_selected = [&](pid_t pid) { open_files_widget->set_pid(pid); @@ -276,7 +268,7 @@ public: } }; -RefPtr<GUI::Widget> build_file_systems_tab() +NonnullRefPtr<GUI::Widget> build_file_systems_tab() { auto fs_widget = GUI::LazyWidget::construct(); @@ -369,7 +361,7 @@ RefPtr<GUI::Widget> build_file_systems_tab() return fs_widget; } -RefPtr<GUI::Widget> build_pci_devices_tab() +NonnullRefPtr<GUI::Widget> build_pci_devices_tab() { auto pci_widget = GUI::LazyWidget::construct(); @@ -427,7 +419,7 @@ RefPtr<GUI::Widget> build_pci_devices_tab() return pci_widget; } -RefPtr<GUI::Widget> build_devices_tab() +NonnullRefPtr<GUI::Widget> build_devices_tab() { auto devices_widget = GUI::LazyWidget::construct(); |