From 82ebebfb8a5867b400c1df726a478bdcb9d7c005 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 22 Sep 2016 16:41:42 -0400 Subject: Large update to how XDGDesktop files are created/used. This impacts almost all tools/utilities within Lumina - please test (passed internal tests so far). This cleans up a lot of the backend XDG compliance class, moving lots of functionality into child functions of the XDGDesktop class and ensuring that they get cleaned up more regularly/properly. This *seems* to make the desktop startup a lot faster, even if the overall memory savings are slight (so far). --- src-qt5/core/libLumina/LuminaUtils.cpp | 5 +- src-qt5/core/libLumina/LuminaXDG.cpp | 647 ++++++++++++++++++++++++++------- src-qt5/core/libLumina/LuminaXDG.h | 55 +-- 3 files changed, 554 insertions(+), 153 deletions(-) (limited to 'src-qt5/core/libLumina') diff --git a/src-qt5/core/libLumina/LuminaUtils.cpp b/src-qt5/core/libLumina/LuminaUtils.cpp index 1ab3faac..dd4c75c4 100644 --- a/src-qt5/core/libLumina/LuminaUtils.cpp +++ b/src-qt5/core/libLumina/LuminaUtils.cpp @@ -159,9 +159,8 @@ QString LUtils::GenerateOpenTerminalExec(QString term, QString dirpath){ //if(!LUtils::isValidBinary(term)){ if(term.endsWith(".desktop")){ //Pull the binary name out of the shortcut - bool ok = false; - XDGDesktop DF = LXDG::loadDesktopFile(term,ok); - if(!ok){ term = "xterm"; } + XDGDesktop DF(term); + if(DF.type == XDGDesktop::BAD){ term = "xterm"; } else{ term= DF.exec.section(" ",0,0); } //only take the binary name - not any other flags }else{ term = "xterm"; //fallback diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index 36b05676..0e33f254 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -15,10 +15,396 @@ static QStringList mimeglobs; static qint64 mimechecktime; +//============================= +// XDGDesktop CLASS +//============================= +XDGDesktop::XDGDesktop(QString file, QObject *parent) : QObject(parent){ + isHidden=false; + useTerminal=false; + startupNotify=false; + type = XDGDesktop::BAD; + filePath = file; + exec = tryexec = ""; // just to make sure this is initialized + if(!filePath.isEmpty()){ sync(); } //if an input file is given - go ahead and sync now +} + +void XDGDesktop::sync(){ + //Reset internal vars + isHidden=false; + useTerminal=false; + startupNotify=false; + type = XDGDesktop::BAD; + exec = tryexec = ""; + //Read in the File + if(!filePath.endsWith(".desktop")){ return; } + lastRead = QDateTime::currentDateTime(); + QStringList file = LUtils::readFile(filePath); + if(file.isEmpty()){ return; } //done with init right here - nothing to load + //Get the current localization code + type = XDGDesktop::APP; //assume this initially if we read the file properly + QString lang = QLocale::system().name(); //lang code + QString slang = lang.section("_",0,0); //short lang code + //Now start looping over the information + XDGDesktopAction CDA; //current desktop action + bool insection=false; + bool inaction=false; + for(int i=0; i