Debian Codegraph @

Dekko/utils/Paths.h

raw symbols SCIP
1 /* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef PATHS_H
19 #define PATHS_H
20
21 #include <QObject>
22 #include <QtQuick>
23 #include <QQmlEngine>
24 #include <QJSEngine>
25
26 class Paths : public QObject
27 {
28 Q_OBJECT
29 Q_PROPERTY(QString cachePath READ cachePath CONSTANT)
30 Q_PROPERTY(QString configPath READ configPath CONSTANT)
31
32 Q_ENUMS(ActionIcon)
33 Q_ENUMS(UserScript)
34
35 public:
36 explicit Paths(QObject *parent = 0);
37
38 enum ActionIcon {
39 NoIcon,AccountIcon,AttachmentIcon,BackIcon,ContextMenuIcon,DeleteIcon,DraftIcon,EditIcon,
40 FolderIcon,ImportantIcon,CombineInboxIcon,InboxIcon,JunkIcon,MailForwardIcon,MailForwardedIcon,
41 MailReadIcon,MailRepliedIcon,MailRepliedAllIcon,MailReplyIcon,MailReplyAllIcon,
42 MailUnreadIcon,NavigationMenuIcon,NewContactIcon,UnStarredIcon,NoteIcon,NoneSelectedIcon,
43 SearchIcon,SelectIcon,SendIcon,SentIcon,StarredIcon,SyncIcon,TagsIcon,ViewFullScreenIcon,
44 CalendarTodayIcon,FilterIcon,TimerIcon,ViewListSymbolic,TickIcon,UndoIcon,CopyIcon,
45 CutIcon,PasteIcon,ShareIcon,BrowserIcon
46 };
47
48 enum UserScript {
49 CidQueryScript,FakeScript,FontScript,
50 OverFlowScript,ViewportScript,ZoomScript
51 };
52
53 static QString iconUrl(const ActionIcon icon, bool prefix = true);
54 // QML use only as it prepends qrc:/// to the icon url instead of :/
55 Q_INVOKABLE QUrl actionIconUrl(const ActionIcon icon);
56 Q_INVOKABLE QString userscript(const UserScript script);
57 Q_INVOKABLE QString standardHomeLocation() {
58 return Paths::homeLocation();
59 }
60 Q_INVOKABLE QString mimeIconForUrl(const QString &url);
61 Q_INVOKABLE QString mimeIconForMimeType(const QString &mimeType);
62
63 QString cachePath() const;
64 QString configPath() const;
65 QString cacheFileLocation(const QString &fileName);
66 QString configFileLocation(const QString &fileName);
67 static QString standardCacheLocation();
68 static QString standardConfigLocation();
69 static QString standardDataLocation();
70 static QString homeLocation();
71 static QString cacheLocationForFile(const QString & fileName);
72 static QString configLocationForFile(const QString & fileName);
73 static QString dataLocationForFile(const QString & fileName);
74 static bool checkForStaleLockFile(QLockFile **lockFile, QString &filePath, QString &errorMessage);
75 static QString findProviderFile();
76 static QString providerIconForDomain(const QString &domain);
77
78 static QObject *factory(QQmlEngine *engine, QJSEngine *scriptEngine);
79
80 signals:
81
82 public slots:
83
84 private:
85 QString findUserScript(const QString &scriptName);
86
87 class MimeTypeCache {
88 public:
89 explicit MimeTypeCache(void);
90
91 void mapIconToMimeType(const QString &mimeType, const QString &icon);
92 QString getIconForMimeType(const QString &type);
93 QMimeType getMimeTypeForFile(const QString &path);
94 QMimeType getMimeTypeForName(const QString &name);
95
96 private:
97 QMimeDatabase mimeDb;
98 QHash<QString, QString> iconForMimetype;
99 };
100 static MimeTypeCache s_mimeCache;
101 };
102
103 #endif // PATHS_H