mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-01 22:08:55 -07:00
Add option to reset desktop keybinds
This commit is contained in:
@@ -58,6 +58,7 @@ DesktopSettingsApp* desktop_settings_app_alloc() {
|
||||
|
||||
app->popup = popup_alloc();
|
||||
app->submenu = submenu_alloc();
|
||||
app->dialog_ex = dialog_ex_alloc();
|
||||
app->variable_item_list = variable_item_list_alloc();
|
||||
app->pin_input_view = desktop_view_pin_input_alloc();
|
||||
app->pin_setup_howto_view = desktop_settings_view_pin_setup_howto_alloc();
|
||||
@@ -71,6 +72,8 @@ DesktopSettingsApp* desktop_settings_app_alloc() {
|
||||
variable_item_list_get_view(app->variable_item_list));
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, DesktopSettingsAppViewIdPopup, popup_get_view(app->popup));
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, DesktopSettingsAppViewDialogEx, dialog_ex_get_view(app->dialog_ex));
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
DesktopSettingsAppViewIdPinInput,
|
||||
@@ -92,10 +95,12 @@ void desktop_settings_app_free(DesktopSettingsApp* app) {
|
||||
view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewVarItemList);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewIdPopup);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewDialogEx);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewIdPinInput);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewIdPinSetupHowto);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, DesktopSettingsAppViewIdPinSetupHowto2);
|
||||
variable_item_list_free(app->variable_item_list);
|
||||
dialog_ex_free(app->dialog_ex);
|
||||
submenu_free(app->submenu);
|
||||
popup_free(app->popup);
|
||||
desktop_view_pin_input_free(app->pin_input_view);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <assets_icons.h>
|
||||
@@ -18,6 +19,7 @@ typedef enum {
|
||||
DesktopSettingsAppViewMenu,
|
||||
DesktopSettingsAppViewVarItemList,
|
||||
DesktopSettingsAppViewIdPopup,
|
||||
DesktopSettingsAppViewDialogEx,
|
||||
DesktopSettingsAppViewIdPinInput,
|
||||
DesktopSettingsAppViewIdPinSetupHowto,
|
||||
DesktopSettingsAppViewIdPinSetupHowto2,
|
||||
@@ -42,6 +44,7 @@ typedef struct {
|
||||
VariableItemList* variable_item_list;
|
||||
Submenu* submenu;
|
||||
Popup* popup;
|
||||
DialogEx* dialog_ex;
|
||||
DesktopViewPinInput* pin_input_view;
|
||||
DesktopSettingsViewPinSetupHowto* pin_setup_howto_view;
|
||||
DesktopSettingsViewPinSetupHowto2* pin_setup_howto2_view;
|
||||
|
||||
@@ -3,6 +3,7 @@ ADD_SCENE(desktop_settings, keybinds_type, KeybindsType)
|
||||
ADD_SCENE(desktop_settings, keybinds_key, KeybindsKey)
|
||||
ADD_SCENE(desktop_settings, keybinds_action_type, KeybindsActionType)
|
||||
ADD_SCENE(desktop_settings, keybinds_action, KeybindsAction)
|
||||
ADD_SCENE(desktop_settings, keybinds_reset, KeybindsReset)
|
||||
ADD_SCENE(desktop_settings, pin_menu, PinMenu)
|
||||
|
||||
ADD_SCENE(desktop_settings, pin_auth, PinAuth)
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "../desktop_settings_app.h"
|
||||
// #include <storage/storage.h>
|
||||
|
||||
static void
|
||||
desktop_settings_scene_keybinds_reset_dialog_callback(DialogExResult result, void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
|
||||
void desktop_settings_scene_keybinds_reset_on_enter(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_set_header(dialog_ex, "Reset Desktop Keybinds?", 64, 10, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_text(dialog_ex, "Your edits will be lost!", 64, 32, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
|
||||
dialog_ex_set_right_button_text(dialog_ex, "Reset");
|
||||
|
||||
dialog_ex_set_context(dialog_ex, app);
|
||||
dialog_ex_set_result_callback(
|
||||
dialog_ex, desktop_settings_scene_keybinds_reset_dialog_callback);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewDialogEx);
|
||||
}
|
||||
|
||||
bool desktop_settings_scene_keybinds_reset_on_event(void* context, SceneManagerEvent event) {
|
||||
DesktopSettingsApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case DialogExResultRight:
|
||||
storage_common_remove(furi_record_open(RECORD_STORAGE), DESKTOP_KEYBINDS_PATH);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
DESKTOP_KEYBINDS_LOAD(&app->desktop->keybinds, sizeof(app->desktop->keybinds));
|
||||
/* fall through */
|
||||
case DialogExResultLeft:
|
||||
consumed = scene_manager_previous_scene(app->scene_manager);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void desktop_settings_scene_keybinds_reset_on_exit(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
enum VarItemListIndex {
|
||||
VarItemListIndexKeybinds,
|
||||
VarItemListIndexResetKeybinds,
|
||||
VarItemListIndexPinSetup,
|
||||
VarItemListIndexAutoLockTime,
|
||||
VarItemListIndexAutoLockPin,
|
||||
@@ -58,6 +59,8 @@ void desktop_settings_scene_start_on_enter(void* context) {
|
||||
|
||||
variable_item_list_add(variable_item_list, "Keybinds Setup", 1, NULL, NULL);
|
||||
|
||||
variable_item_list_add(variable_item_list, "Reset Keybinds to Default", 1, NULL, NULL);
|
||||
|
||||
variable_item_list_add(variable_item_list, "PIN Setup", 1, NULL, NULL);
|
||||
|
||||
item = variable_item_list_add(
|
||||
@@ -101,6 +104,12 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneKeybindsType);
|
||||
consumed = true;
|
||||
break;
|
||||
case VarItemListIndexResetKeybinds:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, DesktopSettingsAppSceneKeybindsType, 0);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneKeybindsReset);
|
||||
consumed = true;
|
||||
break;
|
||||
case VarItemListIndexPinSetup:
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinMenu);
|
||||
consumed = true;
|
||||
|
||||
Reference in New Issue
Block a user