Option to disable poweroff while locked --nobuild

This commit is contained in:
Willy-JL
2023-12-01 23:02:23 +00:00
parent d16ac1f73d
commit e2df487c63
4 changed files with 28 additions and 1 deletions

View File

@@ -41,6 +41,14 @@ static void
app->save_settings = true;
}
static void xtreme_app_scene_interface_lockscreen_lockscreen_poweroff_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
xtreme_settings.lockscreen_poweroff = value;
app->save_settings = true;
}
static void xtreme_app_scene_interface_lockscreen_lockscreen_time_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
@@ -124,6 +132,15 @@ void xtreme_app_scene_interface_lockscreen_on_enter(void* context) {
variable_item_set_current_value_text(
item, xtreme_settings.allow_locked_rpc_commands ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list,
"Allow Poweroff",
2,
xtreme_app_scene_interface_lockscreen_lockscreen_poweroff_changed,
app);
variable_item_set_current_value_index(item, xtreme_settings.lockscreen_poweroff);
variable_item_set_current_value_text(item, xtreme_settings.lockscreen_poweroff ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list,
"Show Time",

View File

@@ -13,6 +13,7 @@
#include "../views/desktop_view_locked.h"
#include "desktop_scene.h"
#include "desktop_scene_i.h"
#include <xtreme.h>
#define TAG "DesktopSrv"
@@ -84,7 +85,9 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case DesktopLockedEventOpenPowerOff: {
loader_start(desktop->loader, "Power", "off", NULL);
if(xtreme_settings.lockscreen_poweroff) {
loader_start(desktop->loader, "Power", "off", NULL);
}
consumed = true;
break;
}