From dfac324cb6b02d19857f0e5dcced099d31ce957d Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 11 Oct 2017 10:34:53 -0400 Subject: Get the Lumina2 screensaver system converted over to the new QML-backed plugin system. Still need to clean up some old files within the source tree, but it all works right now. --- src-qt5/src-cpp/plugins-screensaver.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src-qt5/src-cpp/plugins-screensaver.cpp') diff --git a/src-qt5/src-cpp/plugins-screensaver.cpp b/src-qt5/src-cpp/plugins-screensaver.cpp index 8271e7ac..e9ac1330 100644 --- a/src-qt5/src-cpp/plugins-screensaver.cpp +++ b/src-qt5/src-cpp/plugins-screensaver.cpp @@ -6,6 +6,10 @@ //=========================================== #include "plugins-screensaver.h" #include +#include +#include +#include +#include //Relative directory to search along the XDG paths for screensavers #define REL_DIR QString("/lumina-desktop/screensavers") @@ -24,12 +28,10 @@ SSPlugin::~SSPlugin(){ void SSPlugin::loadFile(QString path){ data = QJsonObject(); currentfile = path; - SSPlugin SSP; QFile file(path); - if(!file.exists() || !file.open(QIODevice::ReadOnly)){ return SSP; } - SSP.data = QJsonDocument::fromJson(file.readAll()).object(); + if(!file.exists() || !file.open(QIODevice::ReadOnly)){ return; } + data = QJsonDocument::fromJson(file.readAll()).object(); file.close(); - return SSP; } bool SSPlugin::isLoaded(){ @@ -53,11 +55,13 @@ if(ok){ //go to the next qml level and see if required sub-items exist QJsonObject tmp = data.value("qml").toObject(); QStringList mustexist; - mustexist << tmp.value("exec").toString(); - ok = !mustexist.isEmpty(); //exec file should **always** be listed + QString exec = tmp.value("exec").toString(); + if(exec.isEmpty() || !exec.endsWith(".qml")){ return false; } + mustexist << exec; QJsonArray tmpA = data.value("additional_files").toArray(); for(int i=0; i SSPluginSystem::findAllPlugins(bool validonly = true){ +QList SSPluginSystem::findAllPlugins(bool validonly){ QList LIST; //Get the list of directories to search QStringList dirs; @@ -132,10 +137,12 @@ QList SSPluginSystem::findAllPlugins(bool validonly = true){ for(int i=0; i