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