Skip to content

Commit

Permalink
Enable browser-like DbTab (Alt + Num) experience across platforms
Browse files Browse the repository at this point in the history
This is follow up of:
 PR keepassxreboot#4063 Enable browser-like DbTab experience (Alt + Nums)
 PR keepassxreboot#4305 Fix browser-like DbTab experience with macOS
This commit introduces desired behaviour across platforms.
 On MacOS only Command key + Nums combination should be used. (on MacOS, ⌘Command is QT::CTRL)
 On Linux and Windows there are combinations with Ctrl and (Left) Alt. (code could be reused)

This is not breaking for various keyboard layout organization on MacOS because of @varjolintu fixes,
nor breaking on Linux or Windows because they use AltGr (Right Alt) as modkey.
  • Loading branch information
JulianVolodia committed Feb 9, 2020
1 parent c560a2c commit ba16e3d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ MainWindow::MainWindow()
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this, SLOT(selectPreviousDatabaseTab()));
new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(selectPreviousDatabaseTab()));

#ifdef Q_OS_MACOS
auto shortcut = new QShortcut(Qt::CTRL + Qt::Key_1, this);
connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(1); });
shortcut = new QShortcut(Qt::CTRL + Qt::Key_2, this);
Expand All @@ -321,8 +320,8 @@ MainWindow::MainWindow()
shortcut = new QShortcut(Qt::CTRL + Qt::Key_8, this);
connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(8); });
new QShortcut(Qt::CTRL + Qt::Key_9, this, SLOT(selectLastDatabaseTab()));
#else
auto shortcut = new QShortcut(Qt::ALT + Qt::Key_1, this);
#if defined(Q_OS_WIN) || (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
shortcut = new QShortcut(Qt::ALT + Qt::Key_1, this);
connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(1); });
shortcut = new QShortcut(Qt::ALT + Qt::Key_2, this);
connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(2); });
Expand Down

0 comments on commit ba16e3d

Please sign in to comment.