@@ -38,6 +38,7 @@ pub enum DeviceMenuOptions {
3838 Trust ,
3939 RevokeTrust ,
4040 Forget ,
41+ Back ,
4142}
4243
4344impl DeviceMenuOptions {
@@ -52,6 +53,7 @@ impl DeviceMenuOptions {
5253 Some ( DeviceMenuOptions :: RevokeTrust )
5354 }
5455 s if s == t ! ( "menus.device.options.forget.name" ) => Some ( DeviceMenuOptions :: Forget ) ,
56+ s if s == t ! ( "menus.common.back" ) => Some ( DeviceMenuOptions :: Back ) ,
5557 _ => None ,
5658 }
5759 }
@@ -63,6 +65,7 @@ impl DeviceMenuOptions {
6365 DeviceMenuOptions :: Trust => t ! ( "menus.device.options.trust.name" ) ,
6466 DeviceMenuOptions :: RevokeTrust => t ! ( "menus.device.options.revoke_trust.name" ) ,
6567 DeviceMenuOptions :: Forget => t ! ( "menus.device.options.forget.name" ) ,
68+ DeviceMenuOptions :: Back => t ! ( "menus.common.back" ) ,
6669 }
6770 }
6871}
@@ -72,6 +75,7 @@ pub enum SettingsMenuOptions {
7275 ToggleDiscoverable ,
7376 TogglePairable ,
7477 DisableAdapter ,
78+ Back ,
7579}
7680
7781impl SettingsMenuOptions {
@@ -86,6 +90,7 @@ impl SettingsMenuOptions {
8690 s if s == t ! ( "menus.settings.options.disable_adapter.name" ) => {
8791 Some ( SettingsMenuOptions :: DisableAdapter )
8892 }
93+ s if s == t ! ( "menus.common.back" ) => Some ( SettingsMenuOptions :: Back ) ,
8994 _ => None ,
9095 }
9196 }
@@ -101,6 +106,7 @@ impl SettingsMenuOptions {
101106 SettingsMenuOptions :: DisableAdapter => {
102107 t ! ( "menus.settings.options.disable_adapter.name" )
103108 }
109+ SettingsMenuOptions :: Back => t ! ( "menus.common.back" ) ,
104110 }
105111 }
106112}
@@ -321,6 +327,7 @@ impl Menu {
321327 spaces : usize ,
322328 available_options : Vec < DeviceMenuOptions > ,
323329 device_name : & str ,
330+ back_on_escape : bool ,
324331 ) -> Result < Option < DeviceMenuOptions > > {
325332 let mut input = String :: new ( ) ;
326333
@@ -331,13 +338,20 @@ impl Menu {
331338 DeviceMenuOptions :: Trust => "trust" ,
332339 DeviceMenuOptions :: RevokeTrust => "revoke_trust" ,
333340 DeviceMenuOptions :: Forget => "forget" ,
341+ DeviceMenuOptions :: Back => "back" ,
334342 } ;
335343
336344 let option_text =
337345 self . get_icon_text ( vec ! [ ( icon_key, option. to_str( ) ) ] , icon_type, spaces) ;
338346 input. push_str ( & format ! ( "{option_text}\n " ) ) ;
339347 }
340348
349+ if !back_on_escape {
350+ let back_text =
351+ self . get_icon_text ( vec ! [ ( "back" , t!( "menus.common.back" ) ) ] , icon_type, spaces) ;
352+ input. push_str ( & format ! ( "{back_text}\n " ) ) ;
353+ }
354+
341355 let hint = t ! ( "menus.device.hint" , device_name = device_name) ;
342356
343357 let menu_output =
@@ -377,6 +391,7 @@ impl Menu {
377391 controller : & Controller ,
378392 icon_type : & str ,
379393 spaces : usize ,
394+ back_on_escape : bool ,
380395 ) -> Result < Option < SettingsMenuOptions > > {
381396 let ( discoverable_text, discoverable_icon) = if controller. is_discoverable {
382397 (
@@ -403,13 +418,18 @@ impl Menu {
403418 } ;
404419
405420 let disable_adapter_text = t ! ( "menus.settings.options.disable_adapter.name" ) ;
421+ let back_text = t ! ( "menus.common.back" ) ;
406422
407- let options = vec ! [
423+ let mut options = vec ! [
408424 ( discoverable_icon, discoverable_text. as_ref( ) ) ,
409425 ( pairable_icon, pairable_text. as_ref( ) ) ,
410426 ( "disable_adapter" , disable_adapter_text. as_ref( ) ) ,
411427 ] ;
412428
429+ if !back_on_escape {
430+ options. push ( ( "back" , back_text. as_ref ( ) ) ) ;
431+ }
432+
413433 let input = self . get_icon_text ( options, icon_type, spaces) ;
414434
415435 let menu_output = self . run_launcher ( launcher_command, Some ( & input) , icon_type, None ) ?;
@@ -423,6 +443,8 @@ impl Menu {
423443 return Ok ( Some ( SettingsMenuOptions :: TogglePairable ) ) ;
424444 } else if cleaned_output == disable_adapter_text. as_ref ( ) {
425445 return Ok ( Some ( SettingsMenuOptions :: DisableAdapter ) ) ;
446+ } else if cleaned_output == back_text. as_ref ( ) {
447+ return Ok ( Some ( SettingsMenuOptions :: Back ) ) ;
426448 }
427449 }
428450
0 commit comments