DtkCore
DTK Core module
dstandardpaths.h
1/*
2 * Copyright (C) 2017 ~ 2021 Deepin Technology Co., Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef DTK_CORE_FILESYSTEM_DSTANDARDPATHS_H
19#define DTK_CORE_FILESYSTEM_DSTANDARDPATHS_H
20
21#include <QStandardPaths>
22
23#include "dtkcore_global.h"
24
25DCORE_BEGIN_NAMESPACE
26
27class DStandardPathsPrivate;
28class LIBDTKCORESHARED_EXPORT DStandardPaths
29{
30public:
31 enum Mode {
32 Auto,
33 Snap,
34 Test,
35 };
36
37 static QString writableLocation(QStandardPaths::StandardLocation type);
38 static QStringList standardLocations(QStandardPaths::StandardLocation type);
39
40 static QString locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile);
41 static QStringList locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile);
42 static QString findExecutable(const QString &executableName, const QStringList &paths = QStringList());
43 static void setMode(Mode mode);
44
45 enum class XDG {
46 DataHome,
47 ConfigHome,
48 CacheHome,
49 RuntimeTime
50 };
51
52 enum class DSG {
53 AppData,
54 DataDir
55 };
56
57 static QString homePath();
58 static QString homePath(const uint uid);
59 static QString path(XDG type);
60 static QString path(DSG type);
61 static QStringList paths(DSG type);
62 static QString filePath(XDG type, QString fileName);
63 static QString filePath(DSG type, QString fileName);
64
65private:
68 Q_DISABLE_COPY(DStandardPaths)
69};
70
71DCORE_END_NAMESPACE
72
73#endif // DTK_CORE_FILESYSTEM_DSTANDARDPATHS_H
DStandardPaths提供兼容Snap/Dtk标准的路径模式。DStandardPaths实现了Qt的QStandardPaths主要接口.
Definition: dstandardpaths.h:29