From 79a87e740a49ba5d12ca5b6b0527cdc3c6446145 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 4 Aug 2019 16:29:54 +0300 Subject: [PATCH] Added new submenu in menu bar for OS X to switch tabs with hotkeys. - Fixed #1176. - https://bugreports.qt.io/browse/QTBUG-8596 --- src/widgets/Window.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 84e1252d4..44d739210 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -346,12 +346,25 @@ void Window::addMenuBar() QMenuBar *mainMenu = new QMenuBar(); mainMenu->setNativeMenuBar(true); - QMenu *menu = new QMenu(QString()); - mainMenu->addMenu(menu); + // First menu. + QMenu *menu = mainMenu->addMenu(QString()); QAction *prefs = menu->addAction(QString()); prefs->setMenuRole(QAction::PreferencesRole); connect(prefs, &QAction::triggered, this, [] { SettingsDialog::showDialog(); }); + + // Window menu. + QMenu *windowMenu = mainMenu->addMenu(QString("Window")); + + QAction *nextTab = windowMenu->addAction(QString("Select next tab")); + nextTab->setShortcuts({QKeySequence("Meta+Tab")}); + connect(nextTab, &QAction::triggered, this, + [=] { this->notebook_->selectNextTab(); }); + + QAction *prevTab = windowMenu->addAction(QString("Select previous tab")); + prevTab->setShortcuts({QKeySequence("Meta+Shift+Tab")}); + connect(prevTab, &QAction::triggered, this, + [=] { this->notebook_->selectPreviousTab(); }); } #define UGLYMACROHACK1(s) #s