@@ -49,8 +49,8 @@ impl SystemTray {
4949 let system_tray: system_tray_ui:: SystemTrayUi =
5050 SystemTray :: build_ui ( SystemTray :: default ( ) ) . expect ( "Failed to build UI" ) ;
5151
52- system_tray . first_time_init ( ) ;
53- system_tray . auto_update ( ) ;
52+ Self :: first_time_init ( ) ;
53+ Self :: auto_update ( ) ;
5454
5555 nwg:: dispatch_thread_events ( ) ;
5656
@@ -66,21 +66,21 @@ impl SystemTray {
6666 }
6767
6868 fn show_window ( & self ) {
69- if self . set_foreground_window ( ) {
69+ if Self :: set_foreground_window ( ) {
7070 return ;
7171 }
7272
7373 let basic_app = BasicApp :: build ( ) ;
7474
7575 unsafe { * WINDOW_HANDLE . lock ( ) . unwrap ( ) = Some ( basic_app. window ( ) . handle . hwnd ( ) . unwrap ( ) ) } ;
7676
77- self . set_foreground_window ( ) ;
77+ Self :: set_foreground_window ( ) ;
7878
7979 nwg:: dispatch_thread_events ( ) ;
8080 }
8181
8282 fn toggle_startup ( & self ) {
83- let Ok ( auto_launch) = self . get_auto_launch ( ) else {
83+ let Ok ( auto_launch) = Self :: get_auto_launch ( ) else {
8484 return ;
8585 } ;
8686
@@ -92,18 +92,18 @@ impl SystemTray {
9292 }
9393
9494 fn toggle_update ( & self ) {
95- let Ok ( ( key, _) ) = self . get_reg_key ( ) else {
95+ let Ok ( ( key, _) ) = Self :: get_reg_key ( ) else {
9696 return ;
9797 } ;
9898
9999 let _: Result < ( ) , std:: io:: Error > =
100100 key. set_value ( "AutoUpdate" , & ( !self . tray_item_update . checked ( ) as u32 ) ) ;
101101
102- self . auto_update ( ) ;
102+ Self :: auto_update ( ) ;
103103 }
104104
105105 fn refresh_startup ( & self ) {
106- let Ok ( auto_launch) = self . get_auto_launch ( ) else {
106+ let Ok ( auto_launch) = Self :: get_auto_launch ( ) else {
107107 return ;
108108 } ;
109109
@@ -113,7 +113,7 @@ impl SystemTray {
113113 }
114114
115115 fn refresh_update ( & self ) {
116- let Ok ( ( key, _) ) = self . get_reg_key ( ) else {
116+ let Ok ( ( key, _) ) = Self :: get_reg_key ( ) else {
117117 return ;
118118 } ;
119119
@@ -122,7 +122,7 @@ impl SystemTray {
122122 }
123123 }
124124
125- fn get_auto_launch ( & self ) -> Result < al:: AutoLaunch , ( ) > {
125+ fn get_auto_launch ( ) -> Result < al:: AutoLaunch , ( ) > {
126126 let Ok ( exe_path) = std:: env:: current_exe ( ) else {
127127 return Err ( ( ) ) ;
128128 } ;
@@ -134,23 +134,21 @@ impl SystemTray {
134134 . unwrap ( ) )
135135 }
136136
137- fn get_reg_key (
138- & self ,
139- ) -> Result < ( winreg:: RegKey , winreg:: enums:: RegDisposition ) , std:: io:: Error > {
137+ fn get_reg_key ( ) -> Result < ( winreg:: RegKey , winreg:: enums:: RegDisposition ) , std:: io:: Error > {
140138 winreg:: RegKey :: predef ( winreg:: enums:: HKEY_CURRENT_USER )
141139 . create_subkey ( std:: path:: Path :: new ( "SOFTWARE" ) . join ( APP_NAME ) )
142140 }
143141
144- fn set_foreground_window ( & self ) -> bool {
142+ fn set_foreground_window ( ) -> bool {
145143 if let Some ( hwnd) = unsafe { * WINDOW_HANDLE . lock ( ) . unwrap ( ) } {
146144 unsafe { winapi:: um:: winuser:: SetForegroundWindow ( hwnd) } ;
147145 return true ;
148146 }
149147 false
150148 }
151149
152- fn first_time_init ( & self ) {
153- let Ok ( ( key, _) ) = self . get_reg_key ( ) else {
150+ fn first_time_init ( ) {
151+ let Ok ( ( key, _) ) = Self :: get_reg_key ( ) else {
154152 return ;
155153 } ;
156154
@@ -172,15 +170,15 @@ impl SystemTray {
172170 return ;
173171 }
174172
175- if let Ok ( auto_launch) = self . get_auto_launch ( ) {
173+ if let Ok ( auto_launch) = Self :: get_auto_launch ( ) {
176174 let _: Result < ( ) , al:: Error > = auto_launch. enable ( ) ;
177175 }
178176
179177 let _: Result < ( ) , std:: io:: Error > = key. set_value ( "AutoUpdate" , & ( true as u32 ) ) ;
180178 }
181179
182- fn auto_update ( & self ) {
183- let Ok ( ( key, _) ) = self . get_reg_key ( ) else {
180+ fn auto_update ( ) {
181+ let Ok ( ( key, _) ) = Self :: get_reg_key ( ) else {
184182 return ;
185183 } ;
186184
@@ -189,22 +187,21 @@ impl SystemTray {
189187 } ;
190188
191189 if auto_update > 0 {
192- let _: Result < ( ) , Box < su:: errors:: Error > > = self . update ( ) ;
190+ let _: Result < ( ) , Box < su:: errors:: Error > > = Self :: update ( ) ;
193191 }
194192 }
195193
196- fn update ( & self ) -> Result < ( ) , Box < su:: errors:: Error > > {
197- let status : su :: Status = su:: backends:: github:: Update :: configure ( )
194+ fn update ( ) -> Result < ( ) , Box < su:: errors:: Error > > {
195+ su:: backends:: github:: Update :: configure ( )
198196 . repo_owner ( "jqntn" )
199197 . repo_name ( APP_NAME )
200198 . bin_name ( APP_NAME )
201- . show_download_progress ( true )
199+ . target ( "zip" )
202200 . current_version ( su:: cargo_crate_version!( ) )
201+ . show_download_progress ( true )
202+ . no_confirm ( true )
203203 . build ( ) ?
204204 . update ( ) ?;
205-
206- println ! ( "Update status: `{}`!" , status. version( ) ) ;
207-
208205 Ok ( ( ) )
209206 }
210207
0 commit comments