diff options
author | Ken Moore <ken@ixsystems.com> | 2017-10-25 12:11:53 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-10-25 12:13:40 -0400 |
commit | 50cda0d1b7c6061cccb89389f44f9173026a678b (patch) | |
tree | cb70e562c6265d4ece4b0db0fee7732ff709ded7 /src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp | |
parent | Merge branch 'master' of http://github.com/trueos/lumina (diff) | |
download | lumina-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/RootDesktopObject.cpp')
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp | 77 |
1 files changed, 77 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 === |