From 7b03f5af04943e2de6f3041e67be23280219a238 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 19 Dec 2017 23:54:07 -0500 Subject: Add a new C++ object: PanelObject This is tied into the RootDesktopObject as well as the ScreenObject, resulting in global-session panels as well as per-screen panels. --- .../src-desktop/src-cpp/PanelObject.cpp | 44 +++++++++++++++++++ .../src-desktop/src-cpp/PanelObject.h | 49 ++++++++++++++++++++++ .../src-desktop/src-cpp/RootDesktopObject.cpp | 24 +++++++++++ .../src-desktop/src-cpp/RootDesktopObject.h | 8 ++++ .../src-desktop/src-cpp/ScreenObject.cpp | 26 ++++++++++++ .../src-desktop/src-cpp/ScreenObject.h | 9 ++++ .../src-desktop/src-cpp/src-cpp.pri | 7 ++-- 7 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp create mode 100644 src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop') diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp new file mode 100644 index 00000000..471da58f --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.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 "PanelObject.h" +#include +#include + +PanelObject::PanelObject(QString id, QObject *parent) : QObject(parent){ + panel_id = id; +} + +void PanelObject::RegisterType(){ + static bool done = false; + if(done){ return; } + done=true; + qmlRegisterType("Lumina.Backend.PanelObject",2,0, "PanelObject"); +} + +QString PanelObject::name(){ return panel_id; } +QString PanelObject::background(){ + if(bg.isEmpty()){ return "transparent"; } + return bg; +} +int PanelObject::x(){ return geom.x(); } +int PanelObject::y(){ return geom.y(); } +int PanelObject::width(){ return geom.width(); } +int PanelObject::height(){ return geom.height(); } + +void PanelObject::setBackground(QString fileOrColor){ + if(bg!=fileOrColor){ + bg = fileOrColor; + emit backgroundChanged(); + } +} + +void PanelObject::setGeometry( QRect newgeom ){ + if(geom!=newgeom){ + geom = newgeom; + emit geomChanged(); + } +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h new file mode 100644 index 00000000..a788fa07 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h @@ -0,0 +1,49 @@ +//=========================================== +// 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 Panel info to the QML classes +//=========================================== +#ifndef _LUMINA_DESKTOP_PANEL_OBJECT_H +#define _LUMINA_DESKTOP_PANEL_OBJECT_H +#include +#include +#include + +class PanelObject : 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: + QString panel_id, bg; + QRect geom; + +public: + PanelObject(QString id = "", 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); + void setGeometry(QRect newgeom); + +signals: + void backgroundChanged(); + void geomChanged(); +}; + +#endif 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 index 60cf56c3..c1652ba6 100644 --- 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 @@ -21,6 +21,9 @@ RootDesktopObject::~RootDesktopObject(){ } void RootDesktopObject::RegisterType(){ + static bool done = false; + if(done){ return; } + done=true; qmlRegisterType("Lumina.Backend.RootDesktopObject", 2, 0, "RootDesktopObject"); //Also register any types that are needed by this class ScreenObject::RegisterType(); @@ -47,6 +50,26 @@ ScreenObject* RootDesktopObject::screen(QString id){ return 0; } +QStringList RootDesktopObject::panels(){ + //qDebug() << "Request Panels:" << panel_objects.length(); + QStringList names; + for(int i=0; iname(); } + return names; +} + +PanelObject* RootDesktopObject::panel(QString id){ + //qDebug() << "Got Panel Request:" << id; + for(int i=0; iname()==id){ return panel_objects[i]; } + } + return 0; +} + +void RootDesktopObject::setPanels(QList list){ + panel_objects = list; + emit panelsChanged(); +} + void RootDesktopObject::logout(){ emit startLogout(); } @@ -85,4 +108,5 @@ void RootDesktopObject::ChangeWallpaper(QString screen, QString value){ } } + // === 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 index ba586701..93beb6e4 100644 --- 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 @@ -17,6 +17,7 @@ class RootDesktopObject : public QObject{ Q_OBJECT //Define all the QML Properties here (interface between QML and the C++ methods below) Q_PROPERTY( QStringList screens READ screens NOTIFY screensChanged) + Q_PROPERTY( QStringList panels READ panels NOTIFY panelsChanged) public: //main contructor/destructor @@ -31,13 +32,19 @@ public: //QML Read Functions QStringList screens(); Q_INVOKABLE ScreenObject* screen(QString id); + Q_INVOKABLE QStringList panels(); + Q_INVOKABLE PanelObject* panel(QString id); + + void setPanels(QList list); //QML Access Functions Q_INVOKABLE void logout(); Q_INVOKABLE void lockscreen(); Q_INVOKABLE void mousePositionChanged(); + private: QList s_objects; + QList panel_objects; public slots: void updateScreens(); //rescan/update screen objects @@ -47,6 +54,7 @@ private slots: signals: void screensChanged(); + void panelsChanged(); void startLogout(); void mouseMoved(); void lockScreen(); 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 index 4c1d6189..82622403 100644 --- 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 @@ -13,7 +13,12 @@ ScreenObject::ScreenObject(QScreen *scrn, QObject *parent) : QObject(parent){ } void ScreenObject::RegisterType(){ + static bool done = false; + if(done){ return; } + done=true; qmlRegisterType("Lumina.Backend.ScreenObject",2,0, "ScreenObject"); + //Also register any types that are needed by this class + PanelObject::RegisterType(); } QString ScreenObject::name(){ return bg_screen->name(); } @@ -29,3 +34,24 @@ void ScreenObject::setBackground(QString fileOrColor){ emit backgroundChanged(); } } + +void ScreenObject::setPanels(QList list){ + panel_objects = list; + emit panelsChanged(); +} + +//QML Read Functions +QStringList ScreenObject::panels(){ + //qDebug() << "Request Panels:" << panel_objects.length(); + QStringList names; + for(int i=0; iname(); } + return names; +} + +PanelObject* ScreenObject::panel(QString id){ + //qDebug() << "Got Panel Request:" << id; + for(int i=0; iname()==id){ return panel_objects[i]; } + } + return 0; +} 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 index 8076f1ae..1afff6d2 100644 --- 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 @@ -12,6 +12,8 @@ #include #include +#include "PanelObject.h" + class ScreenObject : public QObject { Q_OBJECT Q_PROPERTY( QString name READ name ) @@ -20,10 +22,12 @@ class ScreenObject : public QObject { Q_PROPERTY( int y READ y NOTIFY geomChanged) Q_PROPERTY( int width READ width NOTIFY geomChanged) Q_PROPERTY( int height READ height NOTIFY geomChanged) + Q_PROPERTY( QStringList panels READ panels NOTIFY panelsChanged) private: QScreen *bg_screen; QString bg; + QList panel_objects; public: ScreenObject(QScreen *scrn = 0, QObject *parent = 0); @@ -36,6 +40,10 @@ public: Q_INVOKABLE int y(); Q_INVOKABLE int width(); Q_INVOKABLE int height(); + Q_INVOKABLE QStringList panels(); + Q_INVOKABLE PanelObject* panel(QString id); + + void setPanels(QList list); public slots: void setBackground(QString fileOrColor); @@ -43,6 +51,7 @@ public slots: signals: void backgroundChanged(); void geomChanged(); + void panelsChanged(); }; #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 index 33b699da..899f4968 100644 --- 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 @@ -1,8 +1,9 @@ SOURCES *= $${PWD}/RootDesktopObject.cpp \ - $${PWD}/ScreenObject.cpp + $${PWD}/ScreenObject.cpp \ + $${PWD}/PanelObject.cpp HEADERS *= $${PWD}/RootDesktopObject.h \ - $${PWD}/ScreenObject.h + $${PWD}/ScreenObject.h \ + $${PWD}/PanelObject.h INCLUDEPATH *= $${PWD} - -- cgit From 7207ddde754868ef5071e3d5ebb91a0b9bfbc5ca Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 20 Dec 2017 00:06:17 -0500 Subject: Make sure the QML filenames correspond to the C++ objects (PanelObject.h -> Panel.qml) Add a new "Panel.qml" widget for reserved screen areas. --- .../src-desktop/src-qml/Panel.qml | 26 ++++++++++++++++++++++ .../src-desktop/src-qml/RootDesktop.qml | 3 ++- .../src-desktop/src-qml/Screen.qml | 26 ++++++++++++++++++++++ .../src-desktop/src-qml/WallpaperImage.qml | 26 ---------------------- .../src-desktop/src-qml/src-qml.pri | 3 ++- .../src-desktop/src-qml/src-qml.qrc | 3 ++- 6 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml create mode 100644 src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml delete mode 100644 src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop') diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml new file mode 100644 index 00000000..846b5b55 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml @@ -0,0 +1,26 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +import QtQuick 2.2 +import QtQuick.Window 2.2 +import QtQuick.Controls 1 + +import Lumina.Backend.PanelObject 2.0 + +AnimatedImage { + //C++ backend object + property string screen_id + property PanelObject object + + //Normal geometries/placements + asynchronous: true + clip: true + source: object.background + x: object.x + y: object.y + width: object.width + height: object.height + } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml index e0381e23..beecb848 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml @@ -49,8 +49,9 @@ Rectangle { //Setup the wallpapers Repeater{ model: RootObject.screens - QML.WallpaperImage{ + QML.Screen{ screen_id: modelData + object: RootObject.screen(modelData) z: 0+index } } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml new file mode 100644 index 00000000..3b83653a --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml @@ -0,0 +1,26 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +import QtQuick 2.2 +import QtQuick.Window 2.2 +import QtQuick.Controls 1 + +import Lumina.Backend.ScreenObject 2.0 + +AnimatedImage { + //C++ backend object + property string screen_id + property ScreenObject object + + //Normal geometries/placements + asynchronous: true + clip: true + source: object.background + x: object.x + y: object.y + width: object.width + height: object.height + } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml deleted file mode 100644 index 1b44963f..00000000 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml +++ /dev/null @@ -1,26 +0,0 @@ -//=========================================== -// Lumina-desktop source code -// Copyright (c) 2017, Ken Moore -// Available under the 3-clause BSD license -// See the LICENSE file for full details -//=========================================== -import QtQuick 2.2 -import QtQuick.Window 2.2 -import QtQuick.Controls 1 - -import Lumina.Backend.ScreenObject 2.0 - -AnimatedImage { - //C++ backend object - property string screen_id - property ScreenObject object: RootObject.screen(screen_id) - - //Normal geometries/placements - asynchronous: true - clip: true - source: object.background - x: object.x - y: object.y - width: object.width - height: object.height - } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri index fed18e02..ad07902a 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri @@ -2,7 +2,8 @@ lupdate_only{ SOURCES *= $${PWD}/RootDesktop.qml \ $${PWD}/ContextMenu.qml \ - $${PWD}/WallpaperImage.qml + $${PWD}/Screen.qml \ + $${PWD}/Panel.qml } RESOURCES *= $${PWD}/src-qml.qrc diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc index ebdcc606..b0c66e20 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc @@ -2,6 +2,7 @@ RootDesktop.qml ContextMenu.qml - WallpaperImage.qml + Screen.qml + Panel.qml -- cgit From 70a95acc3d3cae25fd99a027d932960cce819299 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 20 Dec 2017 00:28:17 -0500 Subject: Setup the RootDesktopObject to start providing NativeWindow objects to the QML interface. --- .../src-desktop/src-cpp/RootDesktopObject.cpp | 21 +++++++++++++++++++++ .../src-desktop/src-cpp/RootDesktopObject.h | 10 +++++++++- .../src-desktop/src-qml/RootDesktop.qml | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop') 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 index c1652ba6..5750ac2d 100644 --- 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 @@ -65,11 +65,32 @@ PanelObject* RootDesktopObject::panel(QString id){ return 0; } +QStringList RootDesktopObject::windows(){ + //qDebug() << "Request Panels:" << panel_objects.length(); + QStringList names; + for(int i=0; iid()); } + return names; +} + +NativeWindow* RootDesktopObject::window(QString id){ + //qDebug() << "Got Panel Request:" << id; + WId chk = id.toInt(); //numerical ID's in this case + for(int i=0; iid()==chk){ return window_objects[i]; } + } + return 0; +} + void RootDesktopObject::setPanels(QList list){ panel_objects = list; emit panelsChanged(); } +void RootDesktopObject::setWindows(QList list){ + window_objects = list; + emit windowsChanged(); +} + void RootDesktopObject::logout(){ emit startLogout(); } 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 index 93beb6e4..838b5f7d 100644 --- 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 @@ -10,6 +10,7 @@ #define _LUMINA_DESKTOP_QML_BACKEND_ROOT_DESKTOP_OBJECT_H #include #include +#include #include "ScreenObject.h" @@ -18,6 +19,7 @@ class RootDesktopObject : public QObject{ //Define all the QML Properties here (interface between QML and the C++ methods below) Q_PROPERTY( QStringList screens READ screens NOTIFY screensChanged) Q_PROPERTY( QStringList panels READ panels NOTIFY panelsChanged) + Q_PROPERTY( QStringList windows READ windows NOTIFY windowsChanged); public: //main contructor/destructor @@ -30,12 +32,15 @@ public: static RootDesktopObject* instance(); //QML Read Functions - QStringList screens(); + Q_INVOKABLE QStringList screens(); Q_INVOKABLE ScreenObject* screen(QString id); Q_INVOKABLE QStringList panels(); Q_INVOKABLE PanelObject* panel(QString id); + Q_INVOKABLE QStringList windows(); + Q_INVOKABLE NativeWindow* window(QString id); void setPanels(QList list); + void setWindows(QList list); //QML Access Functions Q_INVOKABLE void logout(); @@ -45,6 +50,7 @@ public: private: QList s_objects; QList panel_objects; + QList window_objects; public slots: void updateScreens(); //rescan/update screen objects @@ -55,6 +61,8 @@ private slots: signals: void screensChanged(); void panelsChanged(); + void windowsChanged(); + void startLogout(); void mouseMoved(); void lockScreen(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml index beecb848..c564ee42 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml @@ -46,7 +46,7 @@ Rectangle { //Create the context menu itself QML.ContextMenu { id: contextMenu } - //Setup the wallpapers + //Setup the screens/wallpapers Repeater{ model: RootObject.screens QML.Screen{ -- cgit