diff options
19 files changed, 320 insertions, 200 deletions
@@ -1,8 +1,8 @@ global.h *.qm Makefile.Debug -Makefile.Release -*.o +Makefile.Release +*.o *.qmake.stash moc_*.cpp ui_*.h @@ -27,6 +27,18 @@ src-qt5/desktop-utils/lumina-archiver/lumina-archiver src-qt5/desktop-utils/lumina-calculator/lumina-calculator src-qt5/desktop-utils/lumina-pdf/lumina-pdf src-qt5/desktop-utils/lumina-notify/lumina-notify +src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/ +src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/.build/ +src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/Makefile +src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/liblthemeengine.so +src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/Makefile +src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/lthemeengine-sstest +src-qt5/core/lumina-theme-engine/src/lthemeengine-style/.build/ +src-qt5/core/lumina-theme-engine/src/lthemeengine-style/Makefile +src-qt5/core/lumina-theme-engine/src/lthemeengine-style/liblthemeengine-style.so +src-qt5/core/lumina-theme-engine/src/lthemeengine/Makefile +src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine +src-qt5/desktop-utils/lumina-mediaplayer/lumina-mediaplayer src-qt5/Makefile src-qt5/*/Makefile src-qt5/*/*/Makefile @@ -34,3 +46,6 @@ src-qt5/*/*/*/Makefile dev-tools/*/Makefile dev-tools/systray-tester/test-tray dev-tools/test-dbus/test +icon-theme/Makefile +icon-theme/*/Makefile +Makefile diff --git a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro index ebc13b6f..bb987e25 100644 --- a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro +++ b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro @@ -24,7 +24,7 @@ include(../libLumina/ExternalProcess.pri) include(../../src-cpp/NativeWindow.pri) include(../libLumina/XDGMime.pri) -include(../../src-cpp/plugins-screensaver.pri) +include(../../src-cpp/plugins-base.pri) #include all the main individual source groups include(src-screensaver/screensaver.pri) diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp index 7c098887..aa3214a2 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp @@ -7,6 +7,9 @@ #include "SSBaseWidget.h" +//Relative directory to search along the XDG paths for screensavers +#define REL_DIR QString("/lumina-desktop/screensavers") + #define DEBUG 0 // ======== @@ -39,10 +42,10 @@ void SSBaseWidget::startPainting(){ stopPainting(); //If a random plugin - grab one of the known plugins if(plugType=="random"){ - QList<SSPlugin> valid = SSPluginSystem::findAllPlugins(); + QList<SSPlugin> valid = PluginSystem::findAllPlugins<SSPlugin>(REL_DIR); if(!valid.isEmpty()){ cplug = valid[ qrand()%valid.length() ]; } //grab a random plugin }else if(plugType!="none"){ - cplug = SSPluginSystem::findPlugin(plugType); + cplug = PluginSystem::findPlugin<SSPlugin>(plugType, REL_DIR); } if(DEBUG){ qDebug() << " - Screen Saver:" << plugType << cplug.scriptURL() << cplug.isValid(); } if(cplug.isValid()){ diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h index 72e02702..e0a03d17 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h @@ -10,6 +10,7 @@ #define _LUMINA_DESKTOP_SCREEN_SAVER_BASE_WIDGET_H #include "global-includes.h" +#include <plugins-base.h> #include <plugins-screensaver.h> class SSBaseWidget : public QQuickView{ @@ -25,8 +26,8 @@ public slots: void stopPainting(); private: - QString plugType; - SSPlugin cplug; + QString plugType; + SSPlugin cplug; QTimer *restartTimer; private slots: diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index 47c6bfe1..3d901e8c 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -67,6 +67,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->actionUSB_Image->setEnabled(false); loadIcons(); ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " ); + + preservePaths = false; } MainUI::~MainUI(){ @@ -296,7 +298,7 @@ void MainUI::simpleExtractFiles(){ void MainUI::autoArchiveFiles(){ qDebug() << "Auto Archive Files:" << aaFileList; ui->label_progress->setText(tr("Adding Items...")); - BACKEND->startAdd(aaFileList); + BACKEND->startAdd(aaFileList, true); } void MainUI::extractSelection(){ diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.h b/src-qt5/desktop-utils/lumina-archiver/MainUI.h index 1a9d287c..0a5c094c 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.h +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.h @@ -26,13 +26,14 @@ public: void LoadArguments(QStringList); void loadIcons(); + bool preservePaths; private: Ui::MainUI *ui; - Backend *BACKEND; - QStringList aaFileList, sxList; - QString sxPath, sxFile; - QTimer *delayClose; + Backend *BACKEND; + QStringList aaFileList, sxList; + QString sxPath, sxFile; + QTimer *delayClose; QTreeWidgetItem* findItem(QString path, QTreeWidgetItem *start = 0); bool cleanItems(QStringList list, QTreeWidgetItem *start = 0); //returns true if anything gets cleaned diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index 5338efec..91e233d0 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -91,7 +91,7 @@ QString Backend::linkTo(QString file){ } //Modification routines -void Backend::startAdd(QStringList paths){ +void Backend::startAdd(QStringList paths, bool absolutePaths){ //if(paths.isEmpty() && !insertQueue.isEmpty()){ paths = insertQueue; } //load the queue if(paths.contains(filepath)){ paths.removeAll(filepath); } if(paths.isEmpty()){ return; } @@ -109,11 +109,12 @@ void Backend::startAdd(QStringList paths){ args << "-c" << "-a"; args << flags; //Now setup the parent dir - for(int i=0; i<paths.length(); i++){ - paths[i] = paths[i].section(parent,1,-1); - if(paths[i].startsWith("/")){ paths[i].remove(0,1); } - } - args << "-C" << parent; + if(!absolutePaths) { + for(int i=0; i<paths.length(); i++){ + paths[i] = paths[i].section(parent,1,-1); + if(paths[i].startsWith("/")){ paths[i].remove(0,1); } + } + args << "-C" << parent; } args << paths; if(QFile::exists(filepath)){ //append to existing args.replaceInStrings(filepath, tmpfilepath); diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h index 56a7dcfe..cb24a053 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h @@ -33,7 +33,7 @@ public: QString linkTo(QString file); //Modification routines - void startAdd(QStringList paths); + void startAdd(QStringList paths, bool absolutePaths = false); void startRemove(QStringList paths); void startExtract(QString path, bool overwrite, QString file=""); //path to dir, overwrite, optional file to extract (everything otherwise) void startExtract(QString path, bool overwrite, QStringList files); diff --git a/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_da.ts b/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_da.ts index 5cdf9fa4..7ae80a69 100644 --- a/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_da.ts +++ b/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_da.ts @@ -16,7 +16,7 @@ <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="610"/> <source>Education</source> - <translation>Uddannelse</translation> + <translation>Læring</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="611"/> @@ -41,7 +41,7 @@ <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="615"/> <source>Science</source> - <translation>Videnskab</translation> + <translation>Naturvidenskab</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="616"/> @@ -56,7 +56,7 @@ <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="618"/> <source>Utility</source> - <translation>Hjælpeværktøj</translation> + <translation>Redskab</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="619"/> diff --git a/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_nl.ts b/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_nl.ts index 9947da6d..1cba660b 100644 --- a/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_nl.ts +++ b/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_nl.ts @@ -6,67 +6,67 @@ <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="608"/> <source>Multimedia</source> - <translation type="unfinished"></translation> + <translation>Multimedia</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="609"/> <source>Development</source> - <translation type="unfinished"></translation> + <translation>Ontwikkeling</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="610"/> <source>Education</source> - <translation type="unfinished"></translation> + <translation>Onderwijs</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="611"/> <source>Games</source> - <translation type="unfinished"></translation> + <translation>Spellen</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="612"/> <source>Graphics</source> - <translation type="unfinished"></translation> + <translation>Grafisch</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="613"/> <source>Network</source> - <translation type="unfinished"></translation> + <translation>Netwerk</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="614"/> <source>Office</source> - <translation type="unfinished"></translation> + <translation>Kantoor</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="615"/> <source>Science</source> - <translation type="unfinished"></translation> + <translation>Wetenschappelijk</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="616"/> <source>Settings</source> - <translation type="unfinished"></translation> + <translation>Instellingen</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="617"/> <source>System</source> - <translation type="unfinished"></translation> + <translation>Systeem</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="618"/> <source>Utility</source> - <translation type="unfinished"></translation> + <translation>Hulpmiddel</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="619"/> <source>Wine</source> - <translation type="unfinished"></translation> + <translation>Wine</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="620"/> <source>Unsorted</source> - <translation type="unfinished"></translation> + <translation>Ongesorteerd</translation> </message> </context> <context> @@ -75,22 +75,22 @@ <location filename="../mainUI.ui" line="14"/> <location filename="../mainUI.cpp" line="53"/> <source>Calculator</source> - <translation type="unfinished"></translation> + <translation>Rekenmachine</translation> </message> <message> <location filename="../mainUI.ui" line="657"/> <source>Advanced Operations</source> - <translation type="unfinished"></translation> + <translation>Geavanceerde bewerkingen</translation> </message> <message> <location filename="../mainUI.cpp" line="83"/> <source>Percentage %1</source> - <translation type="unfinished"></translation> + <translation>Percentage %1</translation> </message> <message> <location filename="../mainUI.cpp" line="85"/> <source>Power %1</source> - <translation type="unfinished"></translation> + <translation>Prestatie %1</translation> </message> <message> <location filename="../mainUI.cpp" line="87"/> diff --git a/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_pt_BR.ts b/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_pt_BR.ts index 153a01b4..e26ecb58 100644 --- a/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_pt_BR.ts +++ b/src-qt5/desktop-utils/lumina-calculator/i18n/l-calc_pt_BR.ts @@ -6,67 +6,67 @@ <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="608"/> <source>Multimedia</source> - <translation type="unfinished"></translation> + <translation>Multimídia</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="609"/> <source>Development</source> - <translation type="unfinished"></translation> + <translation>Desenvolvimento</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="610"/> <source>Education</source> - <translation type="unfinished"></translation> + <translation>Educação</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="611"/> <source>Games</source> - <translation type="unfinished"></translation> + <translation>Jogos</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="612"/> <source>Graphics</source> - <translation type="unfinished"></translation> + <translation>Gráficos</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="613"/> <source>Network</source> - <translation type="unfinished"></translation> + <translation>Rede</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="614"/> <source>Office</source> - <translation type="unfinished"></translation> + <translation>Escritório</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="615"/> <source>Science</source> - <translation type="unfinished"></translation> + <translation>Ciência</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="616"/> <source>Settings</source> - <translation type="unfinished"></translation> + <translation>Configurações</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="617"/> <source>System</source> - <translation type="unfinished"></translation> + <translation>Sistema</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="618"/> <source>Utility</source> - <translation type="unfinished"></translation> + <translation>Utilitários</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="619"/> <source>Wine</source> - <translation type="unfinished"></translation> + <translation>Wine</translation> </message> <message> <location filename="../../../core/libLumina/LuminaXDG.cpp" line="620"/> <source>Unsorted</source> - <translation type="unfinished"></translation> + <translation>Não classificado</translation> </message> </context> <context> diff --git a/src-qt5/src-cpp/plugins-base.cpp b/src-qt5/src-cpp/plugins-base.cpp new file mode 100644 index 00000000..f38374df --- /dev/null +++ b/src-qt5/src-cpp/plugins-base.cpp @@ -0,0 +1,50 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "plugins-base.h" + +// ============ +// Base PLUGIN +// ============ +BasePlugin::BasePlugin(){ + +} + +BasePlugin::~BasePlugin(){ + +} + +void BasePlugin::loadFile(QString path){ + data = QJsonObject(); + currentfile = path; + QFile file(path); + if(!file.exists() || !file.open(QIODevice::ReadOnly)){ return; } + data = QJsonDocument::fromJson(file.readAll()).object(); + //qDebug() << "Loaded ScreenSaver Data:" << currentfile << data; + file.close(); +} + +QString BasePlugin::translatedObject(QString obj){ + QJsonObject tmp = data.value(obj).toObject(); + //Get the current locale + QString locale = getenv("LC_ALL"); + if(locale.isEmpty()){ locale = getenv("LC_MEBaseAGES"); } + if(locale.isEmpty()){ locale = getenv("LANG"); } + if(locale.isEmpty()){ locale = "default"; } + if(locale.contains(".")){ locale = locale.section(".",0,0); } //chop any charset code off the end + //Now find which localized string is available and return it + if(tmp.contains(locale)){ return tmp.value(locale).toString(); } + locale = locale.section("_",0,0); //full locale not found - look for shortened form + if(tmp.contains(locale)){ return tmp.value(locale).toString(); } + return tmp.value("default").toString(); //use the default version +} + +QUrl BasePlugin::scriptURL(){ + QString exec = data.value("qml").toObject().value("exec").toString(); + if(!exec.startsWith("/")){ exec.prepend( currentfile.section("/",0,-2)+"/" ); } + return QUrl::fromLocalFile(exec); +} + diff --git a/src-qt5/src-cpp/plugins-base.h b/src-qt5/src-cpp/plugins-base.h new file mode 100644 index 00000000..26b0eacc --- /dev/null +++ b/src-qt5/src-cpp/plugins-base.h @@ -0,0 +1,107 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is a simple class for managing all the various desktop +// screensaver plugins that could be available +//=========================================== +// NOTE: +// This class has a heirarchy-based lookup system +// USER plugins > SYSTEM plugins +// XDG_DATA_HOME/lumina-desktop/screensavers > XDG_DATA_DIRS/lumina-desktop/screensavers +//=========================================== +#ifndef _LUMINA_DESKTOP_BASE_PLUGINS_CLASS_H +#define _LUMINA_DESKTOP_BASE_PLUGINS_CLASS_H + +#include <QJsonObject> +#include <QString> +#include <QUrl> +#include <QObject> +#include <QJsonDocument> +#include <QJsonArray> +#include <QFile> +#include <QDir> +#include <QDebug> + +class BasePlugin{ +protected: + QString currentfile; + +public: + BasePlugin(); + virtual ~BasePlugin(); + + virtual void loadFile(QString path); + bool isLoaded() { return !data.isEmpty(); }; + bool containsDefault(QString obj) { return data.value(obj).toObject().contains("default"); } + + /** + * Check if the plugin is valid as long as the JSON is not empty, + * it contains at least a "name", "qml", and "description" object, + * and the "name" and "description" objects contain a "default" key. + **/ + virtual bool isValid() = 0; + + virtual QString translatedObject(QString obj); + virtual QUrl scriptURL(); + + QJsonObject data; //Hazardous to manually modify + QString relDir; +}; + +class PluginSystem{ +public: + template <class T> + static T findPlugin(QString, QString); + + template <class T> + static QList<T> findAllPlugins(QString, bool validonly=true); +}; + +// =================== +// Base PLUGIN SYSTEM +// =================== +template <class T> +T PluginSystem::findPlugin(QString name, QString REL_DIR){ + //qDebug() << "FindPlugin:" << name; + T BaseP; + if(name.startsWith("/") && QFile::exists(name)){ BaseP.loadFile(name); return BaseP;} //absolute path give - just load that one + //Cleanup the input name and ensure it has the right suffix + name = name.section("/",-1); + if(!name.endsWith(".json")){ name.append(".json"); } + //Get the list of directories to search + QStringList dirs; + dirs << QString(getenv("XDG_DATA_HOME")) << QString(getenv("XDG_DATA_DIRS")).split(":"); + //Look for that file within these directories and return the first one found + for(int i=0; i<dirs.length(); i++){ + if(!QFile::exists(dirs[i]+REL_DIR+"/"+name)){ continue; } + BaseP.loadFile(dirs[i]+REL_DIR+"/"+name); + if(BaseP.isValid()){ break; } //got a good one - stop here + } + return BaseP; +} + +template <class T> +QList<T> PluginSystem::findAllPlugins(QString REL_DIR, bool validonly) { + QList<T> LIST; + //Get the list of directories to search + QStringList dirs; + dirs << QString(getenv("XDG_DATA_HOME")) << QString(getenv("XDG_DATA_DIRS")).split(":"); + //Look for that file within these directories and return the first one found + for(int i=0; i<dirs.length(); i++){ + if(!QFile::exists(dirs[i]+REL_DIR)){ continue; } + QDir dir(dirs[i]+REL_DIR); + QStringList files = dir.entryList(QStringList() << "*.json", QDir::Files, QDir::Name); + //qDebug() << "Found Files:" << files; + for(int j=0; j<files.length(); j++){ + T tmp; + tmp.loadFile(dir.absoluteFilePath(files[j])); + //qDebug() << "Loaded File:" << files[j] << tmp.isValid(); + if(!validonly || tmp.isValid()){ LIST << tmp; } + } + } + return LIST; +} +#endif diff --git a/src-qt5/src-cpp/plugins-base.pri b/src-qt5/src-cpp/plugins-base.pri new file mode 100644 index 00000000..4aa9d96e --- /dev/null +++ b/src-qt5/src-cpp/plugins-base.pri @@ -0,0 +1,8 @@ +HEADERS *= $${PWD}/plugins-base.h \ + $${PWD}/plugins-screensaver.h \ + $${PWD}/plugins-desktop.h +SOURCES *= $${PWD}/plugins-base.cpp \ + $${PWD}/plugins-screensaver.cpp \ + $${PWD}/plugins-desktop.cpp + +INCLUDEPATH *= $${PWD} diff --git a/src-qt5/src-cpp/plugins-desktop.cpp b/src-qt5/src-cpp/plugins-desktop.cpp new file mode 100644 index 00000000..fdbd676d --- /dev/null +++ b/src-qt5/src-cpp/plugins-desktop.cpp @@ -0,0 +1,40 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "plugins-desktop.h" + +// ============ +// DT PLUGIN +// ============ +DTPlugin::DTPlugin(){ + +} + +DTPlugin::~DTPlugin(){ + +} + +bool DTPlugin::isValid(){ + if(data.isEmpty()){ return false; } + bool ok = data.contains("name") && data.contains("qml") && data.contains("description"); + ok &= containsDefault("name"); + ok &= containsDefault("description"); + if(ok) { + QJsonObject tmp = data.value("qml").toObject(); + QStringList mustexist; + 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<tmpA.count(); i++){ mustexist << tmpA[i].toString(); } + QString reldir = currentfile.section("/",0,-2) + "/"; + for(int i=0; i<mustexist.length() && ok; i++){ + if(mustexist[i].startsWith("/")){ ok = QFile::exists(mustexist[i]); } + else { ok = QFile::exists(reldir+mustexist[i]); } + } + } + return ok; +} diff --git a/src-qt5/src-cpp/plugins-desktop.h b/src-qt5/src-cpp/plugins-desktop.h new file mode 100644 index 00000000..ed576db1 --- /dev/null +++ b/src-qt5/src-cpp/plugins-desktop.h @@ -0,0 +1,29 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_DESKTOP_PLUGINS_CLASS_H +#define _LUMINA_DESKTOP_DESKTOP_PLUGINS_CLASS_H + +#include "plugins-base.h" +#include <QJsonObject> +#include <QString> +#include <QUrl> +#include <QObject> +#include <QJsonDocument> +#include <QJsonArray> +#include <QFile> +#include <QDir> +#include <QDebug> + +class DTPlugin : public BasePlugin{ +public: + DTPlugin(); + ~DTPlugin(); + + virtual bool isValid() Q_DECL_OVERRIDE; +}; + +#endif diff --git a/src-qt5/src-cpp/plugins-screensaver.cpp b/src-qt5/src-cpp/plugins-screensaver.cpp index 50796a52..6370b068 100644 --- a/src-qt5/src-cpp/plugins-screensaver.cpp +++ b/src-qt5/src-cpp/plugins-screensaver.cpp @@ -5,14 +5,6 @@ // See the LICENSE file for full details //=========================================== #include "plugins-screensaver.h" -#include <QJsonDocument> -#include <QJsonArray> -#include <QFile> -#include <QDir> -#include <QDebug> - -//Relative directory to search along the XDG paths for screensavers -#define REL_DIR QString("/lumina-desktop/screensavers") // ============ // SS PLUGIN @@ -25,35 +17,12 @@ SSPlugin::~SSPlugin(){ } -void SSPlugin::loadFile(QString path){ - data = QJsonObject(); - currentfile = path; - QFile file(path); - if(!file.exists() || !file.open(QIODevice::ReadOnly)){ return; } - data = QJsonDocument::fromJson(file.readAll()).object(); - //qDebug() << "Loaded ScreenSaver Data:" << currentfile << data; - file.close(); -} - -bool SSPlugin::isLoaded(){ - return !data.isEmpty(); -} - bool SSPlugin::isValid(){ if(data.isEmpty()){ return false; } bool ok = data.contains("name") && data.contains("qml") && data.contains("description"); - if(ok){ - //go to the next name level and see if required sub-items exist - QJsonObject tmp = data.value("name").toObject(); - ok = tmp.contains("default"); - } - if(ok){ - //go to the next description level and see if required sub-items exist - QJsonObject tmp = data.value("description").toObject(); - ok = tmp.contains("default"); - } -if(ok){ - //go to the next qml level and see if required sub-items exist + ok &= containsDefault("name"); + ok &= containsDefault("description"); + if(ok) { QJsonObject tmp = data.value("qml").toObject(); QStringList mustexist; QString exec = tmp.value("exec").toString(); @@ -62,7 +31,6 @@ if(ok){ QJsonArray tmpA = data.value("additional_files").toArray(); for(int i=0; i<tmpA.count(); i++){ mustexist << tmpA[i].toString(); } QString reldir = currentfile.section("/",0,-2) + "/"; - //qDebug() << "Got MustExist:" << mustexist << reldir; for(int i=0; i<mustexist.length() && ok; i++){ if(mustexist[i].startsWith("/")){ ok = QFile::exists(mustexist[i]); } else { ok = QFile::exists(reldir+mustexist[i]); } @@ -70,83 +38,3 @@ if(ok){ } return ok; } - -QString SSPlugin::translatedName(){ - QJsonObject tmp = data.value("name").toObject(); - //Get the current locale - QString locale = getenv("LC_ALL"); - if(locale.isEmpty()){ locale = getenv("LC_MESSAGES"); } - if(locale.isEmpty()){ locale = getenv("LANG"); } - if(locale.isEmpty()){ locale = "default"; } - if(locale.contains(".")){ locale = locale.section(".",0,0); } //chop any charset code off the end - //Now find which localized string is available and return it - if(tmp.contains(locale)){ return tmp.value(locale).toString(); } - locale = locale.section("_",0,0); //full locale not found - look for shortened form - if(tmp.contains(locale)){ return tmp.value(locale).toString(); } - return tmp.value("default").toString(); //use the default version -} - -QString SSPlugin::translatedDescription(){ - QJsonObject tmp = data.value("description").toObject(); - //Get the current locale - QString locale = getenv("LC_ALL"); - if(locale.isEmpty()){ locale = getenv("LC_MESSAGES"); } - if(locale.isEmpty()){ locale = getenv("LANG"); } - if(locale.isEmpty()){ locale = "default"; } - if(locale.contains(".")){ locale = locale.section(".",0,0); } //chop any charset code off the end - //Now find which localized string is available and return it - if(tmp.contains(locale)){ return tmp.value(locale).toString(); } - locale = locale.section("_",0,0); //full locale not found - look for shortened form - if(tmp.contains(locale)){ return tmp.value(locale).toString(); } - return tmp.value("default").toString(); //use the default version -} - -QUrl SSPlugin::scriptURL(){ - QString exec = data.value("qml").toObject().value("exec").toString(); - //qDebug() << "got exec:" << exec << data; - if(!exec.startsWith("/")){ exec.prepend( currentfile.section("/",0,-2)+"/" ); } - return QUrl::fromLocalFile(exec); -} - -// =================== -// SS PLUGIN SYSTEM -// =================== -SSPlugin SSPluginSystem::findPlugin(QString name){ - //qDebug() << "FindPlugin:" << name; - SSPlugin SSP; - if(name.startsWith("/") && QFile::exists(name)){ SSP.loadFile(name); return SSP;} //absolute path give - just load that one - //Cleanup the input name and ensure it has the right suffix - name = name.section("/",-1); - if(!name.endsWith(".json")){ name.append(".json"); } - //Get the list of directories to search - QStringList dirs; - dirs << QString(getenv("XDG_DATA_HOME")) << QString(getenv("XDG_DATA_DIRS")).split(":"); - //Look for that file within these directories and return the first one found - for(int i=0; i<dirs.length(); i++){ - if(!QFile::exists(dirs[i]+REL_DIR+"/"+name)){ continue; } - SSP.loadFile(dirs[i]+REL_DIR+"/"+name); - if(SSP.isValid()){ break; } //got a good one - stop here - } - return SSP; -} - -QList<SSPlugin> SSPluginSystem::findAllPlugins(bool validonly){ - QList<SSPlugin> LIST; - //Get the list of directories to search - QStringList dirs; - dirs << QString(getenv("XDG_DATA_HOME")) << QString(getenv("XDG_DATA_DIRS")).split(":"); - //Look for that file within these directories and return the first one found - for(int i=0; i<dirs.length(); i++){ - if(!QFile::exists(dirs[i]+REL_DIR)){ continue; } - QDir dir(dirs[i]+REL_DIR); - QStringList files = dir.entryList(QStringList() << "*.json", QDir::Files, QDir::Name); - //qDebug() << "Found Files:" << files; - for(int j=0; j<files.length(); j++){ - SSPlugin tmp; - tmp.loadFile(dir.absoluteFilePath(files[j])); - //qDebug() << "Loaded File:" << files[j] << tmp.isValid(); - if(!validonly || tmp.isValid()){ LIST << tmp; } - } - } - return LIST; -} diff --git a/src-qt5/src-cpp/plugins-screensaver.h b/src-qt5/src-cpp/plugins-screensaver.h index 9a7e98f5..042f824d 100644 --- a/src-qt5/src-cpp/plugins-screensaver.h +++ b/src-qt5/src-cpp/plugins-screensaver.h @@ -4,47 +4,26 @@ // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== -// This is a simple class for managing all the various desktop -// screensaver plugins that could be available -//=========================================== -// NOTE: -// This class has a heirarchy-based lookup system -// USER plugins > SYSTEM plugins -// XDG_DATA_HOME/lumina-desktop/screensavers > XDG_DATA_DIRS/lumina-desktop/screensavers -//=========================================== #ifndef _LUMINA_DESKTOP_SCREENSAVER_PLUGINS_CLASS_H #define _LUMINA_DESKTOP_SCREENSAVER_PLUGINS_CLASS_H +#include "plugins-base.h" #include <QJsonObject> #include <QString> #include <QUrl> #include <QObject> +#include <QJsonDocument> +#include <QJsonArray> +#include <QFile> +#include <QDir> +#include <QDebug> -class SSPlugin{ -private: - QString currentfile; - +class SSPlugin : public BasePlugin { public: - QJsonObject data; //Hazardous to manually modify - SSPlugin(); ~SSPlugin(); - void loadFile(QString path); - bool isLoaded(); - - bool isValid(); - - QString translatedName(); - QString translatedDescription(); - QUrl scriptURL(); -}; - -class SSPluginSystem{ -public: - static SSPlugin findPlugin(QString name); - static QList<SSPlugin> findAllPlugins(bool validonly = true); - + virtual bool isValid() Q_DECL_OVERRIDE; }; #endif diff --git a/src-qt5/src-cpp/plugins-screensaver.pri b/src-qt5/src-cpp/plugins-screensaver.pri deleted file mode 100644 index ad03f34c..00000000 --- a/src-qt5/src-cpp/plugins-screensaver.pri +++ /dev/null @@ -1,4 +0,0 @@ -HEADERS *= $${PWD}/plugins-screensaver.h -SOURCES *= $${PWD}/plugins-screensaver.cpp - -INCLUDEPATH *= $${PWD} |