Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
weslly committed Nov 20, 2017
1 parent dc7322c commit 806248e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/core/MacPasteboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QByteArray> data, QString flav);
QList<QByteArray> 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<QByteArray> data, QString flav) override;
QList<QByteArray> convertFromMime(const QString &mime, QVariant data, QString flav) override;
};

#endif // KEEPASSXC_MACPASTEBOARD_H
17 changes: 13 additions & 4 deletions src/gui/Clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#include <QTimer>

#include "core/Config.h"
#ifdef Q_OS_MAC
#include "core/MacPasteboard.h"
#endif

Clipboard* Clipboard::m_instance(nullptr);

Expand All @@ -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());
Expand Down
7 changes: 7 additions & 0 deletions src/gui/Clipboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#define KEEPASSX_CLIPBOARD_H

#include <QObject>
#ifdef Q_OS_MAC
#include "core/MacPasteboard.h"
#endif

class QTimer;

Expand All @@ -28,6 +31,7 @@ class Clipboard : public QObject

public:
void setText(const QString& text);
~Clipboard();

static Clipboard* instance();

Expand All @@ -43,6 +47,9 @@ private slots:
static Clipboard* m_instance;

QTimer* m_timer;
#ifdef Q_OS_MAC
MacPasteboard* m_pasteboard;
#endif
QString m_lastCopied;
};

Expand Down

0 comments on commit 806248e

Please sign in to comment.