diff --git a/Libraries/LibGUI/TabWidget.cpp b/Libraries/LibGUI/TabWidget.cpp index 4bafddd049..5e46f267d0 100644 --- a/Libraries/LibGUI/TabWidget.cpp +++ b/Libraries/LibGUI/TabWidget.cpp @@ -113,6 +113,15 @@ void TabWidget::set_active_widget(Widget* widget) update_bar(); } +void TabWidget::set_tab_index(int index) +{ + if (m_tabs.at(index).widget == m_active_widget) + return; + set_active_widget(m_tabs.at(index).widget); + + update_bar(); +} + void TabWidget::resize_event(ResizeEvent& event) { if (!m_active_widget) diff --git a/Libraries/LibGUI/TabWidget.h b/Libraries/LibGUI/TabWidget.h index 9cd424b7d9..b9b2df63ff 100644 --- a/Libraries/LibGUI/TabWidget.h +++ b/Libraries/LibGUI/TabWidget.h @@ -48,6 +48,7 @@ public: Widget* active_widget() { return m_active_widget.ptr(); } const Widget* active_widget() const { return m_active_widget.ptr(); } void set_active_widget(Widget*); + void set_tab_index(int); int bar_height() const { return m_bar_visible ? 21 : 0; }