-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdefaulttheme.cpp
More file actions
70 lines (63 loc) · 2.62 KB
/
defaulttheme.cpp
File metadata and controls
70 lines (63 loc) · 2.62 KB
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
#include "defaulttheme.h"
DefaultTheme::~DefaultTheme(){
qDebug() << "Default theme dead";
}
void DefaultTheme::registerTypes(const char* /*uri*/)
{
return;
}
void DefaultTheme::initializeEngine(QQmlEngine *engine, const char* /*uri*/)
{
QQuickStyle::setStyle("Default");
QQmlApplicationEngine * appEngine = static_cast<QQmlApplicationEngine* >(engine);
if(!appEngine){
qDebug() << "Engine is not a valid instance of QQmlApplicationEngine";
return;
}
guiEvents = new GUIEvents();
appEngine->rootContext()->setContextProperty("GUIEvents", guiEvents);
appEngine->rootContext()->setContextObject(this);
engine->addImageProvider("icons", new ThemeIconProvider);
}
void DefaultTheme::onEvent(AbstractPlugin* plugin, QString sender, QString event, QVariant eventData) {
qDebug() << "Theme event : " << event << eventData;
if(event == "Notification"){
QJsonDocument doc = QJsonDocument::fromJson(eventData.toString().toUtf8());
if(!doc.isObject()){
qDebug() << "Invalid JSON";
return;
}
QJsonObject object = doc.object();
if(!object.keys().contains("image") || !object.keys().contains("title") || !object.keys().contains("description")){
qDebug() << "Missing event description";
}
emit guiEvents->notificationReceived(object.toVariantMap());
} else if (event == "OpenOverlay") {
QVariantMap map = eventData.toMap();
emit guiEvents->openOverlay(plugin->getSettings(), plugin->getContextProperty(), map["source"].toString(), map["properties"].toMap());
} else if (event == "CloseOverlay") {
emit guiEvents->closeOverlay();
} else if (event == "ChangePageNext") {
emit guiEvents->changePageNext();
} else if (event == "ChangePagePrev") {
emit guiEvents->changePagePrev();
} else if (event == "ChangePageIndex") {
emit guiEvents->changePageIndex(eventData.toInt());
} else if (event == "ChangePagePrevIndex") {
emit guiEvents->changePagePrevIndex();
}
}
QVariantList DefaultTheme::getMountedVolumes(){
QVariantList ret;
for (QStorageInfo storage : QStorageInfo::mountedVolumes()) {
if (storage.isValid() && storage.isReady()) {
if (!storage.isReadOnly() && storage.fileSystemType() != "tmpfs" && storage.fileSystemType() != "squashfs") {
QVariantMap volume;
volume.insert("name", storage.displayName());
volume.insert("path",storage.rootPath());
ret.append(volume);
}
}
}
return ret;
}