Skip to content

Commit

Permalink
Add copy shortcuts to Auto-Type select dialog
Browse files Browse the repository at this point in the history
* Fixes #10213
* Sets copy password/username/totp to Ctrl+Shift+1/2/3 respectively
  • Loading branch information
droidmonkey committed Dec 2, 2024
1 parent 9a63e80 commit 5a3da59
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/autotype/AutoTypeSelectDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 5a3da59

Please sign in to comment.