forked from KDAB/cxx-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqqmlapplicationengine.rs
104 lines (83 loc) · 4.36 KB
/
qqmlapplicationengine.rs
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
// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
// SPDX-FileContributor: Andrew Hayzen <[email protected]>
//
// SPDX-License-Identifier: MIT OR Apache-2.0
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
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;
include!("cxx-qt-lib/qqmlapplicationengine.h");
type QQmlApplicationEngine;
/// 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 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);
/// This property holds 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 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++" {
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>;
#[doc(hidden)]
#[rust_name = "qqmlapplicationengine_as_qqmlengine"]
fn qqmlapplicationengineAsQQmlEngine(
ptr: Pin<&mut QQmlApplicationEngine>,
) -> Pin<&mut QQmlEngine>;
}
// 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> {}
}
use crate::QQmlEngine;
use core::pin::Pin;
pub use ffi::QQmlApplicationEngine;
impl QQmlApplicationEngine {
/// Convert the existing [QQmlApplicationEngine] to a [QQmlEngine]
pub fn as_qqmlengine<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut QQmlEngine> {
ffi::qqmlapplicationengine_as_qqmlengine(self)
}
/// Create a new QQmlApplicationEngine
pub fn new() -> cxx::UniquePtr<Self> {
ffi::qqmlapplicationengine_new()
}
}