From 13659175f2f99f91373c26f4c1bbbdce2f6ea4be Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 22 Jul 2015 13:31:50 -0400 Subject: Add support into libLumina for additional "Actions" listed in *.desktop files. --- libLumina/LuminaXDG.cpp | 106 ++++++++++++++++++++++++++++++++---------------- libLumina/LuminaXDG.h | 10 +++++ 2 files changed, 80 insertions(+), 36 deletions(-) (limited to 'libLumina') diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp index ed576f23..19a3fbae 100644 --- a/libLumina/LuminaXDG.cpp +++ b/libLumina/LuminaXDG.cpp @@ -6,6 +6,7 @@ //=========================================== #include "LuminaXDG.h" #include "LuminaOS.h" +#include "LuminaUtils.h" #include #include @@ -16,33 +17,47 @@ static qint64 mimechecktime; XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){ //Create the outputs ok=false; - //following the specifications, Name and Type are the mandatory in any .desktop file - //bool hasName=false, hasType=false; XDGDesktop DF; DF.isHidden=false; DF.useTerminal=false; DF.startupNotify=false; DF.type = XDGDesktop::APP; DF.filePath = filePath; + DF.lastRead = QDateTime::currentDateTime(); DF.exec = DF.tryexec = ""; // just to make sure this is initialized //Check input file path validity - QFile file(filePath); - if(!file.exists()){ return DF; } //invalid file + //QFile file(filePath); + //if(!file.exists()){ return DF; } //invalid file //Get the current localization code QString lang = QLocale::system().name(); //lang code + QString slang = lang.section("_",0,0); //short lang code //Open the file - if(!file.open(QIODevice::Text | QIODevice::ReadOnly)){ - return DF; - } - QTextStream os(&file); + //if(!file.open(QIODevice::Text | QIODevice::ReadOnly)){ + //return DF; + //} + //QTextStream os(&file); //Read in the File bool insection=false; - while(!os.atEnd()){ - QString line = os.readLine(); - //Check that this is the entry portion of the file (not the action/other sections) + bool inaction=false; + QStringList file = LUtils::readFile(filePath); + if(file.isEmpty()){ return DF; } + XDGDesktopAction CDA; //current desktop action + for(int i=0; i #include +class XDGDesktopAction{ +public: + //Admin variables + QString ID; //The ID name for this action (should correspond to an entry in the "actionList" for the XDGDesktop below) + //General Variables + QString name, icon, exec; +}; + class XDGDesktop{ public: enum XDGDesktopType { BAD, APP, LINK, DIR }; //Admin variables QString filePath; //which file this structure contains the information for (absolute path) + QDateTime lastRead; //when this structure was created from the file XDGDesktopType type; //General variables QString name, genericName, comment, icon; @@ -44,6 +53,7 @@ public: QString exec, tryexec, path, startupWM; QStringList actionList, mimeList, catList, keyList; bool useTerminal, startupNotify; + QList actions; //Type 2 (LINK) variables QString url; -- cgit