aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp44
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.h34
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/desktop.pri11
-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
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/ContextMenu.qml36
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml57
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml25
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri7
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc7
13 files changed, 436 insertions, 3 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp
new file mode 100644
index 00000000..0cfa4e6b
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.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 "RootWindow.h"
+
+RootWindow::RootWindow() : QObject(){
+ root_win = QWindow::fromWinId( QX11Info::appRootWindow() ); //
+ root_view = new QQuickView(root_win); //make it a child of the root window
+ root_obj = RootDesktopObject::instance();
+ syncRootSize();
+ connect(root_win, SIGNAL(widthChanged(int)), this, SLOT(syncRootSize()) );
+ connect(root_win, SIGNAL(heightChanged(int)),this, SLOT(syncRootSize()) );
+ //Now setup the QQuickView
+ root_view->setResizeMode(QQuickView::SizeRootObjectToView);
+ root_view->engine()->rootContext()->setContextProperty("RootObject", root_obj);
+ RootDesktopObject::RegisterType(); //make sure object classes are registered with the QML subsystems
+}
+
+RootWindow::~RootWindow(){
+ root_view->deleteLater();
+ root_obj->deleteLater();
+}
+
+void RootWindow::start(){
+ root_view->setSource(QUrl("qrc:///qml/RootDesktop.qml"));
+ root_win->show();
+ root_view->show();
+}
+
+void RootWindow::syncRootSize(){
+ //qDebug() << "Sync Root Size:" << root_win->width() << root_win->height() << root_view->geometry();
+ QList<QScreen*> screens = QApplication::screens();
+ QRect unif;
+ for(int i=0; i<screens.length(); i++){ unif = unif.united(screens[i]->geometry()); }
+ if(unif.width() != root_view->width() || unif.height() != root_view->height()){
+ root_view->setGeometry(0, 0, unif.width(), unif.height() );
+ emit RootResized(root_view->geometry());
+ }
+ root_obj->updateScreens();
+ //qDebug() << " - after:" << root_view->geometry();
+}
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.h b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.h
new file mode 100644
index 00000000..ba489465
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.h
@@ -0,0 +1,34 @@
+//===========================================
+// Lumina-desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#ifndef _LUMINA_DESKTOP_ROOT_WINDOW_H
+#define _LUMINA_DESKTOP_ROOT_WINDOW_H
+#include <global-includes.h>
+
+class RootWindow : public QObject{
+ Q_OBJECT
+private:
+ QWindow *root_win;
+ QQuickView *root_view;
+ RootDesktopObject *root_obj;
+
+public:
+ RootWindow();
+ ~RootWindow();
+
+ void start();
+
+public slots:
+ void syncRootSize();
+
+signals:
+ void startLogout();
+ void RegisterVirtualRoot(WId);
+ void RootResized(QRect);
+ void MouseMoved();
+};
+
+#endif
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/desktop.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/desktop.pri
index 75aef8a6..e4c4faeb 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/desktop.pri
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/desktop.pri
@@ -1,6 +1,11 @@
-SOURCES *= $${PWD}/ContextMenu.cpp
+QT *= gui widgets qml quick
-HEADERS *= $${PWD}/ContextMenu.h
+SOURCES *= $${PWD}/RootWindow.cpp
+
+HEADERS *= $${PWD}/RootWindow.h
#update the includepath so we can just #include as needed without paths
-INCLUDEPATH *= ${PWD}
+INCLUDEPATH *= $${PWD}
+
+include($${PWD}/src-cpp/src-cpp.pri)
+include($${PWD}/src-qml/src-qml.pri)
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}
+
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/ContextMenu.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/ContextMenu.qml
new file mode 100644
index 00000000..e5bac0b5
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/ContextMenu.qml
@@ -0,0 +1,36 @@
+//===========================================
+// 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 2.0
+
+import Lumina.Backend.RootDesktopObject 2.0
+
+Menu {
+ id: contextMenu
+ closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
+ MenuItem {
+ text: "Lock Screen"
+ onTriggered: {
+ RootObject.lockscreen()
+ }
+ }
+
+ MenuItem {
+ text: "Logout"
+ //iconName: "system-log-out"
+ indicator: Image{
+ asynchronous: true
+ //autoTransform: true
+ //source: "image://theme/system-logout"
+ source: "file:///usr/local/share/icons/material-design-light/scalable/actions/system-log-out.svg"
+ }
+ onTriggered: {
+ RootObject.logout()
+ }
+ }
+ }
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
new file mode 100644
index 00000000..a1a9164f
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml
@@ -0,0 +1,57 @@
+//===========================================
+// 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.2
+import QtQuick.Window 2.2
+import QtQuick.Controls 2.0
+
+import "." as QML
+
+import Lumina.Backend.RootDesktopObject 2.0
+import Lumina.Backend.ScreenObject 2.0
+
+Rectangle {
+ id: rootCanvas
+ color: "black"
+
+ //Setup the right-click context menu
+ MouseArea {
+ anchors.fill: rootCanvas
+ acceptedButtons: Qt.RightButton
+ onClicked: {
+ contextMenu.x = mouseX
+ contextMenu.y = mouseY
+ contextMenu.open()
+ }
+ onPositionChanged: {
+ RootObject.mousePositionChanged()
+ }
+ }
+
+ //Create the context menu itself
+ QML.ContextMenu { id: contextMenu }
+
+ //Setup the wallpapers
+ Repeater{
+ model: RootObject.screens
+ QML.WallpaperImage{
+ //console.log( modelData.name() )
+ object: modelData
+ z: 0+index
+ }
+ }
+}
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
new file mode 100644
index 00000000..4d39b0b8
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml
@@ -0,0 +1,25 @@
+//===========================================
+// 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 2.0
+
+import Lumina.Backend.ScreenObject 2.0
+
+AnimatedImage {
+ //C++ backend object
+ 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/src-qml.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri
new file mode 100644
index 00000000..99905253
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri
@@ -0,0 +1,7 @@
+#Show the QML files to lupdate for translation purposes - not for the actual build
+lupdate_only{
+ SOURCES *= $${PWD}/RootDesktop.qml \
+ $${PWD}/ContextMenu.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
new file mode 100644
index 00000000..ebdcc606
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="qml">
+ <file>RootDesktop.qml</file>
+ <file>ContextMenu.qml</file>
+ <file>WallpaperImage.qml</file>
+ </qresource>
+</RCC>
bgstack15