Improve handling of clipboard actions

* Fix #10804
This commit is contained in:
Jonathan White 2024-05-25 09:13:43 -04:00
parent 28e6887aa4
commit 3662f6aa77
4 changed files with 6 additions and 5 deletions

View file

@ -22,7 +22,6 @@
#include "Application.h"
#include "core/Config.h"
#include "core/Totp.h"
#include "gui/Clipboard.h"
#include "gui/Font.h"
#include "gui/Icons.h"
#if defined(WITH_XC_KEESHARE)
@ -85,10 +84,10 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
});
connect(&m_totpTimer, SIGNAL(timeout()), SLOT(updateTotpLabel()));
connect(m_ui->entryAttributesTable, &QTableWidget::itemDoubleClicked, this, [](QTableWidgetItem* item) {
connect(m_ui->entryAttributesTable, &QTableWidget::itemDoubleClicked, this, [this](QTableWidgetItem* item) {
auto userData = item->data(Qt::UserRole);
if (userData.isValid()) {
clipboard()->setText(userData.toString());
emit copyTextRequested(userData.toString());
}
});
@ -117,7 +116,7 @@ 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());
emit copyTextRequested(m_currentEntry->totp());
m_ui->entryTotpLabel->clearFocus();
return true;
}