From f1198950e9e26ccb63cced1e0b5d3978b4443a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Fri, 21 May 2021 12:33:30 +0300 Subject: [PATCH] GUI: add back to dialog module results. Power: exit from reboot view. (#477) Co-authored-by: SG --- applications/gui/modules/dialog.c | 3 +++ applications/gui/modules/dialog.h | 1 + applications/power/power.c | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/applications/gui/modules/dialog.c b/applications/gui/modules/dialog.c index b7469648..af649086 100644 --- a/applications/gui/modules/dialog.c +++ b/applications/gui/modules/dialog.c @@ -50,6 +50,9 @@ static bool dialog_view_input_callback(InputEvent* event, void* context) { } else if(event->key == InputKeyRight) { dialog->callback(DialogResultRight, dialog->context); consumed = true; + } else if(event->key == InputKeyBack) { + dialog->callback(DialogResultBack, dialog->context); + consumed = true; } } diff --git a/applications/gui/modules/dialog.h b/applications/gui/modules/dialog.h index 325d4b37..5fae73fe 100644 --- a/applications/gui/modules/dialog.h +++ b/applications/gui/modules/dialog.h @@ -12,6 +12,7 @@ typedef struct Dialog Dialog; typedef enum { DialogResultLeft, DialogResultRight, + DialogResultBack, } DialogResult; /* Dialog result callback type diff --git a/applications/power/power.c b/applications/power/power.c index eedeee1b..744f8176 100644 --- a/applications/power/power.c +++ b/applications/power/power.c @@ -60,13 +60,15 @@ void power_menu_reset_dialog_result(DialogResult result, void* context) { power_reset(power, PowerBootModeDfu); } else if(result == DialogResultRight) { power_reset(power, PowerBootModeNormal); + } else if(result == DialogResultBack) { + view_dispatcher_switch_to_view(power->view_dispatcher, VIEW_NONE); } } void power_menu_reset_callback(void* context) { Power* power = context; dialog_set_result_callback(power->dialog, power_menu_reset_dialog_result); - dialog_set_header_text(power->dialog, "Reset type"); + dialog_set_header_text(power->dialog, "Reboot type"); dialog_set_text(power->dialog, "Reboot where?"); dialog_set_left_button_text(power->dialog, "DFU"); dialog_set_right_button_text(power->dialog, "OS"); @@ -98,7 +100,7 @@ Power* power_alloc() { menu_item_subitem_add( power->menu, menu_item_alloc_function("Off", NULL, power_menu_off_callback, power)); menu_item_subitem_add( - power->menu, menu_item_alloc_function("Reset", NULL, power_menu_reset_callback, power)); + power->menu, menu_item_alloc_function("Reboot", NULL, power_menu_reset_callback, power)); menu_item_subitem_add( power->menu, menu_item_alloc_function("Enable OTG", NULL, power_menu_enable_otg_callback, power));