Merge pull request #1178 from 23rd/patch-29-mac-ctrl-tab

Added new submenu in menu bar for OS X to switch tabs with hotkeys.
This commit is contained in:
pajlada 2019-08-10 13:22:33 +02:00 committed by GitHub
commit 0c245fbc4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -344,12 +344,25 @@ void Window::addMenuBar()
QMenuBar *mainMenu = new QMenuBar(); QMenuBar *mainMenu = new QMenuBar();
mainMenu->setNativeMenuBar(true); mainMenu->setNativeMenuBar(true);
QMenu *menu = new QMenu(QString()); // First menu.
mainMenu->addMenu(menu); QMenu *menu = mainMenu->addMenu(QString());
QAction *prefs = menu->addAction(QString()); QAction *prefs = menu->addAction(QString());
prefs->setMenuRole(QAction::PreferencesRole); prefs->setMenuRole(QAction::PreferencesRole);
connect(prefs, &QAction::triggered, this, connect(prefs, &QAction::triggered, this,
[] { SettingsDialog::showDialog(); }); [] { 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 #define UGLYMACROHACK1(s) #s