File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,6 @@ Window {
2626
2727 EnergyUsage {
2828 id: energyUsage
29-
30- // FIXME: have the ability to HandleInit so we can start the server
31- // https://github.com/KDAB/cxx-qt/issues/13
32- Component .onCompleted : startServer ()
3329 }
3430
3531 Image {
Original file line number Diff line number Diff line change @@ -80,11 +80,9 @@ mod ffi {
8080 /// A Q_INVOKABLE that returns the current power usage for a given uuid
8181 #[ qinvokable]
8282 fn sensor_power ( self : Pin < & mut qobject:: EnergyUsage > , uuid : & QString ) -> f64 ;
83-
84- /// A Q_INVOKABLE which starts the TCP server
85- #[ qinvokable]
86- fn start_server ( self : Pin < & mut qobject:: EnergyUsage > ) ;
8783 }
84+
85+ impl cxx_qt:: Constructor < ( ) > for qobject:: EnergyUsage { }
8886}
8987
9088use crate :: {
@@ -113,9 +111,29 @@ impl ffi::EnergyUsageQt {
113111 0.0
114112 }
115113 }
114+ }
115+
116+ impl cxx_qt:: Constructor < ( ) > for qobject:: EnergyUsage {
117+ type NewArguments = ( ) ;
118+ type BaseArguments = ( ) ;
119+ type InitializeArguments = ( ) ;
120+
121+ fn route_arguments (
122+ _args : ( ) ,
123+ ) -> (
124+ Self :: NewArguments ,
125+ Self :: BaseArguments ,
126+ Self :: InitializeArguments ,
127+ ) {
128+ ( ( ) , ( ) , ( ) )
129+ }
130+
131+ fn new ( ( ) : ( ) ) -> EnergyUsage {
132+ EnergyUsage :: default ( )
133+ }
116134
117135 /// A Q_INVOKABLE which starts the TCP server
118- fn start_server ( mut self : Pin < & mut Self > ) {
136+ fn initialize ( mut self : core :: pin :: Pin < & mut Self > , _arguments : Self :: InitializeArguments ) {
119137 if self . rust ( ) . join_handles . is_some ( ) {
120138 println ! ( "Already running a server!" ) ;
121139 return ;
You can’t perform that action at this time.
0 commit comments