1
0
Fork 0
forked from len0rd/rockbox

shortcuts: add 'reboot' type

Enabled by d55dcef

Change-Id: I689e289feb4715aab603bae4a6855cf5e227562b
This commit is contained in:
Christian Soffke 2024-05-11 23:45:25 +02:00
parent f631bfe5b4
commit 8eeef333a1
3 changed files with 21 additions and 4 deletions

View file

@ -61,6 +61,7 @@ static const char * const type_strings[SHORTCUT_TYPE_COUNT] = {
[SHORTCUT_PLAYLISTMENU] = "playlist menu", [SHORTCUT_PLAYLISTMENU] = "playlist menu",
[SHORTCUT_SEPARATOR] = "separator", [SHORTCUT_SEPARATOR] = "separator",
[SHORTCUT_SHUTDOWN] = "shutdown", [SHORTCUT_SHUTDOWN] = "shutdown",
[SHORTCUT_REBOOT] = "reboot",
[SHORTCUT_TIME] = "time", [SHORTCUT_TIME] = "time",
}; };
@ -189,6 +190,7 @@ static bool verify_shortcut(struct shortcut* sc)
case SHORTCUT_DEBUGITEM: case SHORTCUT_DEBUGITEM:
case SHORTCUT_SEPARATOR: case SHORTCUT_SEPARATOR:
case SHORTCUT_SHUTDOWN: case SHORTCUT_SHUTDOWN:
case SHORTCUT_REBOOT:
default: default:
break; break;
} }
@ -362,6 +364,7 @@ static int readline_cb(int n, char *buf, void *parameters)
break; break;
case SHORTCUT_SEPARATOR: case SHORTCUT_SEPARATOR:
case SHORTCUT_SHUTDOWN: case SHORTCUT_SHUTDOWN:
case SHORTCUT_REBOOT:
break; break;
} }
} }
@ -444,10 +447,11 @@ static const char * shortcut_menu_get_name(int selected_item, void * data,
} }
return sc->name; return sc->name;
} }
else if (sc->type == SHORTCUT_SHUTDOWN && sc->name[0] == '\0') else if ((sc->type == SHORTCUT_SHUTDOWN || sc->type == SHORTCUT_REBOOT) &&
sc->name[0] == '\0')
{ {
/* No translation support as only soft_shutdown has LANG_SHUTDOWN defined */ /* No translation support as only soft_shutdown has LANG_SHUTDOWN defined */
return type_strings[SHORTCUT_SHUTDOWN]; return type_strings[sc->type];
} }
else if (sc->type == SHORTCUT_BROWSER && sc->name[0] == '\0' && (sc->u.path)[0] != '\0') else if (sc->type == SHORTCUT_BROWSER && sc->name[0] == '\0' && (sc->u.path)[0] != '\0')
{ {
@ -524,6 +528,7 @@ static enum themable_icons shortcut_menu_get_icon(int selected_item, void * data
case SHORTCUT_PLAYLISTMENU: case SHORTCUT_PLAYLISTMENU:
return Icon_Playlist; return Icon_Playlist;
case SHORTCUT_SHUTDOWN: case SHORTCUT_SHUTDOWN:
case SHORTCUT_REBOOT:
return Icon_System_menu; return Icon_System_menu;
case SHORTCUT_TIME: case SHORTCUT_TIME:
return Icon_Menu_functioncall; return Icon_Menu_functioncall;
@ -605,11 +610,13 @@ static int shortcut_menu_speak_item(int selected_item, void * data)
talk_spell(sc->name, false); talk_spell(sc->name, false);
break; break;
case SHORTCUT_SHUTDOWN: case SHORTCUT_SHUTDOWN:
case SHORTCUT_REBOOT:
if (!sc->name[0]) if (!sc->name[0])
{ {
talk_spell(type_strings[SHORTCUT_SHUTDOWN], false); talk_spell(type_strings[sc->type], false);
break; break;
} }
/* fall-through */
default: default:
talk_spell(sc->name[0] ? sc->name : sc->u.path, false); talk_spell(sc->name[0] ? sc->name : sc->u.path, false);
break; break;
@ -736,6 +743,14 @@ int do_shortcut_menu(void *ignored)
#endif #endif
sys_poweroff(); sys_poweroff();
break; break;
case SHORTCUT_REBOOT:
#if CONFIG_CHARGING
if (charger_inserted())
charging_splash();
else
#endif
sys_reboot();
break;
case SHORTCUT_TIME: case SHORTCUT_TIME:
#if CONFIG_RTC #if CONFIG_RTC
if (!sc->u.timedata.talktime) if (!sc->u.timedata.talktime)

View file

@ -33,6 +33,7 @@ enum shortcut_type {
SHORTCUT_PLAYLISTMENU, SHORTCUT_PLAYLISTMENU,
SHORTCUT_SEPARATOR, SHORTCUT_SEPARATOR,
SHORTCUT_SHUTDOWN, SHORTCUT_SHUTDOWN,
SHORTCUT_REBOOT,
SHORTCUT_TIME, SHORTCUT_TIME,
SHORTCUT_TYPE_COUNT SHORTCUT_TYPE_COUNT

View file

@ -293,7 +293,7 @@ settings. With a shortcut,
\item The current time can be spoken \item The current time can be spoken
} }
\item The sleep timer can be configured \item The sleep timer can be configured
\item The \dap{} can be turned off \item The \dap{} can be turned off or rebooted
\end{itemize} \end{itemize}
\note{Shortcuts into the database are not possible} \note{Shortcuts into the database are not possible}
@ -330,6 +330,7 @@ Available types are:
or started using the default duration; \config{name} will be ignored in that case. Otherwise or started using the default duration; \config{name} will be ignored in that case. Otherwise
\config{name} is required for this shortcut type. \config{name} is required for this shortcut type.
\item[shutdown] \config{data} is ignored; \config{name} can be used to display text \item[shutdown] \config{data} is ignored; \config{name} can be used to display text
\item[reboot] \config{data} is ignored; \config{name} can be used to display text
\end{description} \end{description}
If the name/icon items are not specified, a sensible default will be used. If the name/icon items are not specified, a sensible default will be used.