11use crate :: gui:: GuiSettingsContainer ;
2- use crate :: update:: { check_update, update} ;
2+ use crate :: update:: { check_update, restart_application , update} ;
33use eframe:: egui;
44use eframe:: egui:: { Align2 , InnerResponse , Vec2 , Visuals } ;
55use egui_theme_switch:: ThemeSwitch ;
@@ -11,6 +11,7 @@ pub fn settings_window(
1111 gui_conf : & mut GuiSettingsContainer ,
1212 new_release : & mut Option < Release > ,
1313 settings_window_open : & mut bool ,
14+ update_text : & mut String ,
1415) -> Option < InnerResponse < Option < ( ) > > > {
1516 egui:: Window :: new ( "Settings" )
1617 . fixed_size ( Vec2 { x : 600.0 , y : 200.0 } )
@@ -44,6 +45,7 @@ pub fn settings_window(
4445 if ui. button ( "Update" ) . clicked ( ) {
4546 if let Ok ( ( ) ) = update ( r. clone ( ) ) {
4647 * new_release = None ;
48+ * update_text = "Update done. Please Restart Application." . to_string ( ) ;
4749 }
4850 }
4951 } else {
@@ -55,10 +57,19 @@ pub fn settings_window(
5557 } ) ;
5658 ui. label ( "No new update" ) ;
5759 }
60+ } ) ;
61+ ui. label ( update_text. clone ( ) ) ;
5862
59- ui. end_row ( ) ;
63+ ui. horizontal ( |ui| {
6064 if ui. button ( "Exit Settings" ) . clicked ( ) {
6165 * settings_window_open = false ;
66+ * update_text = "" . to_string ( ) ;
67+ }
68+
69+ if !update_text. is_empty ( ) && ui. button ( "Restart" ) . clicked ( ) {
70+ let _ = restart_application ( ) ;
71+ ctx. request_repaint ( ) ; // Optional: Request repaint for immediate feedback
72+ ui. ctx ( ) . send_viewport_cmd ( egui:: ViewportCommand :: Close ) ;
6273 }
6374 } ) ;
6475 } )
0 commit comments