Skip to content

Commit

Permalink
Add shortcut to copy password with TOTP appended
Browse files Browse the repository at this point in the history
  • Loading branch information
jimheden authored and droidmonkey committed Sep 11, 2022
1 parent 59e2c38 commit b8b218e
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 6 deletions.
7 changes: 4 additions & 3 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ Files: share/icons/application/scalable/actions/application-exit.svg
share/icons/application/scalable/actions/bugreport.svg
share/icons/application/scalable/actions/chevron-double-down.svg
share/icons/application/scalable/actions/chevron-double-right.svg
share/icons/application/scalable/actions/totp.svg
share/icons/application/scalable/actions/totp-copy.svg
share/icons/application/scalable/actions/totp-edit.svg
share/icons/application/scalable/actions/clipboard-text.svg
share/icons/application/scalable/actions/configure.svg
share/icons/application/scalable/actions/database-change-key.svg
Expand Down Expand Up @@ -217,6 +214,10 @@ Files: share/icons/application/scalable/actions/application-exit.svg
share/icons/application/scalable/actions/tag.svg
share/icons/application/scalable/actions/tag-multiple.svg
share/icons/application/scalable/actions/tag-search.svg
share/icons/application/scalable/actions/totp.svg
share/icons/application/scalable/actions/totp-copy.svg
share/icons/application/scalable/actions/totp-copy-password.svg
share/icons/application/scalable/actions/totp-edit.svg
share/icons/application/scalable/actions/trash.svg
share/icons/application/scalable/actions/url-copy.svg
share/icons/application/scalable/actions/user-guide.svg
Expand Down
1 change: 1 addition & 0 deletions docs/topics/KeyboardShortcuts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ NOTE: On macOS please substitute `Ctrl` with `Cmd` (aka `⌘`).
|Copy URL | Ctrl + U
|Open URL | Ctrl + Shift + U
|Copy TOTP | Ctrl + T
|Copy Password and TOTP | Ctrl + Y
|Show TOTP | Ctrl + Shift + T
|Trigger AutoType | Ctrl + Shift + V
|Add key to SSH Agent | Ctrl + H
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions share/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
<file>application/scalable/actions/bugreport.svg</file>
<file>application/scalable/actions/chevron-double-down.svg</file>
<file>application/scalable/actions/chevron-double-right.svg</file>
<file>application/scalable/actions/totp.svg</file>
<file>application/scalable/actions/totp-copy.svg</file>
<file>application/scalable/actions/totp-edit.svg</file>
<file>application/scalable/actions/clipboard-text.svg</file>
<file>application/scalable/actions/configure.svg</file>
<file>application/scalable/actions/database-change-key.svg</file>
Expand Down Expand Up @@ -79,6 +76,10 @@
<file>application/scalable/actions/tag.svg</file>
<file>application/scalable/actions/tag-multiple.svg</file>
<file>application/scalable/actions/tag-search.svg</file>
<file>application/scalable/actions/totp.svg</file>
<file>application/scalable/actions/totp-copy.svg</file>
<file>application/scalable/actions/totp-copy-password.svg</file>
<file>application/scalable/actions/totp-edit.svg</file>
<file>application/scalable/actions/trash.svg</file>
<file>application/scalable/actions/url-copy.svg</file>
<file>application/scalable/actions/user-guide.svg</file>
Expand Down
4 changes: 4 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5430,6 +5430,10 @@ We recommend you use the AppImage available on our downloads page.</source>
<numerusform></numerusform>
</translation>
</message>
<message>
<source>Copy Password and TOTP</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ManageDatabase</name>
Expand Down
9 changes: 9 additions & 0 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,15 @@ void DatabaseWidget::copyPassword()
}
}

void DatabaseWidget::copyPasswordTotp()
{
auto currentEntry = currentSelectedEntry();
if (currentEntry) {
setClipboardTextAndMinimize(
currentEntry->resolveMultiplePlaceholders(currentEntry->password()).append(currentEntry->totp()));
}
}

