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/LuminaXDG.h | 55 +++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'src-qt5/core/libLumina/LuminaXDG.h') diff --git a/src-qt5/core/libLumina/LuminaXDG.h b/src-qt5/core/libLumina/LuminaXDG.h index 5c012b9a..f2b1e3e2 100644 --- a/src-qt5/core/libLumina/LuminaXDG.h +++ b/src-qt5/core/libLumina/LuminaXDG.h @@ -46,8 +46,9 @@ struct XDGDesktopAction{ // ====================== // FreeDesktop Desktop Entry Framework (data structure) // ====================== -struct XDGDesktop{ -//public: +class XDGDesktop : public QObject{ + Q_OBJECT +public: enum XDGDesktopType { BAD, APP, LINK, DIR }; //Admin variables @@ -66,14 +67,18 @@ struct XDGDesktop{ //Type 2 (LINK) variables QString url; - //Constructor/destructor - XDGDesktop(){} - ~XDGDesktop(){ - actions.clear(); - showInList.clear(); notShowInList.clear(); actionList.clear(); mimeList.clear(); catList.clear(); keyList.clear(); - name.clear(); genericName.clear(); comment.clear(); icon.clear(); - exec.clear(); tryexec.clear(); path.clear(); startupWM.clear(); url.clear(); - } + //Constructor/destructor + XDGDesktop(QString filePath="", QObject *parent = 0); + ~XDGDesktop(){} + + //Functions for using this structure in various ways + void sync(); //syncronize this structure with the backend file(as listed in the "filePath" variable) + bool isValid(bool showAll = true); //See if this is a valid .desktop entry (showAll: don't filter out based on DE exclude/include lists) + + QString getDesktopExec(QString ActionID = ""); + bool saveDesktopFile(bool merge = true); //This will use the "filePath" variable for where to save the file + + bool setAutoStarted(bool autostart = true); }; // ======================== @@ -86,12 +91,12 @@ public: XDGDesktopList(QObject *parent = 0, bool watchdirs = false); ~XDGDesktopList(); //Main Interface functions - QList apps(bool showAll, bool showHidden); //showAll: include invalid files, showHidden: include NoShow/Hidden files + QList apps(bool showAll, bool showHidden); //showAll: include invalid files, showHidden: include NoShow/Hidden files //Administration variables (not typically used directly) QDateTime lastCheck; QStringList newApps, removedApps; //list of "new/removed" apps found during the last check - QHash files; /// + QHash files; /// public slots: void updateList(); //run the check routine @@ -114,7 +119,7 @@ signals: class LFileInfo : public QFileInfo{ private: QString mime, icon; - XDGDesktop desk; + XDGDesktop *desk; void loadExtraInfo(); @@ -122,7 +127,9 @@ public: //Couple overloaded contructors LFileInfo(QString filepath); LFileInfo(QFileInfo info); - ~LFileInfo(){} + ~LFileInfo(){ + desk->deleteLater(); + } //Functions for accessing the extra information // -- Return the mimetype for the file @@ -149,25 +156,25 @@ typedef QList LFileInfoList; class LXDG{ public: //Read/write a *.desktop file - static XDGDesktop loadDesktopFile(QString filePath, bool& ok); - static bool saveDesktopFile(XDGDesktop dFile, bool merge = true); + //static XDGDesktop* loadDesktopFile(QString filepath, bool&ok, QObject *parent = 0); + //static bool saveDesktopFile(XDGDesktop *dFile, bool merge = true); //Check a *.desktop file for validity (showAll skips the DE-exclusivity checks) - static bool checkValidity(XDGDesktop dFile, bool showAll = true); + //static bool checkValidity(XDGDesktop *dFile, bool showAll = true); //Check for a valid executable static bool checkExec(QString exec); //Get a list of all the directories where *.desktop files exist static QStringList systemApplicationDirs(); //Get a list of all the *.desktop files available on the system - static XDGDesktopList* systemAppsList(); //return a pointer to the entire class - static QList systemDesktopFiles(bool showAll = false, bool showHidden = false); //simplification for getting just the files + //static XDGDesktopList* systemAppsList(); //return a pointer to the entire class + static QList systemDesktopFiles(bool showAll = false, bool showHidden = false); //simplification for getting just the files //Sort a list of Desktop files into the proper categories - static QHash< QString, QList > sortDesktopCats(QList apps); + static QHash< QString, QList > sortDesktopCats(QList apps); //Return the icon to use for the given category static QString DesktopCatToIcon(QString cat); //Sort a list of Desktop files by name - static QList sortDesktopNames(QList apps); + static QList sortDesktopNames(QList apps); //Get the executable line from a Desktop file - static QString getDesktopExec(XDGDesktop app, QString ActionID = ""); + //static QString getDesktopExec(XDGDesktop *app, QString ActionID = ""); //Set all the default XDG Environment variables static void setEnvironmentVars(); //Find an icon from the current/default theme @@ -198,8 +205,8 @@ public: static QStringList loadMimeFileGlobs2(); //Find all the autostart *.desktop files - static QList findAutoStartFiles(bool includeInvalid = false); - static bool setAutoStarted(bool autostart, XDGDesktop app); + static QList findAutoStartFiles(bool includeInvalid = false); + //static bool setAutoStarted(bool autostart, XDGDesktop *app); static bool setAutoStarted(bool autostart, QString filePath); //for convenience }; -- cgit