diff options
author | Olivier De Cannière <icristalrope@gmail.com> | 2022-03-16 20:06:27 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-02 23:38:32 +0200 |
commit | 1b7850f5114c22683e4c8115c5124409f41f4e42 (patch) | |
tree | 48b02c12d8bc667324aa6634b1a5381633309b88 /Userland/Libraries | |
parent | 04b6a060ca134ab809c1ff68901de9f78df217d1 (diff) | |
download | serenity-1b7850f5114c22683e4c8115c5124409f41f4e42.zip |
LibGUI: Add TabWidget::activate_last_tab()
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/TabWidget.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/TabWidget.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp index c855b76d62..2d97c4a9d1 100644 --- a/Userland/Libraries/LibGUI/TabWidget.cpp +++ b/Userland/Libraries/LibGUI/TabWidget.cpp @@ -592,6 +592,14 @@ void TabWidget::activate_previous_tab() set_active_widget(m_tabs.at(previous_index).widget); } +void TabWidget::activate_last_tab() +{ + size_t number_of_tabs = m_tabs.size(); + if (number_of_tabs == 0) + return; + set_active_widget(m_tabs.at(number_of_tabs - 1).widget); +} + void TabWidget::keydown_event(KeyEvent& event) { if (event.ctrl() && event.key() == Key_Tab) { diff --git a/Userland/Libraries/LibGUI/TabWidget.h b/Userland/Libraries/LibGUI/TabWidget.h index d723f3417b..f7f37031c5 100644 --- a/Userland/Libraries/LibGUI/TabWidget.h +++ b/Userland/Libraries/LibGUI/TabWidget.h @@ -66,6 +66,7 @@ public: void activate_next_tab(); void activate_previous_tab(); + void activate_last_tab(); void set_text_alignment(Gfx::TextAlignment alignment) { m_text_alignment = alignment; } Gfx::TextAlignment text_alignment() const { return m_text_alignment; } |