void DatabaseWidget::copyURL()
{
auto currentEntry = currentSelectedEntry();
Expand Down
1 change: 1 addition & 0 deletions src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public slots:
void showTotp();
void showTotpKeyQrCode();
void copyTotp();
void copyPasswordTotp();
void setupTotp();
#ifdef WITH_XC_SSHAGENT
void addToAgent();
Expand Down
5 changes: 5 additions & 0 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ MainWindow::MainWindow()
m_ui->actionEntryTotp->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_T);
m_ui->actionEntryDownloadIcon->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_D);
m_ui->actionEntryCopyTotp->setShortcut(Qt::CTRL + Qt::Key_T);
m_ui->actionEntryCopyPasswordTotp->setShortcut(Qt::CTRL + Qt::Key_Y);
m_ui->actionEntryMoveUp->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_Up);
m_ui->actionEntryMoveDown->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_Down);
m_ui->actionEntryCopyUsername->setShortcut(Qt::CTRL + Qt::Key_B);
Expand Down Expand Up @@ -308,6 +309,7 @@ MainWindow::MainWindow()
m_ui->actionEntryTotp->setShortcutVisibleInContextMenu(true);
m_ui->actionEntryDownloadIcon->setShortcutVisibleInContextMenu(true);
m_ui->actionEntryCopyTotp->setShortcutVisibleInContextMenu(true);
m_ui->actionEntryCopyPasswordTotp->setShortcutVisibleInContextMenu(true);
m_ui->actionEntryMoveUp->setShortcutVisibleInContextMenu(true);
m_ui->actionEntryMoveDown->setShortcutVisibleInContextMenu(true);
m_ui->actionEntryCopyUsername->setShortcutVisibleInContextMenu(true);
Expand Down Expand Up @@ -406,6 +408,7 @@ MainWindow::MainWindow()
m_ui->menuEntryTotp->setIcon(icons()->icon("totp"));
m_ui->actionEntryTotp->setIcon(icons()->icon("totp"));
m_ui->actionEntryCopyTotp->setIcon(icons()->icon("totp-copy"));
m_ui->actionEntryCopyPasswordTotp->setIcon(icons()->icon("totp-copy-password"));
m_ui->actionEntryTotpQRCode->setIcon(icons()->icon("qrcode"));
m_ui->actionEntrySetupTotp->setIcon(icons()->icon("totp-edit"));
m_ui->menuTags->setIcon(icons()->icon("tag-multiple"));
Expand Down Expand Up @@ -498,6 +501,7 @@ MainWindow::MainWindow()
m_actionMultiplexer.connect(m_ui->actionEntrySetupTotp, SIGNAL(triggered()), SLOT(setupTotp()));

m_actionMultiplexer.connect(m_ui->actionEntryCopyTotp, SIGNAL(triggered()), SLOT(copyTotp()));
m_actionMultiplexer.connect(m_ui->actionEntryCopyPasswordTotp, SIGNAL(triggered()), SLOT(copyPasswordTotp()));
m_actionMultiplexer.connect(m_ui->actionEntryTotpQRCode, SIGNAL(triggered()), SLOT(showTotpKeyQrCode()));
m_actionMultiplexer.connect(m_ui->actionEntryCopyTitle, SIGNAL(triggered()), SLOT(copyTitle()));
m_actionMultiplexer.connect(m_ui->actionEntryMoveUp, SIGNAL(triggered()), SLOT(moveEntryUp()));
Expand Down Expand Up @@ -942,6 +946,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryOpenUrl->setEnabled(singleEntrySelected && dbWidget->currentEntryHasUrl());
m_ui->actionEntryTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp());
m_ui->actionEntryCopyTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp());
m_ui->actionEntryCopyPasswordTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp());
m_ui->actionEntrySetupTotp->setEnabled(singleEntrySelected);
m_ui->actionEntryTotpQRCode->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp());
m_ui->actionEntryDownloadIcon->setEnabled((entriesSelected && !singleEntrySelected)
Expand Down
6 changes: 6 additions & 0 deletions src/gui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
<string>TOTP</string>
</property>
<addaction name="actionEntryCopyTotp"/>
<addaction name="actionEntryCopyPasswordTotp"/>
<addaction name="actionEntryTotp"/>
<addaction name="actionEntryTotpQRCode"/>
<addaction name="actionEntrySetupTotp"/>
Expand Down Expand Up @@ -887,6 +888,11 @@
<property name="text">
<string>Copy &amp;TOTP</string>
</property>
</action>
<action name="actionEntryCopyPasswordTotp">
<property name="text">
<string>Copy Password and TOTP</string>
</property>
</action>
<action name="actionGroupEmptyRecycleBin">
<property name="text">
Expand Down

0 comments on commit b8b218e

Please sign in to comment.