summaryrefslogtreecommitdiff
path: root/Applications/Browser
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-23 21:43:24 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-23 21:43:24 +0200
commit1b8b492258d2d31e313e4a30eb54ef86bc38fd7b (patch)
treea50da84065a54da5aa884b5883741c5d36c2f4f7 /Applications/Browser
parent4087e3cfb9ddc88396b42d9e1e7509061ded51d4 (diff)
downloadserenity-1b8b492258d2d31e313e4a30eb54ef86bc38fd7b.zip
Browser: Add "next tab" and "previous tab" actions
Now you can switch between the open tabs with Ctrl+PgUp and Ctrl+PgDn
Diffstat (limited to 'Applications/Browser')
-rw-r--r--Applications/Browser/WindowActions.cpp14
-rw-r--r--Applications/Browser/WindowActions.h6
-rw-r--r--Applications/Browser/main.cpp8
3 files changed, 28 insertions, 0 deletions
diff --git a/Applications/Browser/WindowActions.cpp b/Applications/Browser/WindowActions.cpp
index e5169ea7b8..99f0bc8654 100644
--- a/Applications/Browser/WindowActions.cpp
+++ b/Applications/Browser/WindowActions.cpp
@@ -21,6 +21,20 @@ WindowActions::WindowActions(GUI::Window& window)
on_create_new_tab();
},
&window);
+
+ m_next_tab_action = GUI::Action::create(
+ "Next tab", { Mod_Ctrl, Key_PageDown }, [this](auto&) {
+ if (on_next_tab)
+ on_next_tab();
+ },
+ &window);
+
+ m_previous_tab_action = GUI::Action::create(
+ "Previous tab", { Mod_Ctrl, Key_PageUp }, [this](auto&) {
+ if (on_previous_tab)
+ on_previous_tab();
+ },
+ &window);
}
}
diff --git a/Applications/Browser/WindowActions.h b/Applications/Browser/WindowActions.h
index 8b64fa2fe9..0ae2e1a64e 100644
--- a/Applications/Browser/WindowActions.h
+++ b/Applications/Browser/WindowActions.h
@@ -11,11 +11,17 @@ public:
WindowActions(GUI::Window&);
Function<void()> on_create_new_tab;
+ Function<void()> on_next_tab;
+ Function<void()> on_previous_tab;
GUI::Action& create_new_tab_action() { return *m_create_new_tab_action; }
+ GUI::Action& next_tab_action() { return *m_next_tab_action; }
+ GUI::Action& previous_tab_action() { return *m_previous_tab_action; }
private:
RefPtr<GUI::Action> m_create_new_tab_action;
+ RefPtr<GUI::Action> m_next_tab_action;
+ RefPtr<GUI::Action> m_previous_tab_action;
};
}
diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp
index 16502bc97f..6bc9f1b907 100644
--- a/Applications/Browser/main.cpp
+++ b/Applications/Browser/main.cpp
@@ -131,6 +131,14 @@ int main(int argc, char** argv)
create_new_tab();
};
+ window_actions.on_next_tab = [&] {
+ tab_widget.activate_next_tab();
+ };
+
+ window_actions.on_previous_tab = [&] {
+ tab_widget.activate_previous_tab();
+ };
+
create_new_tab();
return app.exec();