From 7dfeb472128c5628fa5ff0aa47702aa179f0b94b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?X=C3=AC=20G=C3=A0?= Date: Mon, 27 Oct 2025 04:46:51 +0900 Subject: [PATCH] Open TOTP setup dialog if entry has no valid TOTP set (#12584) --------- Co-authored-by: x Co-authored-by: Jonathan White --- src/gui/DatabaseWidget.cpp | 7 +++++++ src/gui/MainWindow.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 1f928247f..7d7af0f70 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -550,6 +550,13 @@ void DatabaseWidget::copyTotp() if (!currentEntry) { return; } + + // If the entry has no TOTP set, open the setup dialog first + if (!currentEntry->hasValidTotp()) { + setupTotp(); + return; + } + setClipboardTextAndMinimize(currentEntry->totp()); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 145bb4b99..2468c5f58 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1027,7 +1027,7 @@ void MainWindow::updateMenuActionState() m_ui->actionEntryAutoTypeTOTP->setVisible(singleEntrySelected && dbWidget->currentEntryHasTotp()); m_ui->actionEntryOpenUrl->setEnabled(singleEntryOrEditing && dbWidget->currentEntryHasUrl()); m_ui->actionEntryTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp()); - m_ui->actionEntryCopyTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp()); + m_ui->actionEntryCopyTotp->setEnabled(singleEntrySelected); m_ui->actionEntryCopyPasswordTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp()); m_ui->actionEntrySetupTotp->setEnabled(singleEntrySelected); m_ui->actionEntryTotpQRCode->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp());