From f0c42b4adec948b43ef08062efa56d8dca2670ee Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Sat, 18 Jun 2022 23:30:09 +0200 Subject: [PATCH] Add Ctrl+Tab shortcut to cycle databases in unlock dialog The main window has both `Ctrl+PageUp` / `Ctrl+PageDown` and `Ctrl+Tab / Ctrl+Shift+Tab` shortcuts to cycle the database tabs. When in PR #5427 the abbility to select any open database in the unlock dialog was introduced, only the `Ctrl+PageUp` / `Ctrl+PageDown` shortcuts were added. This commit adds the `Ctrl+Tab / Ctrl+Shift+Tab` shortcuts to the unlock diaglog to fix this inconsistent UI behaviour. Signed-off-by: Daniel Ziegenberg --- src/gui/DatabaseOpenDialog.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/DatabaseOpenDialog.cpp b/src/gui/DatabaseOpenDialog.cpp index 799e82963e..e1b9391d00 100644 --- a/src/gui/DatabaseOpenDialog.cpp +++ b/src/gui/DatabaseOpenDialog.cpp @@ -59,13 +59,24 @@ DatabaseOpenDialog::DatabaseOpenDialog(QWidget* parent) setLayout(layout); setMinimumWidth(700); - // set up Ctrl+PageUp and Ctrl+PageDown shortcuts to cycle tabs + // set up Ctrl+PageUp / Ctrl+PageDown and Ctrl+Tab / Ctrl+Shift+Tab shortcuts to cycle tabs + // Ctrl+Tab is broken on Mac, so use Alt (i.e. the Option key) - https://bugreports.qt.io/browse/QTBUG-8596 + auto dbTabModifier = Qt::CTRL; +#ifdef Q_OS_MACOS + dbTabModifier = Qt::ALT; +#endif auto* shortcut = new QShortcut(Qt::CTRL + Qt::Key_PageUp, this); shortcut->setContext(Qt::WidgetWithChildrenShortcut); connect(shortcut, &QShortcut::activated, this, [this]() { selectTabOffset(-1); }); + shortcut = new QShortcut(dbTabModifier + Qt::Key_Tab, this); + shortcut->setContext(Qt::WidgetWithChildrenShortcut); + connect(shortcut, &QShortcut::activated, this, [this]() { selectTabOffset(-1); }); shortcut = new QShortcut(Qt::CTRL + Qt::Key_PageDown, this); shortcut->setContext(Qt::WidgetWithChildrenShortcut); connect(shortcut, &QShortcut::activated, this, [this]() { selectTabOffset(1); }); + shortcut = new QShortcut(dbTabModifier + Qt::SHIFT + Qt::Key_Tab, this); + shortcut->setContext(Qt::WidgetWithChildrenShortcut); + connect(shortcut, &QShortcut::activated, this, [this]() { selectTabOffset(1); }); } void DatabaseOpenDialog::selectTabOffset(int offset)