diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts
index cd05345ae..4b17fe01c 100644
--- a/share/translations/keepassxc_en.ts
+++ b/share/translations/keepassxc_en.ts
@@ -3939,6 +3939,10 @@ Error: %1
+
+
+
+
EntryURLModel
diff --git a/src/gui/EntryPreviewWidget.cpp b/src/gui/EntryPreviewWidget.cpp
index 1b5c6efcd..50c94325b 100644
--- a/src/gui/EntryPreviewWidget.cpp
+++ b/src/gui/EntryPreviewWidget.cpp
@@ -68,6 +68,8 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
m_ui->entryNotesTextEdit->document()->setDocumentMargin(0);
m_ui->groupNotesTextEdit->document()->setDocumentMargin(0);
+ m_ui->entryTotpLabel->installEventFilter(this);
+
connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpLabel, SLOT(setVisible(bool)));
connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpProgress, SLOT(setVisible(bool)));
connect(m_ui->entryCloseButton, SIGNAL(clicked()), SLOT(hide()));
@@ -111,6 +113,18 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
EntryPreviewWidget::~EntryPreviewWidget() = default;
+bool EntryPreviewWidget::eventFilter(QObject* object, QEvent* event)
+{
+ if (object == m_ui->entryTotpLabel && event->type() == QEvent::MouseButtonDblClick) {
+ if (m_currentEntry && m_currentEntry->hasTotp()) {
+ clipboard()->setText(m_currentEntry->totp());
+ m_ui->entryTotpLabel->clearFocus();
+ return true;
+ }
+ }
+ return QWidget::eventFilter(object, event);
+}
+
void EntryPreviewWidget::clear()
{
hide();
diff --git a/src/gui/EntryPreviewWidget.h b/src/gui/EntryPreviewWidget.h
index 901b4a097..f4ea8be66 100644
--- a/src/gui/EntryPreviewWidget.h
+++ b/src/gui/EntryPreviewWidget.h
@@ -46,6 +46,9 @@ public slots:
signals:
void entryUrlActivated(Entry* entry);
+protected:
+ bool eventFilter(QObject* object, QEvent* event) override;
+
private slots:
void updateEntryHeaderLine();
void updateEntryTotp();
diff --git a/src/gui/EntryPreviewWidget.ui b/src/gui/EntryPreviewWidget.ui
index 322b6ef74..36e8d3850 100644
--- a/src/gui/EntryPreviewWidget.ui
+++ b/src/gui/EntryPreviewWidget.ui
@@ -123,6 +123,9 @@
true
+
+ Double click to copy to clipboard
+
1234567