diff --git a/src/autotype/AutoType.cpp b/src/autotype/AutoType.cpp index 01ef9d762..913a3c2ad 100644 --- a/src/autotype/AutoType.cpp +++ b/src/autotype/AutoType.cpp @@ -269,7 +269,7 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c /** * Single Autotype entry-point function - * Perfom autotype sequence in the active window + * Look up the Auto-Type sequence for the given entry then perfom Auto-Type in the active window */ void AutoType::performAutoType(const Entry* entry, QWidget* hideWindow) { @@ -285,6 +285,19 @@ void AutoType::performAutoType(const Entry* entry, QWidget* hideWindow) executeAutoTypeActions(entry, hideWindow, sequences.first()); } +/** + * Extra Autotype entry-point function + * Perfom Auto-Type of the directly specified sequence in the active window + */ +void AutoType::performAutoTypeWithSequence(const Entry* entry, const QString& sequence, QWidget* hideWindow) +{ + if (!m_plugin) { + return; + } + + executeAutoTypeActions(entry, hideWindow, sequence); +} + void AutoType::startGlobalAutoType() { m_windowForGlobal = m_plugin->activeWindow(); diff --git a/src/autotype/AutoType.h b/src/autotype/AutoType.h index 7f9e3ab22..78cd42f88 100644 --- a/src/autotype/AutoType.h +++ b/src/autotype/AutoType.h @@ -48,6 +48,7 @@ public: static bool checkHighDelay(const QString& string); static bool verifyAutoTypeSyntax(const QString& sequence); void performAutoType(const Entry* entry, QWidget* hideWindow = nullptr); + void performAutoTypeWithSequence(const Entry* entry, const QString& sequence, QWidget* hideWindow = nullptr); inline bool isAvailable() { diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 042e2a561..3e1d3192b 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -799,6 +799,38 @@ void DatabaseWidget::performAutoType() } } +void DatabaseWidget::performAutoTypeUsername() +{ + auto currentEntry = currentSelectedEntry(); + if (currentEntry) { + autoType()->performAutoTypeWithSequence(currentEntry, QStringLiteral("{USERNAME}"), window()); + } +} + +void DatabaseWidget::performAutoTypeUsernameEnter() +{ + auto currentEntry = currentSelectedEntry(); + if (currentEntry) { + autoType()->performAutoTypeWithSequence(currentEntry, QStringLiteral("{USERNAME}{ENTER}"), window()); + } +} + +void DatabaseWidget::performAutoTypePassword() +{ + auto currentEntry = currentSelectedEntry(); + if (currentEntry) { + autoType()->performAutoTypeWithSequence(currentEntry, QStringLiteral("{PASSWORD}"), window()); + } +} + +void DatabaseWidget::performAutoTypePasswordEnter() +{ + auto currentEntry = currentSelectedEntry(); + if (currentEntry) { + autoType()->performAutoTypeWithSequence(currentEntry, QStringLiteral("{PASSWORD}{ENTER}"), window()); + } +} + void DatabaseWidget::openUrl() { auto currentEntry = currentSelectedEntry(); diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index a31dfd37b..2564977dc 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -186,6 +186,10 @@ public slots: void removeFromAgent(); #endif void performAutoType(); + void performAutoTypeUsername(); + void performAutoTypeUsernameEnter(); + void performAutoTypePassword(); + void performAutoTypePasswordEnter(); void openUrl(); void downloadSelectedFavicons(); void downloadAllFavicons(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 2ae78157e..d3d624e91 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -126,6 +126,7 @@ MainWindow::MainWindow() m_entryContextMenu->addAction(m_ui->menuEntryTotp->menuAction()); m_entryContextMenu->addSeparator(); m_entryContextMenu->addAction(m_ui->actionEntryAutoType); + m_entryContextMenu->addAction(m_ui->menuEntryAutoTypeWithSequence->menuAction()); m_entryContextMenu->addSeparator(); m_entryContextMenu->addAction(m_ui->actionEntryEdit); m_entryContextMenu->addAction(m_ui->actionEntryClone); @@ -220,7 +221,12 @@ MainWindow::MainWindow() m_ui->toolbarSeparator->setVisible(false); m_showToolbarSeparator = config()->get(Config::GUI_ApplicationTheme).toString() != "classic"; - m_ui->actionEntryAutoType->setVisible(autoType()->isAvailable()); + bool isAutoTypeAvailable = autoType()->isAvailable(); + m_ui->actionEntryAutoType->setVisible(isAutoTypeAvailable); + m_ui->actionEntryAutoTypeUsername->setVisible(isAutoTypeAvailable); + m_ui->actionEntryAutoTypeUsernameEnter->setVisible(isAutoTypeAvailable); + m_ui->actionEntryAutoTypePassword->setVisible(isAutoTypeAvailable); + m_ui->actionEntryAutoTypePasswordEnter->setVisible(isAutoTypeAvailable); m_inactivityTimer = new InactivityTimer(this); connect(m_inactivityTimer, SIGNAL(inactivityDetected()), this, SLOT(lockDatabasesAfterInactivity())); @@ -352,6 +358,11 @@ MainWindow::MainWindow() m_ui->actionEntryEdit->setIcon(resources()->icon("entry-edit")); m_ui->actionEntryDelete->setIcon(resources()->icon("entry-delete")); m_ui->actionEntryAutoType->setIcon(resources()->icon("auto-type")); + m_ui->menuEntryAutoTypeWithSequence->setIcon(resources()->icon("auto-type")); + m_ui->actionEntryAutoTypeUsername->setIcon(resources()->icon("auto-type")); + m_ui->actionEntryAutoTypeUsernameEnter->setIcon(resources()->icon("auto-type")); + m_ui->actionEntryAutoTypePassword->setIcon(resources()->icon("auto-type")); + m_ui->actionEntryAutoTypePasswordEnter->setIcon(resources()->icon("auto-type")); m_ui->actionEntryMoveUp->setIcon(resources()->icon("move-up")); m_ui->actionEntryMoveDown->setIcon(resources()->icon("move-down")); m_ui->actionEntryCopyUsername->setIcon(resources()->icon("username-copy")); @@ -446,6 +457,14 @@ MainWindow::MainWindow() m_actionMultiplexer.connect(m_ui->actionEntryCopyURL, SIGNAL(triggered()), SLOT(copyURL())); m_actionMultiplexer.connect(m_ui->actionEntryCopyNotes, SIGNAL(triggered()), SLOT(copyNotes())); m_actionMultiplexer.connect(m_ui->actionEntryAutoType, SIGNAL(triggered()), SLOT(performAutoType())); + m_actionMultiplexer.connect( + m_ui->actionEntryAutoTypeUsername, SIGNAL(triggered()), SLOT(performAutoTypeUsername())); + m_actionMultiplexer.connect( + m_ui->actionEntryAutoTypeUsernameEnter, SIGNAL(triggered()), SLOT(performAutoTypeUsernameEnter())); + m_actionMultiplexer.connect( + m_ui->actionEntryAutoTypePassword, SIGNAL(triggered()), SLOT(performAutoTypePassword())); + m_actionMultiplexer.connect( + m_ui->actionEntryAutoTypePasswordEnter, SIGNAL(triggered()), SLOT(performAutoTypePasswordEnter())); m_actionMultiplexer.connect(m_ui->actionEntryOpenUrl, SIGNAL(triggered()), SLOT(openUrl())); m_actionMultiplexer.connect(m_ui->actionEntryDownloadIcon, SIGNAL(triggered()), SLOT(downloadSelectedFavicons())); #ifdef WITH_XC_SSHAGENT @@ -711,6 +730,13 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) m_ui->menuEntryCopyAttribute->setEnabled(singleEntrySelected); m_ui->menuEntryTotp->setEnabled(singleEntrySelected); m_ui->actionEntryAutoType->setEnabled(singleEntrySelected); + m_ui->menuEntryAutoTypeWithSequence->setEnabled(singleEntrySelected); + m_ui->actionEntryAutoTypeUsername->setEnabled(singleEntrySelected && dbWidget->currentEntryHasUsername()); + m_ui->actionEntryAutoTypeUsernameEnter->setEnabled(singleEntrySelected + && dbWidget->currentEntryHasUsername()); + m_ui->actionEntryAutoTypePassword->setEnabled(singleEntrySelected && dbWidget->currentEntryHasPassword()); + m_ui->actionEntryAutoTypePasswordEnter->setEnabled(singleEntrySelected + && dbWidget->currentEntryHasPassword()); m_ui->actionEntryOpenUrl->setEnabled(singleEntrySelected && dbWidget->currentEntryHasUrl()); m_ui->actionEntryTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp()); m_ui->actionEntryCopyTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp()); @@ -761,6 +787,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) m_ui->actionEntryCopyURL, m_ui->actionEntryOpenUrl, m_ui->actionEntryAutoType, + m_ui->menuEntryAutoTypeWithSequence->menuAction(), m_ui->actionEntryDownloadIcon, m_ui->actionEntryCopyNotes, m_ui->actionEntryCopyTitle, diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index 10951f3c0..93488dc05 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -310,6 +310,18 @@ + + + false + + + Perform Auto-Type Sequence + + + + + + @@ -324,6 +336,7 @@ + @@ -680,6 +693,38 @@ Perform &Auto-Type + + + false + + + {USERNAME} + + + + + false + + + {USERNAME}{ENTER} + + + + + false + + + {PASSWORD} + + + + + false + + + {PASSWORD}{ENTER} + + Download &Favicon