From 6c5100b644d6f1f9581ae69943be0e5072e5b420 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 23 Feb 2020 12:23:48 +0100 Subject: 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("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); --- Applications/SystemMonitor/main.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'Applications/SystemMonitor') 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 build_file_systems_tab(); -static RefPtr build_pci_devices_tab(); -static RefPtr build_devices_tab(); +static NonnullRefPtr build_file_systems_tab(); +static NonnullRefPtr build_pci_devices_tab(); +static NonnullRefPtr build_devices_tab(); static NonnullRefPtr build_graphs_tab(); int main(int argc, char** argv) @@ -123,8 +123,7 @@ int main(int argc, char** argv) auto tabwidget = keeper->add(); - auto process_container_splitter = GUI::VerticalSplitter::construct(); - tabwidget->add_widget("Processes", process_container_splitter); + auto process_container_splitter = tabwidget->add_tab("Processes"); auto process_table_container = process_container_splitter->add(); @@ -232,17 +231,10 @@ int main(int argc, char** argv) auto process_tab_widget = process_container_splitter->add(); - 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("Memory map"); + auto open_files_widget = process_tab_widget->add_tab("Open files"); + auto unveiled_paths_widget = process_tab_widget->add_tab("Unveiled paths"); + auto stacks_widget = process_tab_widget->add_tab("Stacks"); process_table_view->on_process_selected = [&](pid_t pid) { open_files_widget->set_pid(pid); @@ -276,7 +268,7 @@ public: } }; -RefPtr build_file_systems_tab() +NonnullRefPtr build_file_systems_tab() { auto fs_widget = GUI::LazyWidget::construct(); @@ -369,7 +361,7 @@ RefPtr build_file_systems_tab() return fs_widget; } -RefPtr build_pci_devices_tab() +NonnullRefPtr build_pci_devices_tab() { auto pci_widget = GUI::LazyWidget::construct(); @@ -427,7 +419,7 @@ RefPtr build_pci_devices_tab() return pci_widget; } -RefPtr build_devices_tab() +NonnullRefPtr build_devices_tab() { auto devices_widget = GUI::LazyWidget::construct(); -- cgit v1.2.3