@@ -46,6 +46,18 @@ BrowserWindow::BrowserWindow()
46
46
quit_action->setShortcut (QKeySequence (Qt::CTRL | Qt::Key_Q));
47
47
menu->addAction (quit_action);
48
48
49
+ auto * view_menu = menuBar ()->addMenu (" &View" );
50
+
51
+ auto * open_next_tab_action = new QAction (" Open &Next Tab" );
52
+ open_next_tab_action->setShortcut (QKeySequence (Qt::CTRL | Qt::Key_PageDown));
53
+ view_menu->addAction (open_next_tab_action);
54
+ QObject::connect (open_next_tab_action, &QAction::triggered, this , &BrowserWindow::open_next_tab);
55
+
56
+ auto * open_previous_tab_action = new QAction (" Open &Previous Tab" );
57
+ open_previous_tab_action->setShortcut (QKeySequence (Qt::CTRL | Qt::Key_PageUp));
58
+ view_menu->addAction (open_previous_tab_action);
59
+ QObject::connect (open_previous_tab_action, &QAction::triggered, this , &BrowserWindow::open_previous_tab);
60
+
49
61
auto * inspect_menu = menuBar ()->addMenu (" &Inspect" );
50
62
51
63
auto * view_source_action = new QAction (" View &Source" );
@@ -258,3 +270,25 @@ void BrowserWindow::tab_favicon_changed(int index, QIcon icon)
258
270
m_tabs_container->setTabIcon (index, icon);
259
271
setWindowIcon (icon);
260
272
}
273
+
274
+ void BrowserWindow::open_next_tab ()
275
+ {
276
+ if (m_tabs_container->count () <= 1 )
277
+ return ;
278
+
279
+ auto next_index = m_tabs_container->currentIndex () + 1 ;
280
+ if (next_index >= m_tabs_container->count ())
281
+ next_index = 0 ;
282
+ m_tabs_container->setCurrentIndex (next_index);
283
+ }
284
+
285
+ void BrowserWindow::open_previous_tab ()
286
+ {
287
+ if (m_tabs_container->count () <= 1 )
288
+ return ;
289
+
290
+ auto next_index = m_tabs_container->currentIndex () - 1 ;
291
+ if (next_index < 0 )
292
+ next_index = m_tabs_container->count () - 1 ;
293
+ m_tabs_container->setCurrentIndex (next_index);
294
+ }
0 commit comments