diff options
author | Anees Ahmed <aneesahmedpro@github.com> | 2020-06-22 13:50:45 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2020-07-22 01:22:47 +0300 |
commit | 1d0523ec21b1e46c8ccf53250a3227568d79f082 (patch) | |
tree | 19f0717f811905d826cc14143b991f99f75d8270 /src | |
parent | f73855a7f2168957a1a917ea4154445d8e1aa583 (diff) |
Add option to Auto-Type just the username/password
Fixes #4444
Some websites these days do not present both the "username" and the "password"
input box on the same webpage (e.g. Google, Amazon). So no custom sequence is
possible to enter both the said attributes in one go.
So, two new context menu actions have been added:
1. Perform Auto-Type of just the username
2. Perform Auto-Type of just the password
These context menu actions are analogous to "Copy username" and "Copy
password", except it avoids sending all characters via clipboard.
* Create a sub-menu in the Context Menu of Entry.
* The sub-menu offers the following sequences:
- {USERNAME}
- {USERNAME}{ENTER}
- {PASSWORD}
- {PASSWORD}{ENTER}
Diffstat (limited to 'src')
-rw-r--r-- | src/autotype/AutoType.cpp | 15 | ||||
-rw-r--r-- | src/autotype/AutoType.h | 1 | ||||
-rw-r--r-- | src/gui/DatabaseWidget.cpp | 32 | ||||
-rw-r--r-- | src/gui/DatabaseWidget.h | 4 | ||||
-rw-r--r-- | src/gui/MainWindow.cpp | 29 | ||||
-rw-r--r-- | src/gui/MainWindow.ui | 45 |
6 files changed, 124 insertions, 2 deletions
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 @@ <addaction name="actionEntryTotpQRCode"/> <addaction name="actionEntrySetupTotp"/> </widget> + <widget class="QMenu" name="menuEntryAutoTypeWithSequence"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="title"> + <string>Perform Auto-Type Sequence</string> + </property> + <addaction name="actionEntryAutoTypeUsername"/> + <addaction name="actionEntryAutoTypeUsernameEnter"/> + <addaction name="actionEntryAutoTypePassword"/> + <addaction name="actionEntryAutoTypePasswordEnter"/> + </widget> <addaction name="actionEntryNew"/> <addaction name="actionEntryEdit"/> <addaction name="actionEntryClone"/> @@ -324,6 +336,7 @@ <addaction name="menuEntryTotp"/> <addaction name="separator"/> <addaction name="actionEntryAutoType"/> + <addaction name="menuEntryAutoTypeWithSequence"/> <addaction name="separator"/> <addaction name="actionEntryOpenUrl"/> <addaction name="actionEntryDownloadIcon"/> @@ -680,6 +693,38 @@ <string>Perform &Auto-Type</string> </property> </action> + <action name="actionEntryAutoTypeUsername"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>{USERNAME}</string> + </property> + </action> + <action name="actionEntryAutoTypeUsernameEnter"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>{USERNAME}{ENTER}</string> + </property> + </action> + <action name="actionEntryAutoTypePassword"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>{PASSWORD}</string> + </property> + </action> + <action name="actionEntryAutoTypePasswordEnter"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>{PASSWORD}{ENTER}</string> + </property> + </action> <action name="actionEntryDownloadIcon"> <property name="text"> <string>Download &Favicon</string> |