Copy TOTP on preview panel on double click

* Closes #9545
This commit is contained in:
Jonathan White 2023-07-19 21:27:53 -04:00
parent a35f446585
commit a7f857d32c
4 changed files with 24 additions and 0 deletions

View File

@ -3939,6 +3939,10 @@ Error: %1</source>
<source>Disabled</source> <source>Disabled</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Double click to copy to clipboard</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>EntryURLModel</name> <name>EntryURLModel</name>

View File

@ -68,6 +68,8 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
m_ui->entryNotesTextEdit->document()->setDocumentMargin(0); m_ui->entryNotesTextEdit->document()->setDocumentMargin(0);
m_ui->groupNotesTextEdit->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->entryTotpLabel, SLOT(setVisible(bool)));
connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpProgress, SLOT(setVisible(bool))); connect(m_ui->entryTotpButton, SIGNAL(toggled(bool)), m_ui->entryTotpProgress, SLOT(setVisible(bool)));
connect(m_ui->entryCloseButton, SIGNAL(clicked()), SLOT(hide())); connect(m_ui->entryCloseButton, SIGNAL(clicked()), SLOT(hide()));
@ -111,6 +113,18 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
EntryPreviewWidget::~EntryPreviewWidget() = default; 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() void EntryPreviewWidget::clear()
{ {
hide(); hide();

View File

@ -46,6 +46,9 @@ public slots:
signals: signals:
void entryUrlActivated(Entry* entry); void entryUrlActivated(Entry* entry);
protected:
bool eventFilter(QObject* object, QEvent* event) override;
private slots: private slots:
void updateEntryHeaderLine(); void updateEntryHeaderLine();
void updateEntryTotp(); void updateEntryTotp();

View File

@ -123,6 +123,9 @@
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<property name="toolTip">
<string>Double click to copy to clipboard</string>
</property>
<property name="text"> <property name="text">
<string notr="true">1234567</string> <string notr="true">1234567</string>
</property> </property>