aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorOle-André Rodlie <ole.andre.rodlie@gmail.com>2018-04-14 23:15:44 +0200
committerOle-André Rodlie <ole.andre.rodlie@gmail.com>2018-04-14 23:15:44 +0200
commit4c9bc199200fd4931dc1f0050c6111d1cc7fa3e0 (patch)
treebe4f06db2e4deef4da9d5c04c028fa8852799ffa /src-qt5
parentAdd a quick test script I wrote to probe icon themes and see what is found or... (diff)
downloadlumina-4c9bc199200fd4931dc1f0050c6111d1cc7fa3e0.tar.gz
lumina-4c9bc199200fd4931dc1f0050c6111d1cc7fa3e0.tar.bz2
lumina-4c9bc199200fd4931dc1f0050c6111d1cc7fa3e0.zip
lumina-desktop: add basic clipboard support
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/lumina-desktop/LSession.cpp20
-rw-r--r--src-qt5/core/lumina-desktop/LSession.h7
2 files changed, 27 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
//===============
diff --git a/src-qt5/core/lumina-desktop/LSession.h b/src-qt5/core/lumina-desktop/LSession.h
index a25f3c15..824eede7 100644
--- a/src-qt5/core/lumina-desktop/LSession.h
+++ b/src-qt5/core/lumina-desktop/LSession.h
@@ -21,6 +21,7 @@
#include <QMediaPlayer>
#include <QThread>
#include <QUrl>
+#include <QClipboard>
#include "Globals.h"
#include "AppMenu.h"
@@ -141,6 +142,8 @@ private:
int VersionStringToNumber(QString version);
+ bool ignoreClipboard; // flag for (handle/store)Clipboard
+
public slots:
void StartLogout();
void StartShutdown(bool skipupdates = false);
@@ -170,6 +173,10 @@ private slots:
void SessionEnding();
+ // Clipboard
+ void handleClipboard(QClipboard::Mode mode);
+ void storeClipboard(QString text, QClipboard::Mode mode);
+
signals:
//System Tray Signals
void VisualTrayAvailable(); //new Visual Tray Plugin can be registered
bgstack15