diff --git a/src/core/MacPasteboard.h b/src/core/MacPasteboard.h index 15e99616c..8461cbc5d 100644 --- a/src/core/MacPasteboard.h +++ b/src/core/MacPasteboard.h @@ -26,12 +26,12 @@ class MacPasteboard : public QMacPasteboardMime public: explicit MacPasteboard() : QMacPasteboardMime(MIME_ALL) {} - QString convertorName(); - bool canConvert(const QString &mime, QString flav); - QString mimeFor(QString flav); - QString flavorFor(const QString &mime); - QVariant convertToMime(const QString &mime, QList data, QString flav); - QList convertFromMime(const QString &mime, QVariant data, QString flav); + QString convertorName() override; + bool canConvert(const QString &mime, QString flav) override; + QString mimeFor(QString flav) override; + QString flavorFor(const QString &mime) override; + QVariant convertToMime(const QString &mime, QList data, QString flav) override; + QList convertFromMime(const QString &mime, QVariant data, QString flav) override; }; #endif // KEEPASSXC_MACPASTEBOARD_H diff --git a/src/gui/Clipboard.cpp b/src/gui/Clipboard.cpp index a62385728..a35f59b19 100644 --- a/src/gui/Clipboard.cpp +++ b/src/gui/Clipboard.cpp @@ -22,9 +22,6 @@ #include #include "core/Config.h" -#ifdef Q_OS_MAC -#include "core/MacPasteboard.h" -#endif Clipboard* Clipboard::m_instance(nullptr); @@ -33,16 +30,28 @@ Clipboard::Clipboard(QObject* parent) , m_timer(new QTimer(this)) { m_timer->setSingleShot(true); +#ifdef Q_OS_MAC + m_pasteboard = new MacPasteboard; +#endif + connect(m_timer, SIGNAL(timeout()), SLOT(clearClipboard())); connect(qApp, SIGNAL(aboutToQuit()), SLOT(clearCopiedText())); } +Clipboard::~Clipboard() +{ +#ifdef Q_OS_MAC + if (m_pasteboard) { + delete m_pasteboard; + } +#endif +} + void Clipboard::setText(const QString& text) { QClipboard* clipboard = QApplication::clipboard(); #ifdef Q_OS_MAC - new MacPasteboard; QMimeData* mime = new QMimeData; mime->setText(text); mime->setData("application/x-nspasteboard-concealed-type", text.toUtf8()); diff --git a/src/gui/Clipboard.h b/src/gui/Clipboard.h index e0a16d26d..68f4e0485 100644 --- a/src/gui/Clipboard.h +++ b/src/gui/Clipboard.h @@ -19,6 +19,9 @@ #define KEEPASSX_CLIPBOARD_H #include +#ifdef Q_OS_MAC +#include "core/MacPasteboard.h" +#endif class QTimer; @@ -28,6 +31,7 @@ class Clipboard : public QObject public: void setText(const QString& text); + ~Clipboard(); static Clipboard* instance(); @@ -43,6 +47,9 @@ private: static Clipboard* m_instance; QTimer* m_timer; +#ifdef Q_OS_MAC + MacPasteboard* m_pasteboard; +#endif QString m_lastCopied; };