aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/src-cpp/plugins-base.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2018-01-02 22:00:13 +0000
committerWeblate <noreply@weblate.org>2018-01-02 22:00:13 +0000
commit76f036e835d89572b92006c7f6d4918b7c799664 (patch)
treea80a82bda02e0fc740ea607767ad2409c8aeaa8d /src-qt5/src-cpp/plugins-base.cpp
parentTranslated using Weblate (Portuguese (Brazil)) (diff)
parentMerge branch 'master' of github.com:trueos/lumina (diff)
downloadlumina-76f036e835d89572b92006c7f6d4918b7c799664.tar.gz
lumina-76f036e835d89572b92006c7f6d4918b7c799664.tar.bz2
lumina-76f036e835d89572b92006c7f6d4918b7c799664.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/src-cpp/plugins-base.cpp')
-rw-r--r--src-qt5/src-cpp/plugins-base.cpp50
1 files changed, 50 insertions, 0 deletions
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);
+}
+
bgstack15