4
4
// SPDX-License-Identifier: MIT OR Apache-2.0
5
5
6
6
use core:: pin:: Pin ;
7
- use cxx_qt_lib:: { QByteArray , QFont , QString , QStringList , QVector } ;
7
+ use cxx_qt:: Upcast ;
8
+ use cxx_qt_lib:: { QByteArray , QFont , QGuiApplication , QString , QStringList , QVector } ;
9
+ use std:: ops:: Deref ;
8
10
9
11
#[ cxx:: bridge]
10
12
mod ffi {
@@ -18,12 +20,28 @@ mod ffi {
18
20
include ! ( "cxx-qt-lib/qvector.h" ) ;
19
21
type QVector_QByteArray = cxx_qt_lib:: QVector < QByteArray > ;
20
22
include ! ( "cxx-qt-lib/qfont.h" ) ;
23
+
21
24
type QFont = cxx_qt_lib:: QFont ;
25
+ include ! ( "cxx-qt-lib/qguiapplication.h" ) ;
26
+ type QGuiApplication = cxx_qt_lib:: QGuiApplication ;
22
27
23
28
include ! ( "cxx-qt-lib-extras/qapplication.h" ) ;
24
29
type QApplication ;
25
30
}
26
31
32
+ #[ namespace = "rust::cxxqt1" ]
33
+ unsafe extern "C++" {
34
+ include ! ( "cxx-qt/casting.h" ) ;
35
+
36
+ #[ doc( hidden) ]
37
+ #[ rust_name = "upcast_qapplication" ]
38
+ unsafe fn upcastPtr ( thiz : * const QApplication ) -> * const QGuiApplication ;
39
+
40
+ #[ doc( hidden) ]
41
+ #[ rust_name = "downcast_qapplication" ]
42
+ unsafe fn downcastPtr ( base : * const QGuiApplication ) -> * const QApplication ;
43
+ }
44
+
27
45
#[ namespace = "rust::cxxqtlib1" ]
28
46
unsafe extern "C++" {
29
47
#[ doc( hidden) ]
@@ -93,6 +111,24 @@ mod ffi {
93
111
94
112
pub use ffi:: QApplication ;
95
113
114
+ impl Upcast < QGuiApplication > for QApplication {
115
+ unsafe fn upcast_ptr ( this : * const Self ) -> * const QGuiApplication {
116
+ ffi:: upcast_qapplication ( this)
117
+ }
118
+
119
+ unsafe fn from_base_ptr ( base : * const QGuiApplication ) -> * const Self {
120
+ ffi:: downcast_qapplication ( base)
121
+ }
122
+ }
123
+
124
+ impl Deref for QApplication {
125
+ type Target = QGuiApplication ;
126
+
127
+ fn deref ( & self ) -> & Self :: Target {
128
+ self . upcast ( )
129
+ }
130
+ }
131
+
96
132
impl QApplication {
97
133
/// Prepends path to the beginning of the library path list,
98
134
/// ensuring that it is searched for libraries first.
0 commit comments