1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
// SPDX-FileContributor: Andrew Hayzen <andrew.hayzen@kdab.com>
//
// SPDX-License-Identifier: MIT OR Apache-2.0
#[cxx_qt::bridge]
mod ffi {
unsafe extern "C++" {
include!("cxx-qt-lib/qbytearray.h");
type QByteArray = crate::QByteArray;
include!("cxx-qt-lib/qmap.h");
type QMap_QString_QVariant = crate::QMap<crate::QMapPair_QString_QVariant>;
include!("cxx-qt-lib/qstring.h");
type QString = crate::QString;
include!("cxx-qt-lib/qstringlist.h");
type QStringList = crate::QStringList;
include!("cxx-qt-lib/qurl.h");
type QUrl = crate::QUrl;
/// Adds `path` as a directory where the engine searches for installed modules in a URL-based directory structure.
#[rust_name = "add_import_path"]
fn addImportPath(self: Pin<&mut QQmlApplicationEngine>, path: &QString);
/// Adds `path` as a directory where the engine searches for native plugins for imported modules (referenced in the `qmldir` file).
#[rust_name = "add_plugin_path"]
fn addPluginPath(self: Pin<&mut QQmlApplicationEngine>, path: &QString);
/// Return the base URL for this engine.
/// The base URL is only used to resolve components when a relative URL is passed to the [QQmlComponent](https://doc.qt.io/qt/qqmlcomponent.html) constructor.
#[rust_name = "base_url"]
fn baseUrl(self: &QQmlApplicationEngine) -> QUrl;
/// Returns the list of directories where the engine searches for installed modules in a URL-based directory structure.
#[rust_name = "import_path_list"]
fn importPathList(self: &QQmlApplicationEngine) -> QStringList;
/// Loads the root QML file located at `url`.
fn load(self: Pin<&mut QQmlApplicationEngine>, url: &QUrl);
/// Loads the QML given in data. The object tree defined by data is instantiated immediately.
#[rust_name = "load_data"]
fn loadData(self: Pin<&mut QQmlApplicationEngine>, data: &QByteArray, url: &QUrl);
/// Returns the directory for storing offline user data.
#[rust_name = "offline_storage_path"]
fn offlineStoragePath(self: &QQmlApplicationEngine) -> QString;
/// Returns the list of directories where the engine searches for native plugins for imported modules (referenced in the `qmldir` file).
#[rust_name = "plugin_path_list"]
fn pluginPathList(self: &QQmlApplicationEngine) -> QStringList;
/// Set the base URL for this engine to `url`.
#[rust_name = "set_base_url"]
fn setBaseUrl(self: Pin<&mut QQmlApplicationEngine>, url: &QUrl);
/// Sets `paths` as the list of directories where the engine searches for installed modules in a URL-based directory structure.
#[rust_name = "set_import_path_list"]
fn setImportPathList(self: Pin<&mut QQmlApplicationEngine>, paths: &QStringList);
/// Sets the initialProperties with which the QML component gets initialized after it gets loaded.
#[rust_name = "set_initial_properties"]
fn setInitialProperties(
self: Pin<&mut QQmlApplicationEngine>,
properties: &QMap_QString_QVariant,
);
/// Sets the list of directories where the engine searches for native plugins for imported modules (referenced in the `qmldir` file) to `paths`.
#[rust_name = "set_plugin_path_list"]
fn setPluginPathList(self: Pin<&mut QQmlApplicationEngine>, paths: &QStringList);
/// Sets `path` as string for storing offline user data.
#[rust_name = "set_offline_storage_path"]
fn setOfflineStoragePath(self: Pin<&mut QQmlApplicationEngine>, dir: &QString);
}
unsafe extern "C++Qt" {
include!("cxx-qt-lib/qqmlapplicationengine.h");
/// `QQmlApplicationEngine` provides a convenient way to load an application from a single QML file.
///
/// Qt Documentation: [QQmlApplicationEngine](https://doc.qt.io/qt/qqmlapplicationengine.html#details)
#[qobject]
#[base = QQmlEngine]
type QQmlApplicationEngine;
}
unsafe extern "C++Qt" {
/// This signal is emitted when an object finishes loading. If loading was successful, `object` contains a pointer to the loaded object, otherwise the pointer is null.
///
/// The `url` to the component the `object` came from is also provided.
///
/// Note: If the path to the component was provided as a [`QString`](crate::QString) containing a relative path, the `url` will contain a fully resolved path to the file.
#[qsignal]
#[rust_name = "object_created"]
unsafe fn objectCreated(
self: Pin<&mut QQmlApplicationEngine>,
qobject: *mut QObject,
url: &QUrl,
);
/// This signal is emitted when loading finishes because an error occurred.
///
/// The `url` to the component that failed to load is provided as an argument.
///
/// **Note:** If the path to the component was provided as a [`QString`](crate::QString) containing a relative path, the `url` will contain a fully resolved path to the file.
///
/// This function was introduced in Qt 6.4.
#[qsignal]
#[rust_name = "object_creation_failed"]
#[cfg(any(cxxqt_qt_version_at_least_7, cxxqt_qt_version_at_least_6_4))]
fn objectCreationFailed(self: Pin<&mut QQmlApplicationEngine>, url: &QUrl);
}
unsafe extern "C++" {
include!("cxx-qt-lib/qqmlengine.h");
type QQmlEngine = crate::QQmlEngine;
}
#[namespace = "rust::cxxqtlib1"]
unsafe extern "C++" {
#[doc(hidden)]
#[rust_name = "qqmlapplicationengine_new"]
fn qqmlapplicationengineNew() -> UniquePtr<QQmlApplicationEngine>;
}
// QQmlApplicationEngine is not a trivial to CXX and is not relocatable in Qt
// as the following fails in C++. So we cannot mark it as a trivial type
// and need to use references or pointers.
// static_assert(QTypeInfo<QQmlApplicationEngine>::isRelocatable);
impl UniquePtr<QQmlApplicationEngine> {}
}
pub use ffi::QQmlApplicationEngine;
impl QQmlApplicationEngine {
/// Create a new `QQmlApplicationEngine`.
///
/// You will have to call [load](https://doc.qt.io/qt/qqmlapplicationengine.html#load)() later in order to load a QML file.
pub fn new() -> cxx::UniquePtr<Self> {
ffi::qqmlapplicationengine_new()
}
}