From af466b120eae99d25d79fd0f1fcd0c7318d56411 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Mon, 24 Oct 2022 23:46:44 -0400 Subject: [PATCH] Fix clicking links in entry preview panel * Fixes #8636 --- src/gui/DatabaseWidget.cpp | 1 - src/gui/EntryPreviewWidget.cpp | 23 ++++++++++++++++------- src/gui/EntryPreviewWidget.h | 1 - 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index ec5705914..e737fb7aa 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -197,7 +197,6 @@ DatabaseWidget::DatabaseWidget(QSharedPointer db, QWidget* parent) connect(m_groupSplitter, SIGNAL(splitterMoved(int,int)), SIGNAL(splitterSizesChanged())); connect(m_previewSplitter, SIGNAL(splitterMoved(int,int)), SIGNAL(splitterSizesChanged())); connect(this, SIGNAL(currentModeChanged(DatabaseWidget::Mode)), m_previewView, SLOT(setDatabaseMode(DatabaseWidget::Mode))); - connect(m_previewView, SIGNAL(errorOccurred(QString)), SLOT(showErrorMessage(QString))); connect(m_previewView, SIGNAL(entryUrlActivated(Entry*)), SLOT(openUrlForEntry(Entry*))); connect(m_entryView, SIGNAL(viewStateChanged()), SIGNAL(entryViewStateChanged())); connect(m_groupView, SIGNAL(groupSelectionChanged()), SLOT(onGroupChanged())); diff --git a/src/gui/EntryPreviewWidget.cpp b/src/gui/EntryPreviewWidget.cpp index 11de4a60f..d864560dd 100644 --- a/src/gui/EntryPreviewWidget.cpp +++ b/src/gui/EntryPreviewWidget.cpp @@ -66,8 +66,6 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent) m_ui->entryNotesTextEdit->document()->setDocumentMargin(0); m_ui->groupNotesTextEdit->document()->setDocumentMargin(0); - connect(m_ui->entryUrlLabel, SIGNAL(linkActivated(QString)), SLOT(openEntryUrl())); - 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())); @@ -77,7 +75,10 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent) connect(m_ui->toggleGroupNotesButton, SIGNAL(clicked(bool)), SLOT(setGroupNotesVisible(bool))); connect(m_ui->entryTabWidget, SIGNAL(tabBarClicked(int)), SLOT(updateTabIndexes()), Qt::QueuedConnection); // Prevent the url from being focused after clicked to allow the Copy Password button to work properly - connect(m_ui->entryUrlLabel, &QLabel::linkActivated, this, [this] { m_ui->entryTabWidget->setFocus(); }); + connect(m_ui->entryUrlLabel, &QLabel::linkActivated, this, [this] { + openEntryUrl(); + m_ui->entryTabWidget->setFocus(); + }); connect(&m_totpTimer, SIGNAL(timeout()), SLOT(updateTotpLabel())); connect(m_ui->entryAttributesTable, &QTableWidget::itemDoubleClicked, this, [](QTableWidgetItem* item) { @@ -120,8 +121,12 @@ void EntryPreviewWidget::clear() void EntryPreviewWidget::setEntry(Entry* selectedEntry) { - disconnect(m_currentEntry); - disconnect(m_currentGroup); + if (m_currentEntry) { + disconnect(m_currentEntry); + } + if (m_currentGroup) { + disconnect(m_currentGroup); + } m_currentEntry = selectedEntry; m_currentGroup = nullptr; @@ -137,8 +142,12 @@ void EntryPreviewWidget::setEntry(Entry* selectedEntry) void EntryPreviewWidget::setGroup(Group* selectedGroup) { - disconnect(m_currentEntry); - disconnect(m_currentGroup); + if (m_currentEntry) { + disconnect(m_currentEntry); + } + if (m_currentGroup) { + disconnect(m_currentGroup); + } m_currentEntry = nullptr; m_currentGroup = selectedGroup; diff --git a/src/gui/EntryPreviewWidget.h b/src/gui/EntryPreviewWidget.h index b7a71aa02..901b4a097 100644 --- a/src/gui/EntryPreviewWidget.h +++ b/src/gui/EntryPreviewWidget.h @@ -44,7 +44,6 @@ public slots: void clear(); signals: - void errorOccurred(const QString& error); void entryUrlActivated(Entry* entry); private slots: