source: lumina/libLumina/LuminaXDG.h @ b8c1be6

releng/10.0.3releng/10.1releng/10.1.1releng/10.1.2
Last change on this file since b8c1be6 was b8c1be6, checked in by Ken Moore <ken@…>, 9 months ago

Speed up sequential mime-type checks by caching the contents of the globs2 DB. The minimum time for the cache to get updated is 30 seconds.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1//===========================================
2//  Lumina-DE source code
3//  Copyright (c) 2013, Ken Moore
4//  Available under the 3-clause BSD license
5//  See the LICENSE file for full details
6//===========================================
7// These structures/classes are for conforming to the FreeDesktop standards
8// REFERENCE: (*.desktop files) http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html
9// -- Current Implementation (OCT 2013) --
10// Desktop File Version Compliance: 1.0 (except "DBusActivatable")
11// Icon Theme Compliance: Built in to Qt (QIcon::fromTheme()) with "oxygen" theme default
12//===========================================
13
14 
15#ifndef _LUMINA_LIBRARY_XDG_H
16#define _LUMINA_LIBRARY_XDG_H
17
18#include <QFile>
19#include <QDir>
20#include <QFileInfo>
21#include <QStringList>
22#include <QString>
23#include <QIcon>
24#include <QList>
25#include <QHash>
26#include <QLocale>
27#include <QTextStream>
28#include <QDateTime>
29#include <QDebug>
30
31class XDGDesktop{
32public:
33  enum XDGDesktopType { BAD, APP, LINK, DIR };
34  //Admin variables
35  QString filePath; //which file this structure contains the information for (absolute path)
36  XDGDesktopType type;
37  //General variables
38  QString name, genericName, comment, icon;
39  QStringList showInList, notShowInList;
40  bool isHidden;
41  //Type 1 (APP) variables
42  QString exec, tryexec, path, startupWM;
43  QStringList actionList, mimeList, catList, keyList;
44  bool useTerminal, startupNotify;
45  //Type 2 (LINK) variables
46  QString url;
47 
48  //Constructor/destructor
49  XDGDesktop(){}
50  ~XDGDesktop(){}
51};
52
53
54class LXDG{
55public:
56        //Read a *.desktop file
57        static XDGDesktop loadDesktopFile(QString filePath, bool& ok);
58        //Check a *.desktop file for validity (showAll skips the DE-exclusivity checks)
59        static bool checkValidity(XDGDesktop dFile, bool showAll = true); 
60        //Check for a valid executable
61        static bool checkExec(QString exec);
62        //Get a list of all the directories where *.desktop files exist
63        static QStringList systemApplicationDirs();
64        //Get a list of all the *.desktop files available on the system
65        static QList<XDGDesktop> systemDesktopFiles(bool showAll = true, bool showHidden = false);
66        //Sort a list of Desktop files into the proper categories
67        static QHash< QString, QList<XDGDesktop> > sortDesktopCats(QList<XDGDesktop> apps);
68        //Sort a list of Desktop files by name
69        static QList<XDGDesktop> sortDesktopNames(QList<XDGDesktop> apps);
70        //Get the executable line from a Desktop file
71        static QString getDesktopExec(XDGDesktop);
72        //Set all the default XDG Environment variables
73        static void setEnvironmentVars();
74        //Find an icon from the current/default theme
75        static QIcon findIcon(QString iconName, QString fallback = "");
76        //Recursivly compile a list of child directories with *.png files in them
77        static QStringList getChildIconDirs(QString parent);
78        //List all the mime-type directories
79        static QStringList systemMimeDirs();
80        //Find the mime-type icon for a particular file extension
81        static QIcon findMimeIcon(QString extension);
82        //Find the mime-type of a particular file extension
83        static QString findAppMimeForFile(QString extension);
84        //Load all the "globs2" mime database files
85        static QStringList loadMimeFileGlobs2();
86};
87
88#endif
89
Note: See TracBrowser for help on using the repository browser.