blob: 9842712efced4a5e7c47fc8c23166f46e7a46d40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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 ===
|