aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-10-25 12:11:53 -0400
committerKen Moore <ken@ixsystems.com>2017-10-25 12:13:40 -0400
commit50cda0d1b7c6061cccb89389f44f9173026a678b (patch)
treecb70e562c6265d4ece4b0db0fee7732ff709ded7 /src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp
parentMerge branch 'master' of http://github.com/trueos/lumina (diff)
downloadlumina-50cda0d1b7c6061cccb89389f44f9173026a678b.tar.gz
lumina-50cda0d1b7c6061cccb89389f44f9173026a678b.tar.bz2
lumina-50cda0d1b7c6061cccb89389f44f9173026a678b.zip
Re-arrange the 2.0 desktop sources (QML + associated C++ files).
Also another checkpoint commit with some of the QML desktop stuff (have a working context menu, wallpapers not working yet though)
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp77
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h54
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp31
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h48
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/src-cpp.pri8
5 files changed, 218 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp
new file mode 100644
index 00000000..9842712e
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp
@@ -0,0 +1,77 @@
+//===========================================
+// 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"
+#include <QQmlEngine>
+#include <QApplication>
+#include <QScreen>
+
+#include <QDebug>
+
+// === PUBLIC ===
+RootDesktopObject::RootDesktopObject(QObject *parent) : QObject(parent){
+ updateScreens(); //make sure the internal list is updated right away
+}
+
+RootDesktopObject::~RootDesktopObject(){
+
+}
+
+void RootDesktopObject::RegisterType(){
+ qmlRegisterType<RootDesktopObject>("Lumina.Backend.RootDesktopObject", 2, 0, "RootDesktopObject");
+ //Also register any types that are needed by this class
+ ScreenObject::RegisterType();
+}
+
+RootDesktopObject* RootDesktopObject::instance(){
+ static RootDesktopObject* r_obj = new RootDesktopObject();
+ return r_obj;
+}
+
+//QML Read Functions
+QList<ScreenObject*> RootDesktopObject::screens(){
+ return s_objects;
+}
+
+void RootDesktopObject::logout(){
+ emit startLogout();
+}
+
+void RootDesktopObject::lockscreen(){
+ emit lockScreen();
+}
+
+void RootDesktopObject::mousePositionChanged(){
+ emit mouseMoved();
+}
+
+// === 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[i]->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;
+ emit screensChanged();
+ for(int i=0; i<s_objects.length(); i++){
+ s_objects[i]->emit geomChanged();
+ }
+}
+
+void RootDesktopObject::ChangeWallpaper(QString screen, QString value){
+ for(int i=0; i<s_objects.length(); i++){
+ if(s_objects[i]->name()==screen){ s_objects[i]->setBackground(value); break; }
+ }
+}
+
+// === PRIVATE ===
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h
new file mode 100644
index 00000000..dd7c7ab3
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h
@@ -0,0 +1,54 @@
+//===========================================
+// 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_QML_BACKEND_ROOT_DESKTOP_OBJECT_H
+#define _LUMINA_DESKTOP_QML_BACKEND_ROOT_DESKTOP_OBJECT_H
+#include <QObject>
+#include <QList>
+
+#include "ScreenObject.h"
+
+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();
+
+ static void RegisterType();
+
+ //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();
+
+ //QML Access Functions
+ Q_INVOKABLE void logout();
+ Q_INVOKABLE void lockscreen();
+ Q_INVOKABLE void mousePositionChanged();
+private:
+ QList<ScreenObject*> s_objects;
+
+public slots:
+ void updateScreens(); //rescan/update screen objects
+ void ChangeWallpaper(QString screen, QString);
+
+private slots:
+
+signals:
+ void screensChanged();
+ void startLogout();
+ void mouseMoved();
+ void lockScreen();
+
+};
+#endif
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp
new file mode 100644
index 00000000..4c1d6189
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp
@@ -0,0 +1,31 @@
+//===========================================
+// Lumina-desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "ScreenObject.h"
+#include <QQmlEngine>
+#include <QDebug>
+
+ScreenObject::ScreenObject(QScreen *scrn, QObject *parent) : QObject(parent){
+ bg_screen = scrn;
+}
+
+void ScreenObject::RegisterType(){
+ qmlRegisterType<ScreenObject>("Lumina.Backend.ScreenObject",2,0, "ScreenObject");
+}
+
+QString ScreenObject::name(){ return bg_screen->name(); }
+QString ScreenObject::background(){ qDebug() << "Got Background:" << bg_screen->name() << bg << bg_screen->geometry(); return bg; }
+int ScreenObject::x(){ return bg_screen->geometry().x(); }
+int ScreenObject::y(){ return bg_screen->geometry().y(); }
+int ScreenObject::width(){ return bg_screen->geometry().width(); }
+int ScreenObject::height(){ return bg_screen->geometry().height(); }
+
+void ScreenObject::setBackground(QString fileOrColor){
+ if(bg!=fileOrColor){
+ bg = fileOrColor;
+ emit backgroundChanged();
+ }
+}
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h
new file mode 100644
index 00000000..8076f1ae
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h
@@ -0,0 +1,48 @@
+//===========================================
+// 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 Screen/Wallpaper info to the QML classes
+//===========================================
+#ifndef _LUMINA_DESKTOP_SCREEN_DESKTOP_OBJECT_H
+#define _LUMINA_DESKTOP_SCREEN_DESKTOP_OBJECT_H
+#include <QObject>
+#include <QString>
+#include <QScreen>
+
+class ScreenObject : public QObject {
+ Q_OBJECT
+ Q_PROPERTY( QString name READ name )
+ Q_PROPERTY( QString background READ background NOTIFY backgroundChanged)
+ Q_PROPERTY( int x READ x NOTIFY geomChanged)
+ Q_PROPERTY( int y READ y NOTIFY geomChanged)
+ Q_PROPERTY( int width READ width NOTIFY geomChanged)
+ Q_PROPERTY( int height READ height NOTIFY geomChanged)
+
+private:
+ QScreen *bg_screen;
+ QString bg;
+
+public:
+ ScreenObject(QScreen *scrn = 0, QObject *parent = 0);
+
+ static void RegisterType();
+
+ Q_INVOKABLE QString name();
+ Q_INVOKABLE QString background();
+ Q_INVOKABLE int x();
+ Q_INVOKABLE int y();
+ Q_INVOKABLE int width();
+ Q_INVOKABLE int height();
+
+public slots:
+ void setBackground(QString fileOrColor);
+
+signals:
+ void backgroundChanged();
+ void geomChanged();
+};
+
+#endif
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/src-cpp.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/src-cpp.pri
new file mode 100644
index 00000000..33b699da
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/src-cpp.pri
@@ -0,0 +1,8 @@
+SOURCES *= $${PWD}/RootDesktopObject.cpp \
+ $${PWD}/ScreenObject.cpp
+
+HEADERS *= $${PWD}/RootDesktopObject.h \
+ $${PWD}/ScreenObject.h
+
+INCLUDEPATH *= $${PWD}
+
bgstack15