Clear clipboard when locking databases.

Closes #342
This commit is contained in:
Felix Geyer 2015-09-13 12:38:19 +02:00
parent 236edae60b
commit f236c32063
3 changed files with 15 additions and 10 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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<DatabaseWidget*>(widget(i));
Database* db = databaseFromDatabaseWidget(dbWidget);