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