Преглед изворни кода

LibGUI: Add GUI::TabWidget::add_tab() that takes a constructed tab

This patch adds a new add_tab() function in GUI::TabWidget that takes
an already created NonnullRefPtr<Widget> object. This allows us to
handle errors while creating the Tab object and then pass it to this
function to actually add the object to the TabWidget.
Baitinq пре 2 година
родитељ
комит
61789de11d
1 измењених фајлова са 7 додато и 0 уклоњено
  1. 7 0
      Userland/Libraries/LibGUI/TabWidget.h

+ 7 - 0
Userland/Libraries/LibGUI/TabWidget.h

@@ -73,6 +73,13 @@ public:
         return *t;
         return *t;
     }
     }
 
 
+    ErrorOr<void> add_tab(NonnullRefPtr<Widget> const& tab, DeprecatedString title)
+    {
+        tab->set_title(move(title));
+        TRY(try_add_widget(*tab));
+        return {};
+    }
+
     void remove_tab(Widget& tab) { remove_widget(tab); }
     void remove_tab(Widget& tab) { remove_widget(tab); }
     void remove_all_tabs_except(Widget& tab);
     void remove_all_tabs_except(Widget& tab);