diff options
author | Ken Moore <ken@ixsystems.com> | 2017-10-12 13:51:47 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-10-12 13:51:47 -0400 |
commit | 34bac34d5d1e7d95120ab745e2be42dd3cdccef5 (patch) | |
tree | bbae0a401a7146ccf93d56949a9eb237857b2005 /src-qt5 | |
parent | Tinker with the color divisions in "Warp" a bit - ensure more even distributi... (diff) | |
download | lumina-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')
-rw-r--r-- | src-qt5/src-cpp/RootDesktopObject.cpp | 44 | ||||
-rw-r--r-- | src-qt5/src-cpp/RootDesktopObject.h | 71 | ||||
-rw-r--r-- | src-qt5/src-qml/RootDesktop.qml | 39 |
3 files changed, 154 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 diff --git a/src-qt5/src-qml/RootDesktop.qml b/src-qt5/src-qml/RootDesktop.qml new file mode 100644 index 00000000..d4d7fed7 --- /dev/null +++ b/src-qt5/src-qml/RootDesktop.qml @@ -0,0 +1,39 @@ +//=========================================== +// 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 QML script the launches/controls the desktop interface itself +//=========================================== +// NOTE: This needs to be paired/used with the corresponding C++ class: RootDesktopObject +// Which should be added as the "RootObject" context property to the QML engine +//------------------ +// Example Code: +// RootDesktopObject *rootobj = new RootDesktopObject(); +// QQuickView *root = new QQuickView(); +// root->setResizeMode(QQuickView::SizeRootObjectToView); +// root->engine()->rootContext->setContextProperty("RootObject", rootobj); +//=========================================== +import QtQuick 2.0 +import QtQuick.Window 2.2 + +Rectangle { + id: RootCanvas + color: "black" + + //Setup the wallpapers + Repeater{ + model: RootObject.screens + AnimatedImage { + id: modelData.name + asynchronous: true + clip: true + source: modelData.background + x: modelData.screen.virtualX + y: modelData.screen.virtualY + width: modelData.screen.width + height: modelData.screen.height + } + } +} |