diff options
author | Ken Moore <ken@ixsystems.com> | 2018-04-16 09:11:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-16 09:11:56 -0400 |
commit | 96429fabec9839770d087ab36d8e51aaa48c1041 (patch) | |
tree | 7a039110eff206dd58ac6fec1ef5c959f10242f6 /src-qt5/core/lumina-desktop/LSession.cpp | |
parent | Setup lumina-config with window geometry save/restore. (diff) | |
parent | lumina-desktop: add basic clipboard support (diff) | |
download | lumina-96429fabec9839770d087ab36d8e51aaa48c1041.tar.gz lumina-96429fabec9839770d087ab36d8e51aaa48c1041.tar.bz2 lumina-96429fabec9839770d087ab36d8e51aaa48c1041.zip |
Merge pull request #574 from rodlie/lumina-desktop_add_clipboard_support
lumina-desktop: add basic clipboard support
Diffstat (limited to 'src-qt5/core/lumina-desktop/LSession.cpp')
-rw-r--r-- | src-qt5/core/lumina-desktop/LSession.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index c1f49fc3..9ea377ba 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -10,6 +10,7 @@ #include <QTime> #include <QScreen> #include <QtConcurrent> +#include <QMimeData> #include "LXcbEventFilter.h" #include "BootSplash.h" @@ -72,6 +73,11 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu connect(this, SIGNAL(screenAdded(QScreen*)), this, SLOT(screensChanged()) ); connect(this, SIGNAL(screenRemoved(QScreen*)), this, SLOT(screensChanged()) ); connect(this, SIGNAL(primaryScreenChanged(QScreen*)), this, SLOT(screensChanged()) ); + + // Clipboard + ignoreClipboard = false; + qRegisterMetaType<QClipboard::Mode>("QClipboard::Mode"); + connect(QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)), this, SLOT(handleClipboard(QClipboard::Mode))); } //end check for primary process } @@ -587,6 +593,20 @@ void LSession::SessionEnding(){ stopSystemTray(); //just in case it was not stopped properly earlier } +void LSession::handleClipboard(QClipboard::Mode mode){ + if (!ignoreClipboard) { + const QMimeData *mime = QApplication::clipboard()->mimeData(mode); + if (!mime) { return; } + if (mime->hasText()) { QMetaObject::invokeMethod(this, "storeClipboard", Qt::QueuedConnection, Q_ARG(QString, mime->text()), Q_ARG(QClipboard::Mode, mode)); } + } +} + +void LSession::storeClipboard(QString text, QClipboard::Mode mode){ + ignoreClipboard = true; + QApplication::clipboard()->setText(text, mode); + ignoreClipboard = false; +} + //=============== // SYSTEM ACCESS //=============== |