aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/src-cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-10-12 13:51:47 -0400
committerKen Moore <ken@ixsystems.com>2017-10-12 13:51:47 -0400
commit34bac34d5d1e7d95120ab745e2be42dd3cdccef5 (patch)
treebbae0a401a7146ccf93d56949a9eb237857b2005 /src-qt5/src-cpp
parentTinker with the color divisions in "Warp" a bit - ensure more even distributi... (diff)
downloadlumina-34bac34d5d1e7d95120ab745e2be42dd3cdccef5.tar.gz
lumina-34bac34d5d1e7d95120ab745e2be42dd3cdccef5.tar.bz2
lumina-34bac34d5d1e7d95120ab745e2be42dd3cdccef5.zip
Add the beginnings of the root desktop QML system. Not finished yet.
Diffstat (limited to 'src-qt5/src-cpp')
-rw-r--r--src-qt5/src-cpp/RootDesktopObject.cpp44
-rw-r--r--src-qt5/src-cpp/RootDesktopObject.h71
2 files changed, 115 insertions, 0 deletions
diff --git a/src-qt5/src-cpp/RootDesktopObject.cpp b/src-qt5/src-cpp/RootDesktopObject.cpp
new file mode 100644
index 00000000..088c88b7
--- /dev/null
+++ b/src-qt5/src-cpp/RootDesktopObject.cpp
@@ -0,0 +1,44 @@
+//===========================================
+// Lumina-desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "RootDesktopObject.h"
+
+// === PUBLIC ===
+RootDesktopObject::RootDesktopObject(QObject *parent = 0){
+ updateScreens(); //make sure the internal list is updated right away
+}
+
+RootDesktopObject::~RootDesktopObject(){
+
+}
+
+static RootDesktopObject* RootDesktopObject::instance(){
+ static RootDesktopObject* r_obj = new RootDesktopObject();
+ return r_obj;
+}
+
+//QML Read Functions
+QList<QScreen*> RootDesktopObject::screens(){
+ return ;
+}
+
+// === PUBLIC SLOTS ===
+void RootDesktopObject::updateScreens(){
+ QList<QScreen*> scrns = QApplication::screens();
+ QList<ScreenObject*> tmp; //copy of the internal array initially
+ for(int i=0; i<scrns.length(); i++){
+ bool found = false;
+ for(int j=0; j<s_objects.length() && !found; j++){
+ if(s_objects[j].name()==scrns.name()){ found = true; tmp << s_objects.takeAt(j); }
+ }
+ if(!found){ tmp << new ScreenObject(scrns[i], this); }
+ }
+ //Delete any leftover objects
+ for(int i=0; i<s_objects.length(); i++){ s_objects[i]->deleteLater(); }
+ s_objects = tmp;
+}
+
+// === PRIVATE ===
diff --git a/src-qt5/src-cpp/RootDesktopObject.h b/src-qt5/src-cpp/RootDesktopObject.h
new file mode 100644
index 00000000..08c15fa2
--- /dev/null
+++ b/src-qt5/src-cpp/RootDesktopObject.h
@@ -0,0 +1,71 @@
+//===========================================
+// Lumina-desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is the base C++ object that is used to pass information to the QML "RootDesktop" object
+//===========================================
+#ifndef _LUMINA_DESKTOP_ROOT_DESKTOP_OBJECT_H
+#define _LUMINA_DESKTOP_ROOT_DESKTOP_OBJECT_H
+
+class ScreenObject : public QObject{
+ Q_OBJECT
+ Q_PROPERTY( QString name READ name )
+ Q_PROPERTY( QString background READ background NOTIFY backgroundChanged)
+ Q_PROPERTY( QScreen * screen READ screen)
+
+private:
+ QScreen* bg_screen;
+ QString bg;
+
+public
+ ScreenObject(QScreen *scrn, QObject *parent = 0) : QObject(parent){
+ bg_screen = scrn;
+ }
+
+ QString name(){ return bg_screen->name(); }
+ QString background(){ return bg; }
+ QScreen* screen(){ return screen; }
+
+public slots:
+ void setBackground(QString fileOrColor){
+ if(bg!=fileOrColor){
+ bg = fileOrColor;
+ emit backgroundChanged();
+ }
+ }
+
+signals:
+ void backgroundChanged();
+};
+
+
+class RootDesktopObject : public QObject{
+ Q_OBJECT
+ //Define all the QML Properties here (interface between QML and the C++ methods below)
+ Q_PROPERTY( QList<ScreenObject*> screens READ screens NOTIFY screensChanged)
+
+public:
+ //main contructor/destructor
+ RootDesktopObject(QObject *parent = 0);
+ ~RootDesktopObject();
+ //primary interface to fetch the current instance of the class (so only one is running at any given time)
+ static RootDesktopObject* instance();
+
+ //QML Read Functions
+ QList<ScreenObject*> screens();
+
+private:
+ QList<ScreenObject*> s_objects;
+
+public slots:
+ void updateScreens(); //rescan/update screen objects
+
+private slots:
+
+signals:
+ void screensChanged();
+
+};
+#endif
bgstack15