1 | // Copyright (C) 2021 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 "qqmlstandardpaths_p.h" |
5 | |
6 | #include <QtQml/qqmlengine.h> |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | /*! |
11 | \qmltype StandardPaths |
12 | \inherits QtObject |
13 | \inqmlmodule QtCore |
14 | \since 6.2 |
15 | \brief Provides access to the standard system paths. |
16 | |
17 | The StandardPaths singleton type provides methods for querying the standard |
18 | system paths. |
19 | |
20 | \qml |
21 | property url documentsFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) |
22 | \endqml |
23 | |
24 | \sa QStandardPaths |
25 | */ |
26 | |
27 | static QList<QUrl> toUrlList(const QStringList &paths) |
28 | { |
29 | QList<QUrl> urls; |
30 | urls.reserve(asize: paths.size()); |
31 | for (const QString &path : paths) |
32 | urls += QUrl::fromLocalFile(localfile: path); |
33 | return urls; |
34 | } |
35 | |
36 | QQmlStandardPaths::QQmlStandardPaths(QObject *parent) |
37 | : QObject(parent) |
38 | { |
39 | } |
40 | |
41 | /*! |
42 | \qmlmethod string QtCore::StandardPaths::displayName(StandardLocation type) |
43 | |
44 | \include standardpath/functiondocs.qdocinc displayName |
45 | |
46 | \sa QStandardPaths::displayName() |
47 | */ |
48 | QString QQmlStandardPaths::displayName(QStandardPaths::StandardLocation type) const |
49 | { |
50 | return QStandardPaths::displayName(type); |
51 | } |
52 | |
53 | /*! |
54 | \qmlmethod url QtCore::StandardPaths::findExecutable(string executableName, list<string> paths) const |
55 | |
56 | \include standardpath/functiondocs.qdocinc findExecutable |
57 | |
58 | \sa QStandardPaths::findExecutable() |
59 | */ |
60 | QUrl QQmlStandardPaths::findExecutable(const QString &executableName, const QStringList &paths) const |
61 | { |
62 | return QUrl::fromLocalFile(localfile: QStandardPaths::findExecutable(executableName, paths)); |
63 | } |
64 | |
65 | /*! |
66 | \qmlmethod url QtCore::StandardPaths::locate(StandardLocation type, string fileName, LocateOptions options) const |
67 | |
68 | \include standardpath/functiondocs.qdocinc locate |
69 | |
70 | \sa QStandardPaths::locate() |
71 | */ |
72 | QUrl QQmlStandardPaths::locate(QStandardPaths::StandardLocation type, const QString &fileName, |
73 | QStandardPaths::LocateOptions options) const |
74 | { |
75 | return QUrl::fromLocalFile(localfile: QStandardPaths::locate(type, fileName, options)); |
76 | } |
77 | |
78 | /*! |
79 | \qmlmethod list<url> QtCore::StandardPaths::locateAll(StandardLocation type, string fileName, LocateOptions options) const |
80 | |
81 | \include standardpath/functiondocs.qdocinc locateAll |
82 | |
83 | \sa QStandardPaths::locateAll() |
84 | */ |
85 | QList<QUrl> QQmlStandardPaths::locateAll(QStandardPaths::StandardLocation type, const QString &fileName, |
86 | QStandardPaths::LocateOptions options) const |
87 | { |
88 | return toUrlList(paths: QStandardPaths::locateAll(type, fileName, options)); |
89 | } |
90 | |
91 | /*! |
92 | \qmlmethod list<url> QtCore::StandardPaths::standardLocations(StandardLocation type) |
93 | |
94 | \include standardpath/functiondocs.qdocinc standardLocations |
95 | |
96 | \sa QStandardPaths::standardLocations() |
97 | */ |
98 | QList<QUrl> QQmlStandardPaths::standardLocations(QStandardPaths::StandardLocation type) const |
99 | { |
100 | return toUrlList(paths: QStandardPaths::standardLocations(type)); |
101 | } |
102 | |
103 | /*! |
104 | \qmlmethod url QtCore::StandardPaths::writableLocation(StandardLocation type) |
105 | |
106 | \include standardpath/functiondocs.qdocinc writableLocation |
107 | |
108 | \sa QStandardPaths::writableLocation() |
109 | */ |
110 | QUrl QQmlStandardPaths::writableLocation(QStandardPaths::StandardLocation type) const |
111 | { |
112 | return QUrl::fromLocalFile(localfile: QStandardPaths::writableLocation(type)); |
113 | } |
114 | |
115 | QT_END_NAMESPACE |
116 | |
117 | #include "moc_qqmlstandardpaths_p.cpp" |
118 | |