@@ -9,6 +9,8 @@ pub struct MenuBarOwn {
99 menu_item_clicked : State < bool > ,
1010 current_menu : State < String > ,
1111 open_file_state : State < Option < FileOwn > > ,
12+ save_requested : State < bool > ,
13+ exit_requested : State < bool > ,
1214 show_about : State < bool > ,
1315 show_licenses : State < bool > ,
1416 submenu_file_position : Position ,
@@ -18,6 +20,8 @@ pub struct MenuBarOwn {
1820impl MenuBarOwn {
1921 pub fn new (
2022 open_file_state : State < Option < FileOwn > > ,
23+ save_requested : State < bool > ,
24+ exit_requested : State < bool > ,
2125 show_about : State < bool > ,
2226 show_licenses : State < bool > ,
2327 background : Option < String >
@@ -29,6 +33,8 @@ impl MenuBarOwn {
2933 menu_item_clicked : use_state ( || false ) ,
3034 current_menu : use_state ( || String :: new ( ) ) ,
3135 open_file_state,
36+ save_requested,
37+ exit_requested,
3238 show_about,
3339 show_licenses,
3440 submenu_file_position : Position :: new_absolute ( )
@@ -105,6 +111,8 @@ impl MenuBarOwn {
105111
106112 fn submenu_file ( & self , submenu_file_position : Position ) -> impl IntoElement {
107113 let mut open_file_state = self . open_file_state . clone ( ) ;
114+ let mut save_requested = self . save_requested . clone ( ) ;
115+ let mut exit_requested = self . exit_requested . clone ( ) ;
108116 let menu_item_clicked = self . menu_item_clicked . clone ( ) ;
109117 let current_menu = self . current_menu . clone ( ) ;
110118
@@ -114,14 +122,15 @@ impl MenuBarOwn {
114122 Menu :: new ( )
115123 . child (
116124 MenuButton :: new ( )
117- . child ( "Save" )
125+ . child ( "Save Ctrl+S " )
118126 . on_press ( move |_| {
127+ * save_requested. write ( ) = true ;
119128 close_menu ( menu_item_clicked. clone ( ) , current_menu. clone ( ) ) ;
120129 } )
121130 )
122131 . child (
123132 MenuButton :: new ( )
124- . child ( "Open" )
133+ . child ( "Open Ctrl+O " )
125134 . on_press ( move |_| {
126135 if let Some ( file) = open_file ( ) {
127136 * open_file_state. write ( ) = Some ( file) ;
@@ -131,8 +140,9 @@ impl MenuBarOwn {
131140 )
132141 . child (
133142 MenuButton :: new ( )
134- . child ( "Exit" )
143+ . child ( "Exit Ctrl+Q " )
135144 . on_press ( move |_| {
145+ * exit_requested. write ( ) = true ;
136146 close_menu ( menu_item_clicked. clone ( ) , current_menu. clone ( ) ) ;
137147 } )
138148 )
@@ -154,15 +164,15 @@ impl MenuBarOwn {
154164 Menu :: new ( )
155165 . child (
156166 MenuButton :: new ( )
157- . child ( "About" )
167+ . child ( "About Ctrl+I " )
158168 . on_press ( move |_| {
159169 show_about. toggle ( ) ;
160170 close_menu ( menu_item_clicked. clone ( ) , current_menu. clone ( ) ) ;
161171 } )
162172 )
163173 . child (
164174 MenuButton :: new ( )
165- . child ( "Licenses" )
175+ . child ( "Licenses Ctrl+L " )
166176 . on_press ( move |_| {
167177 show_licenses. toggle ( ) ;
168178 close_menu ( menu_item_clicked. clone ( ) , current_menu. clone ( ) ) ;
@@ -208,19 +218,16 @@ fn close_menu(mut menu_item_clicked: State<bool>, mut current_menu: State<String
208218 * current_menu. write ( ) = String :: new ( ) ;
209219}
210220
211- fn open_file ( ) -> Option < FileOwn > {
221+ pub ( crate ) fn open_file ( ) -> Option < FileOwn > {
212222 let filters = vec ! [
213223 Filter :: new( "Excel" , & [ "xlsx" ] ) ,
214224 Filter :: new( "Word" , & [ "docx" ] ) ,
215225 Filter :: new( "PowerPoint" , & [ "pptx" ] ) ,
216226 Filter :: new( "PDF" , & [ "pdf" ] ) ,
217- Filter :: new( "Images" , & [ "png" , "jpg" , "jpeg" , "gif" , "webp" , "svg" , "bmp" ] ) ,
218- Filter :: new( "Audio" , & [ "mp3" , "wav" , "flac" , "ogg" , "m4a" , "aac" ] ) ,
219227 Filter :: new( "HTML" , & [ "html" , "htm" ] ) ,
220228 Filter :: new( "CSV (UTF-8)" , & [ "csv" ] ) ,
221229 Filter :: new( "Text-based formats" , & [ "xml" , "rss" , "atom" , "txt" ] ) ,
222- Filter :: new( "ZIP" , & [ "zip" ] ) ,
223- Filter :: new( "Markdown" , & [ "md" , "markdown" ] )
230+ Filter :: new( "ZIP" , & [ "zip" ] )
224231 ] ;
225232
226233 FileOwn :: open_file_dialog ( filters)
0 commit comments