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