diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp index a5d2f000b3..6e680b38ff 100644 --- a/Userland/Libraries/LibGUI/TabWidget.cpp +++ b/Userland/Libraries/LibGUI/TabWidget.cpp @@ -68,15 +68,20 @@ void TabWidget::add_widget(const StringView& title, Widget& widget) m_tabs.append({ title, nullptr, &widget }); add_child(widget); update_focus_policy(); + if (on_tab_count_change) + on_tab_count_change(m_tabs.size()); } void TabWidget::remove_widget(Widget& widget) { + VERIFY(widget.parent() == this); if (active_widget() == &widget) activate_next_tab(); m_tabs.remove_first_matching([&widget](auto& entry) { return &widget == entry.widget; }); remove_child(widget); update_focus_policy(); + if (on_tab_count_change) + on_tab_count_change(m_tabs.size()); } void TabWidget::update_focus_policy() diff --git a/Userland/Libraries/LibGUI/TabWidget.h b/Userland/Libraries/LibGUI/TabWidget.h index b9b2df63ff..d8f078c75c 100644 --- a/Userland/Libraries/LibGUI/TabWidget.h +++ b/Userland/Libraries/LibGUI/TabWidget.h @@ -84,6 +84,7 @@ public: void set_bar_visible(bool bar_visible); bool is_bar_visible() const { return m_bar_visible; }; + Function on_tab_count_change; Function on_change; Function on_middle_click; Function on_context_menu_request;