From f236c32063460edbf290d4d519f2c722a3ec7092 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sun, 13 Sep 2015 12:38:19 +0200 Subject: [PATCH] Clear clipboard when locking databases. Closes #342 --- src/gui/Clipboard.cpp | 18 +++++++++--------- src/gui/Clipboard.h | 4 +++- src/gui/DatabaseTabWidget.cpp | 3 +++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/gui/Clipboard.cpp b/src/gui/Clipboard.cpp index d4f34a187..698ca893e 100644 --- a/src/gui/Clipboard.cpp +++ b/src/gui/Clipboard.cpp @@ -31,7 +31,7 @@ Clipboard::Clipboard(QObject* parent) { m_timer->setSingleShot(true); connect(m_timer, SIGNAL(timeout()), SLOT(clearClipboard())); - connect(qApp, SIGNAL(aboutToQuit()), SLOT(cleanup())); + connect(qApp, SIGNAL(aboutToQuit()), SLOT(clearCopiedText())); } void Clipboard::setText(const QString& text) @@ -52,6 +52,14 @@ void Clipboard::setText(const QString& text) } } +void Clipboard::clearCopiedText() +{ + if (m_timer->isActive()) { + m_timer->stop(); + clearClipboard(); + } +} + void Clipboard::clearClipboard() { QClipboard* clipboard = QApplication::clipboard(); @@ -73,14 +81,6 @@ void Clipboard::clearClipboard() m_lastCopied.clear(); } -void Clipboard::cleanup() -{ - if (m_timer->isActive()) { - m_timer->stop(); - clearClipboard(); - } -} - Clipboard* Clipboard::instance() { if (!m_instance) { diff --git a/src/gui/Clipboard.h b/src/gui/Clipboard.h index 8b6ea69f5..8c234a2c5 100644 --- a/src/gui/Clipboard.h +++ b/src/gui/Clipboard.h @@ -33,9 +33,11 @@ public: static Clipboard* instance(); +public Q_SLOTS: + void clearCopiedText(); + private Q_SLOTS: void clearClipboard(); - void cleanup(); private: explicit Clipboard(QObject* parent = Q_NULLPTR); diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 4c957a27f..3d03093d7 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -27,6 +27,7 @@ #include "core/Metadata.h" #include "core/qsavefile.h" #include "format/CsvExporter.h" +#include "gui/Clipboard.h" #include "gui/DatabaseWidget.h" #include "gui/DatabaseWidgetStateSync.h" #include "gui/DragTabBar.h" @@ -632,6 +633,8 @@ bool DatabaseTabWidget::hasLockableDatabases() const void DatabaseTabWidget::lockDatabases() { + clipboard()->clearCopiedText(); + for (int i = 0; i < count(); i++) { DatabaseWidget* dbWidget = static_cast(widget(i)); Database* db = databaseFromDatabaseWidget(dbWidget);