aboutsummaryrefslogtreecommitdiff
path: root/libLumina
diff options
context:
space:
mode:
Diffstat (limited to 'libLumina')
-rw-r--r--libLumina/LuminaUtils.cpp34
-rw-r--r--libLumina/LuminaUtils.h2
-rw-r--r--libLumina/quickplugins/quick-sample.qml12
-rw-r--r--libLumina/quickplugins/sample.qml7
4 files changed, 45 insertions, 10 deletions
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp
index 540598cf..42f36962 100644
--- a/libLumina/LuminaUtils.cpp
+++ b/libLumina/LuminaUtils.cpp
@@ -189,15 +189,43 @@ bool LUtils::validQuickPlugin(QString ID){
}
QString LUtils::findQuickPluginFile(QString ID){
- if(ID.startsWith("quick-")){ ID = ID.section("-",1,50); }
+ if(ID.startsWith("quick-")){ ID = ID.section("-",1,50); } //just in case
//Give preference to any user-supplied plugins (overwrites for system plugins)
- QString path = QDir::homePath()+"/.lumina/quickplugins/"+ID+".qml";
+ QString path = QDir::homePath()+"/.lumina/quickplugins/quick-"+ID+".qml";
if( QFile::exists(path) ){return path; }
- path = LOS::LuminaShare()+"quickplugins/"+ID+".qml";
+ path = LOS::LuminaShare()+"quickplugins/quick-"+ID+".qml";
if( QFile::exists(path) ){return path; }
return ""; //could not be found
}
+QStringList LUtils::listQuickPlugins(){
+ QDir dir(QDir::homePath()+"/.lumina/quickplugins");
+ QStringList files = dir.entryList(QStringList() << "quick-*.qml", QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
+ dir.cd(LOS::LuminaShare()+"quickplugins");
+ files << files = dir.entryList(QStringList() << "quick-*.qml", QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
+ for(int i=0; i<files.length(); i++){
+ files[i] = files[i].section("quick-",1,100).section(".qml",0,0); //just grab the ID out of the middle of the filename
+ }
+ files.removeDuplicates();
+ return files;
+}
+
+QStringList LUtils::infoQuickPlugin(QString ID){ //Returns: [Name, Description, Icon]
+ QString path = findQuickPluginFile(ID);
+ if(path.isEmpty()){ return QStringList(); } //invalid ID
+ QStringList contents = LUtils::readFile(path).filter("//").filter("=").filter("Plugin");
+ if(contents.isEmpty()){ return QStringList(); } //invalid file (unreadable)
+ QStringList info; info << "" << "" << "";
+ for(int i=0; i<contents.length(); i++){
+ if(contents[i].contains("Plugin-Name=")){ info[0] = contents[i].section("Plugin-Name=",1,1).simplified(); }
+ else if(contents[i].contains("Plugin-Description=")){ info[1] = contents[i].section("Plugin-Description=",1,1).simplified(); }
+ else if(contents[i].contains("Plugin-Icon=")){ info[2] = contents[i].section("Plugin-Icon=",1,1).simplified(); }
+ }
+ if(info[0].isEmpty()){ info[0]=ID; }
+ if(info[2].isEmpty()){ info[2]="preferences-plugin"; }
+ return info;
+}
+
QStringList LUtils::listFavorites(){
static QDateTime lastRead;
QDateTime cur = QDateTime::currentDateTime();
diff --git a/libLumina/LuminaUtils.h b/libLumina/LuminaUtils.h
index 605f2653..188563dc 100644
--- a/libLumina/LuminaUtils.h
+++ b/libLumina/LuminaUtils.h
@@ -56,6 +56,8 @@ public:
//Various function for finding valid QtQuick plugins on the system
static bool validQuickPlugin(QString ID);
static QString findQuickPluginFile(QString ID);
+ static QStringList listQuickPlugins(); //List of valid ID's
+ static QStringList infoQuickPlugin(QString ID); //Returns: [Name, Description, Icon]
//Various functions for the favorites sub-system
// Formatting Note: "<name>::::[dir/app/<mimetype>]::::<path>"
diff --git a/libLumina/quickplugins/quick-sample.qml b/libLumina/quickplugins/quick-sample.qml
new file mode 100644
index 00000000..18b10d77
--- /dev/null
+++ b/libLumina/quickplugins/quick-sample.qml
@@ -0,0 +1,12 @@
+// Plugin-Name=Sample
+// Plugin-Description=A simple example for QtQuick/QML plugins
+// Plugin-Icon=preferences-plugin
+// Created: Ken Moore (ken@pcbsd.org) May 2015
+
+import QtQuick.Controls 1.3
+
+Label {
+ text: "Sample"
+ color: "blue"
+ font.bold: true
+} \ No newline at end of file
diff --git a/libLumina/quickplugins/sample.qml b/libLumina/quickplugins/sample.qml
deleted file mode 100644
index b12702ba..00000000
--- a/libLumina/quickplugins/sample.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick.Controls 1.3
-
-Label {
- text: "Sample"
- color: "blue"
- font.bold: true
-} \ No newline at end of file
bgstack15