From 4e2464d4405205e0ba1c1e0a36b029ce7b993d8d Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sun, 1 Dec 2024 15:13:32 -0500 Subject: [PATCH] Add copy shortcuts to Auto-Type select dialog * Fixes #10213 * Sets copy password/username/totp to Ctrl+Shift+1/2/3 respectively --- src/autotype/AutoTypeSelectDialog.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/autotype/AutoTypeSelectDialog.cpp b/src/autotype/AutoTypeSelectDialog.cpp index c8fa1480e3..c40db9c58e 100644 --- a/src/autotype/AutoTypeSelectDialog.cpp +++ b/src/autotype/AutoTypeSelectDialog.cpp @@ -330,15 +330,7 @@ void AutoTypeSelectDialog::buildActionMenu() }); #endif - // Qt 5.10 introduced a new "feature" to hide shortcuts in context menus - // Unfortunately, Qt::AA_DontShowShortcutsInContextMenus is broken, have to manually enable them - typeUsernameAction->setShortcutVisibleInContextMenu(true); - typePasswordAction->setShortcutVisibleInContextMenu(true); - typeTotpAction->setShortcutVisibleInContextMenu(true); -#if defined(Q_OS_WIN) || defined(Q_OS_MAC) - typeVirtualAction->setShortcutVisibleInContextMenu(true); -#endif - + copyUsernameAction->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_1); copyUsernameAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::USERNAME); connect(copyUsernameAction, &QAction::triggered, this, [&] { auto entry = m_ui->view->currentMatch().first; @@ -348,6 +340,7 @@ void AutoTypeSelectDialog::buildActionMenu() } }); + copyPasswordAction->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_2); copyPasswordAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::PASSWORD); connect(copyPasswordAction, &QAction::triggered, this, [&] { auto entry = m_ui->view->currentMatch().first; @@ -357,6 +350,7 @@ void AutoTypeSelectDialog::buildActionMenu() } }); + copyTotpAction->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_3); copyTotpAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::TOTP); connect(copyTotpAction, &QAction::triggered, this, [&] { auto entry = m_ui->view->currentMatch().first; @@ -365,6 +359,18 @@ void AutoTypeSelectDialog::buildActionMenu() reject(); } }); + + // Qt 5.10 introduced a new "feature" to hide shortcuts in context menus + // Unfortunately, Qt::AA_DontShowShortcutsInContextMenus is broken, have to manually enable them + typeUsernameAction->setShortcutVisibleInContextMenu(true); + typePasswordAction->setShortcutVisibleInContextMenu(true); + typeTotpAction->setShortcutVisibleInContextMenu(true); +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) + typeVirtualAction->setShortcutVisibleInContextMenu(true); +#endif + copyUsernameAction->setShortcutVisibleInContextMenu(true); + copyPasswordAction->setShortcutVisibleInContextMenu(true); + copyTotpAction->setShortcutVisibleInContextMenu(true); } void AutoTypeSelectDialog::showEvent(QShowEvent* event)