diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts index 113053acb..3b34abb9f 100644 --- a/share/translations/keepassxc_en.ts +++ b/share/translations/keepassxc_en.ts @@ -800,15 +800,6 @@ Double click a row to perform Auto-Type or find an entry using the search: - - <p>You can use advanced search queries to find any entry in your open databases. The following shortcuts are useful:<br/> -Ctrl+F - Toggle database search<br/> -Ctrl+1 - Type username<br/> -Ctrl+2 - Type password<br/> -Ctrl+3 - Type TOTP<br/> -Ctrl+4 - Use Virtual Keyboard (Windows Only)</p> - - Search all open databases @@ -853,6 +844,24 @@ Ctrl+4 - Use Virtual Keyboard (Windows Only)</p> Use Virtual Keyboard + + <p>You can use advanced search queries to find any entry in your open databases. The following shortcuts are useful:<br/> +Ctrl+F - Toggle database search<br/> +Ctrl+1 - Type username<br/> +Ctrl+2 - Type password<br/> +Ctrl+3 - Type TOTP<br/> +Ctrl+4 - Type URL<br/> +Ctrl+5 - Use Virtual Keyboard (Windows Only)</p> + + + + Type {URL} + + + + Copy URL + + BrowserAccessControlDialog diff --git a/src/autotype/AutoTypeSelectDialog.cpp b/src/autotype/AutoTypeSelectDialog.cpp index d06eaa1c3..3810418b5 100644 --- a/src/autotype/AutoTypeSelectDialog.cpp +++ b/src/autotype/AutoTypeSelectDialog.cpp @@ -37,6 +37,7 @@ enum MENU_FIELD USERNAME = 1, PASSWORD, TOTP, + URL, }; AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent) @@ -265,6 +266,7 @@ void AutoTypeSelectDialog::updateActionMenu(const AutoTypeMatch& match) bool hasUsername = !match.first->username().isEmpty(); bool hasPassword = !match.first->password().isEmpty(); bool hasTotp = match.first->hasValidTotp(); + bool hasUrl = !match.first->url().isEmpty(); for (auto action : m_actionMenu->actions()) { auto prop = action->property(MENU_FIELD_PROP_NAME); @@ -279,6 +281,9 @@ void AutoTypeSelectDialog::updateActionMenu(const AutoTypeMatch& match) case MENU_FIELD::TOTP: action->setEnabled(hasTotp); break; + case MENU_FIELD::URL: + action->setEnabled(hasUrl); + break; } } } @@ -290,15 +295,19 @@ void AutoTypeSelectDialog::buildActionMenu() auto typeUsernameAction = new QAction(icons()->icon("auto-type"), tr("Type {USERNAME}"), this); auto typePasswordAction = new QAction(icons()->icon("auto-type"), tr("Type {PASSWORD}"), this); auto typeTotpAction = new QAction(icons()->icon("auto-type"), tr("Type {TOTP}"), this); + auto typeUrlAction = new QAction(icons()->icon("auto-type"), tr("Type {URL}"), this); auto copyUsernameAction = new QAction(icons()->icon("username-copy"), tr("Copy Username"), this); auto copyPasswordAction = new QAction(icons()->icon("password-copy"), tr("Copy Password"), this); auto copyTotpAction = new QAction(icons()->icon("totp"), tr("Copy TOTP"), this); + auto copyUrlAction = new QAction(icons()->icon("url-copy"), tr("Copy URL"), this); m_actionMenu->addAction(typeUsernameAction); m_actionMenu->addAction(typePasswordAction); m_actionMenu->addAction(typeTotpAction); + m_actionMenu->addAction(typeUrlAction); m_actionMenu->addAction(copyUsernameAction); m_actionMenu->addAction(copyPasswordAction); m_actionMenu->addAction(copyTotpAction); + m_actionMenu->addAction(copyUrlAction); typeUsernameAction->setShortcut(Qt::CTRL + Qt::Key_1); typeUsernameAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::USERNAME); @@ -324,10 +333,18 @@ void AutoTypeSelectDialog::buildActionMenu() submitAutoTypeMatch(match); }); + typeUrlAction->setShortcut(Qt::CTRL + Qt::Key_4); + typeUrlAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::URL); + connect(typeUrlAction, &QAction::triggered, this, [&] { + auto match = m_ui->view->currentMatch(); + match.second = "{URL}"; + submitAutoTypeMatch(match); + }); + #if defined(Q_OS_WIN) || defined(Q_OS_MAC) auto typeVirtualAction = new QAction(icons()->icon("auto-type"), tr("Use Virtual Keyboard"), nullptr); m_actionMenu->insertAction(copyUsernameAction, typeVirtualAction); - typeVirtualAction->setShortcut(Qt::CTRL + Qt::Key_4); + typeVirtualAction->setShortcut(Qt::CTRL + Qt::Key_5); connect(typeVirtualAction, &QAction::triggered, this, [&] { m_virtualMode = true; activateCurrentMatch(); @@ -364,17 +381,29 @@ void AutoTypeSelectDialog::buildActionMenu() } }); + copyUrlAction->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_4); + copyUrlAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::URL); + connect(copyUrlAction, &QAction::triggered, this, [&] { + auto entry = m_ui->view->currentMatch().first; + if (entry) { + clipboard()->setText(entry->resolvePlaceholder(entry->url())); + 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); + typeUrlAction->setShortcutVisibleInContextMenu(true); #if defined(Q_OS_WIN) || defined(Q_OS_MAC) typeVirtualAction->setShortcutVisibleInContextMenu(true); #endif copyUsernameAction->setShortcutVisibleInContextMenu(true); copyPasswordAction->setShortcutVisibleInContextMenu(true); copyTotpAction->setShortcutVisibleInContextMenu(true); + copyUrlAction->setShortcutVisibleInContextMenu(true); } void AutoTypeSelectDialog::showEvent(QShowEvent* event) diff --git a/src/autotype/AutoTypeSelectDialog.ui b/src/autotype/AutoTypeSelectDialog.ui index 0c5e3c8c2..0c0f6561e 100644 --- a/src/autotype/AutoTypeSelectDialog.ui +++ b/src/autotype/AutoTypeSelectDialog.ui @@ -50,13 +50,14 @@ Qt::NoFocus - - <p>You can use advanced search queries to find any entry in your open databases. The following shortcuts are useful:<br/> -Ctrl+F - Toggle database search<br/> -Ctrl+1 - Type username<br/> -Ctrl+2 - Type password<br/> -Ctrl+3 - Type TOTP<br/> -Ctrl+4 - Use Virtual Keyboard (Windows Only)</p> + + <p>You can use advanced search queries to find any entry in your open databases. The following shortcuts are useful:<br/> +Ctrl+F - Toggle database search<br/> +Ctrl+1 - Type username<br/> +Ctrl+2 - Type password<br/> +Ctrl+3 - Type TOTP<br/> +Ctrl+4 - Type URL<br/> +Ctrl+5 - Use Virtual Keyboard (Windows Only)</p> QToolButton { diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index e84916960..73434c3a4 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -924,6 +924,16 @@ void DatabaseWidget::performAutoTypeTOTP() performAutoType(QStringLiteral("{TOTP}")); } +void DatabaseWidget::performAutoTypeURL() +{ + performAutoType(QStringLiteral("{URL}")); +} + +void DatabaseWidget::performAutoTypeURLEnter() +{ + performAutoType(QStringLiteral("{URL}{ENTER}")); +} + void DatabaseWidget::openUrl() { auto currentEntry = currentSelectedEntry(); diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index a96c9d488..2507f1842 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -214,6 +214,8 @@ public slots: void performAutoTypePassword(); void performAutoTypePasswordEnter(); void performAutoTypeTOTP(); + void performAutoTypeURL(); + void performAutoTypeURLEnter(); void setClipboardTextAndMinimize(const QString& text); void openUrl(); void downloadSelectedFavicons(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 3abb8f12f..28594e945 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -172,6 +172,8 @@ MainWindow::MainWindow() autotypeMenu->addAction(m_ui->actionEntryAutoTypePassword); autotypeMenu->addAction(m_ui->actionEntryAutoTypePasswordEnter); autotypeMenu->addAction(m_ui->actionEntryAutoTypeTOTP); + autotypeMenu->addAction(m_ui->actionEntryAutoTypeURL); + autotypeMenu->addAction(m_ui->actionEntryAutoTypeURLEnter); m_ui->actionEntryAutoType->setMenu(autotypeMenu); auto autoTypeButton = qobject_cast(m_ui->toolBar->widgetForAction(m_ui->actionEntryAutoType)); if (autoTypeButton) { @@ -387,6 +389,8 @@ MainWindow::MainWindow() m_ui->actionEntryAutoTypePassword->setIcon(icons()->icon("auto-type")); m_ui->actionEntryAutoTypePasswordEnter->setIcon(icons()->icon("auto-type")); m_ui->actionEntryAutoTypeTOTP->setIcon(icons()->icon("auto-type")); + m_ui->actionEntryAutoTypeURL->setIcon(icons()->icon("auto-type")); + m_ui->actionEntryAutoTypeURLEnter->setIcon(icons()->icon("auto-type")); m_ui->actionEntryMoveUp->setIcon(icons()->icon("move-up")); m_ui->actionEntryMoveDown->setIcon(icons()->icon("move-down")); m_ui->actionEntryCopyUsername->setIcon(icons()->icon("username-copy")); @@ -526,6 +530,9 @@ MainWindow::MainWindow() m_actionMultiplexer.connect( m_ui->actionEntryAutoTypePasswordEnter, SIGNAL(triggered()), SLOT(performAutoTypePasswordEnter())); m_actionMultiplexer.connect(m_ui->actionEntryAutoTypeTOTP, SIGNAL(triggered()), SLOT(performAutoTypeTOTP())); + m_actionMultiplexer.connect(m_ui->actionEntryAutoTypeURL, SIGNAL(triggered()), SLOT(performAutoTypeURL())); + m_actionMultiplexer.connect( + m_ui->actionEntryAutoTypeURLEnter, SIGNAL(triggered()), SLOT(performAutoTypeURLEnter())); m_actionMultiplexer.connect(m_ui->actionEntryOpenUrl, SIGNAL(triggered()), SLOT(openUrl())); m_actionMultiplexer.connect(m_ui->actionEntryDownloadIcon, SIGNAL(triggered()), SLOT(downloadSelectedFavicons())); #ifdef WITH_XC_SSHAGENT @@ -976,6 +983,8 @@ void MainWindow::updateMenuActionState() m_ui->actionEntryAutoTypePassword->setEnabled(singleEntrySelected && dbWidget->currentEntryHasPassword()); m_ui->actionEntryAutoTypePasswordEnter->setEnabled(singleEntrySelected && dbWidget->currentEntryHasPassword()); m_ui->actionEntryAutoTypeTOTP->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp()); + m_ui->actionEntryAutoTypeURL->setEnabled(singleEntrySelected && dbWidget->currentEntryHasUrl()); + m_ui->actionEntryAutoTypeURLEnter->setEnabled(singleEntrySelected && dbWidget->currentEntryHasUrl()); m_ui->actionEntryAutoTypeTOTP->setVisible(singleEntrySelected && dbWidget->currentEntryHasTotp()); m_ui->actionEntryOpenUrl->setEnabled(singleEntryOrEditing && dbWidget->currentEntryHasUrl()); m_ui->actionEntryTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp()); diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index 283bfd999..558320003 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -859,6 +859,34 @@ Perform Auto-Type: {TOTP} + + + false + + + {URL} + + + {URL} + + + {URL} + + + + + false + + + {URL}{ENTER} + + + {URL}{ENTER} + + + {URL}{ENTER} + + Download &Favicon