From 50cda0d1b7c6061cccb89389f44f9173026a678b Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 25 Oct 2017 12:11:53 -0400 Subject: 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) --- .../src-desktop/src-cpp/RootDesktopObject.cpp | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp') 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 +#include +#include + +#include + +// === PUBLIC === +RootDesktopObject::RootDesktopObject(QObject *parent) : QObject(parent){ + updateScreens(); //make sure the internal list is updated right away +} + +RootDesktopObject::~RootDesktopObject(){ + +} + +void RootDesktopObject::RegisterType(){ + qmlRegisterType("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 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 scrns = QApplication::screens(); + QList tmp; //copy of the internal array initially + for(int i=0; iname()==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; ideleteLater(); } + s_objects = tmp; + emit screensChanged(); + for(int i=0; iemit geomChanged(); + } +} + +void RootDesktopObject::ChangeWallpaper(QString screen, QString value){ + for(int i=0; iname()==screen){ s_objects[i]->setBackground(value); break; } + } +} + +// === PRIVATE === -- cgit