1 | // Copyright (C) 2017 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qquicklabsplatformstandardpaths_p.h" |
5 | |
6 | #if QT_DEPRECATED_SINCE(6, 4) |
7 | |
8 | #include <QtQml/qqmlengine.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | /*! |
13 | \qmltype StandardPaths |
14 | \inherits QtObject |
15 | //! \instantiates QQuickLabsPlatformStandardPaths |
16 | \inqmlmodule Qt.labs.platform |
17 | \since 5.8 |
18 | \deprecated [6.4] Use QtCore::StandardPaths instead. |
19 | \brief Provides access to the standard system paths. |
20 | |
21 | The StandardPaths singleton type provides methods for querying the standard |
22 | system paths. The standard paths are mostly useful in conjunction with the |
23 | FileDialog and FolderDialog types. |
24 | |
25 | \qml |
26 | FileDialog { |
27 | folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) |
28 | } |
29 | \endqml |
30 | |
31 | \labs |
32 | |
33 | \sa QtCore::StandardPaths, FileDialog, FolderDialog, QStandardPaths |
34 | */ |
35 | |
36 | static QList<QUrl> toUrlList(const QStringList &paths) |
37 | { |
38 | QList<QUrl> urls; |
39 | urls.reserve(asize: paths.size()); |
40 | for (const QString &path : paths) |
41 | urls += QUrl::fromLocalFile(localfile: path); |
42 | return urls; |
43 | } |
44 | |
45 | QQuickLabsPlatformStandardPaths::QQuickLabsPlatformStandardPaths(QObject *parent) |
46 | : QObject(parent) |
47 | { |
48 | } |
49 | |
50 | QObject *QQuickLabsPlatformStandardPaths::create(QQmlEngine *engine, QJSEngine *scriptEngine) |
51 | { |
52 | Q_UNUSED(scriptEngine); |
53 | return new QQuickLabsPlatformStandardPaths(engine); |
54 | } |
55 | |
56 | /*! |
57 | \qmlmethod string Qt.labs.platform::StandardPaths::displayName(StandardLocation type) |
58 | |
59 | \include standardpath/functiondocs.qdocinc displayName |
60 | |
61 | \sa QStandardPaths::displayName() |
62 | */ |
63 | QString QQuickLabsPlatformStandardPaths::displayName(QStandardPaths::StandardLocation type) |
64 | { |
65 | return QStandardPaths::displayName(type); |
66 | } |
67 | |
68 | /*! |
69 | \qmlmethod url Qt.labs.platform::StandardPaths::findExecutable(string executableName, list<string> paths) |
70 | |
71 | \include standardpath/functiondocs.qdocinc findExecutable |
72 | |
73 | \sa QStandardPaths::findExecutable() |
74 | */ |
75 | QUrl QQuickLabsPlatformStandardPaths::findExecutable(const QString &executableName, const QStringList &paths) |
76 | { |
77 | return QUrl::fromLocalFile(localfile: QStandardPaths::findExecutable(executableName, paths)); |
78 | } |
79 | |
80 | /*! |
81 | \qmlmethod url Qt.labs.platform::StandardPaths::locate(StandardLocation type, string fileName, LocateOptions options) |
82 | |
83 | \include standardpath/functiondocs.qdocinc locate |
84 | |
85 | \sa QStandardPaths::locate() |
86 | */ |
87 | QUrl QQuickLabsPlatformStandardPaths::locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options) |
88 | { |
89 | return QUrl::fromLocalFile(localfile: QStandardPaths::locate(type, fileName, options)); |
90 | } |
91 | |
92 | /*! |
93 | \qmlmethod list<url> Qt.labs.platform::StandardPaths::locateAll(StandardLocation type, string fileName, LocateOptions options) |
94 | |
95 | \include standardpath/functiondocs.qdocinc locateAll |
96 | |
97 | \sa QStandardPaths::locateAll() |
98 | */ |
99 | QList<QUrl> QQuickLabsPlatformStandardPaths::locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options) |
100 | { |
101 | return toUrlList(paths: QStandardPaths::locateAll(type, fileName, options)); |
102 | } |
103 | |
104 | /*! |
105 | \qmlmethod void Qt.labs.platform::StandardPaths::setTestModeEnabled(bool testMode) |
106 | |
107 | \include standardpath/functiondocs.qdocinc setTestModeEnabled |
108 | |
109 | \sa QStandardPaths::setTestModeEnabled() |
110 | */ |
111 | void QQuickLabsPlatformStandardPaths::setTestModeEnabled(bool testMode) |
112 | { |
113 | QStandardPaths::setTestModeEnabled(testMode); |
114 | } |
115 | |
116 | /*! |
117 | \qmlmethod list<url> Qt.labs.platform::StandardPaths::standardLocations(StandardLocation type) |
118 | |
119 | \include standardpath/functiondocs.qdocinc standardLocations |
120 | |
121 | \sa QStandardPaths::standardLocations() |
122 | */ |
123 | QList<QUrl> QQuickLabsPlatformStandardPaths::standardLocations(QStandardPaths::StandardLocation type) |
124 | { |
125 | return toUrlList(paths: QStandardPaths::standardLocations(type)); |
126 | } |
127 | |
128 | /*! |
129 | \qmlmethod url Qt.labs.platform::StandardPaths::writableLocation(StandardLocation type) |
130 | |
131 | \include standardpath/functiondocs.qdocinc writableLocation |
132 | |
133 | \sa QStandardPaths::writableLocation() |
134 | */ |
135 | QUrl QQuickLabsPlatformStandardPaths::writableLocation(QStandardPaths::StandardLocation type) |
136 | { |
137 | return QUrl::fromLocalFile(localfile: QStandardPaths::writableLocation(type)); |
138 | } |
139 | |
140 | QT_END_NAMESPACE |
141 | |
142 | #include "moc_qquicklabsplatformstandardpaths_p.cpp" |
143 | |
144 | #endif // QT_DEPRECATED_SINCE(6, 4) |
145 | |