From c016e8af9b154f169dde04681f273bb7be767a37 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 e5cc2a9e4..925c890b9 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -555,6 +555,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 a75963e07..caaf4bc2c 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1000,7 +1000,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());