1
0
Fork 0
forked from len0rd/rockbox

plugins: clock: simplify settings

- Use system time format and remove separate setting
- Hide timer until started & eliminate setting for it
- Simplify menu, reorder settings, keep theme enabled
- Make dialog for resetting settings more consistent
  with other reset dialogs

Change-Id: I0fd38612b0592cd5a650c8985f377acc70a48eb7
This commit is contained in:
Christian Soffke 2025-06-07 20:58:09 +02:00
parent ab161a3d89
commit 8d4efb6cf2
6 changed files with 60 additions and 95 deletions

View file

@ -145,13 +145,16 @@ enum plugin_status plugin_start(const void* parameter){
redraw=true;/* we'll set it to false afterwards if there was no action */
switch (button){
case ACTION_COUNTER_TOGGLE: /* start/stop counter */
if(clock_settings.general.show_counter)
counter_toggle(&counter);
show_counter = true;
counter_toggle(&counter);
break;
case ACTION_COUNTER_RESET: /* reset counter */
if(clock_settings.general.show_counter)
if(show_counter)
{
counter_reset(&counter);
show_counter = false;
}
break;
case ACTION_MODE_NEXT_REPEAT:
@ -179,7 +182,11 @@ enum plugin_status plugin_start(const void* parameter){
#endif
case ACTION_MENU:
clock_draw_restore_colors();
FOR_NB_SCREENS(i)
rb->viewportmanager_theme_enable(i, true, NULL);
exit_clock=main_menu();
FOR_NB_SCREENS(i)
rb->viewportmanager_theme_undo(i, false);
break;
default:
exit_on_usb(button);

View file

@ -87,7 +87,7 @@ void clock_draw_restore_colors(void){
void clock_draw(struct screen* display, struct time* time,
struct counter* counter){
if(!clock_settings.general.show_counter)
if(!show_counter)
counter=0;
int skin=clock_settings.skin[clock_settings.mode];
skin_set_background(display, clock_settings.mode, skin);

View file

@ -50,13 +50,13 @@ void digital_clock_draw(struct screen* display,
else
display_colon=true;
if(settings->general.hour_format==H12 && time->hour>12)/* AM/PM format */
if(rb->global_settings->timeformat && time->hour>12)/* AM/PM format */
hour -= 12;
buffer_printf(buffer, buffer_pos, "%02d", hour);
buffer_printf(buffer, buffer_pos, "%c", display_colon?':':' ');
buffer_printf(buffer, buffer_pos, "%02d", time->minute);
if(settings->general.hour_format==H12){
if(rb->global_settings->timeformat){
if(time->hour>=12){
buffer_printf(buffer, buffer_pos, "P");/* PM */
}else{

View file

@ -33,7 +33,7 @@ static const struct opt_items noyes_text[] = {
static const struct opt_items backlight_settings_text[] = {
{ "Always Off", -1 },
{ "Use Rockbox Setting", -1 },
{ "Use System Setting", -1 },
{ "Always On", -1 }
};
@ -49,17 +49,12 @@ static const struct opt_items date_format_text[] = {
{ "Japanese (Y-M-D)", -1 },
};
static const struct opt_items hour_format_text[] = {
{ "24-Hour", -1 },
{ "12-Hour", -1 }
};
/***************
* Select a mode, returs true when the mode has been selected
* (we go back to clock display then)
**************/
static bool menu_mode_selector(void){
MENUITEM_STRINGLIST(menu,"Mode Selector",NULL, "Analog",
MENUITEM_STRINGLIST(menu,"Mode",NULL, "Analog",
"Digital", "Binary");
if(rb->do_menu(&menu, &clock_settings.mode, NULL, false) >=0)
return(true);
@ -73,7 +68,7 @@ static void menu_analog_settings(void)
{
int selection=0, result=0;
MENUITEM_STRINGLIST(menu,"Analog Mode Settings",NULL,"Show Date",
MENUITEM_STRINGLIST(menu,"Analog",NULL,"Show Date",
"Show Second Hand","Show Border");
while(result>=0){
@ -103,7 +98,7 @@ static void menu_analog_settings(void)
static void menu_digital_settings(void){
int selection=0, result=0;
MENUITEM_STRINGLIST(menu,"Digital Mode Settings",NULL,"Show Seconds",
MENUITEM_STRINGLIST(menu,"Digital",NULL,"Show Seconds",
"Blinking Colon");
while(result>=0){
@ -123,62 +118,45 @@ static void menu_digital_settings(void){
}
}
/***********************************************************
* Confirm resetting of settings, used in general_settings()
**********************************************************/
static void confirm_reset(void){
int result=0;
rb->set_option("Reset all settings?", &result, RB_INT, noyes_text, 2, NULL);
if(result == 1){ /* reset! */
clock_settings_reset(&clock_settings);
rb->splash(HZ, "Settings reset!");
}
else
rb->splash(HZ, "Settings NOT reset.");
}
/************************************
* General settings. Reset, save, etc
***********************************/
static void menu_general_settings(void){
static int menu_general_settings(void){
int selection=0, result=0;
MENUITEM_STRINGLIST(menu,"General Settings",NULL,
"Hour Format","Date Format","Show Counter",
"Reset Settings","Save Settings Now",
"Save On Exit","Backlight Settings",
"Idle Poweroff (temporary)");
MENUITEM_STRINGLIST(menu, "Clock Settings", NULL,
"Analog", "Digital",
"Date Format", "Backlight", "Idle Poweroff",
"Save on Exit", "Save", "Reset");
while(result>=0){
result=rb->do_menu(&menu, &selection, NULL, false);
switch(result){
case 0:
rb->set_option("Hour format",
&clock_settings.general.hour_format,
RB_INT, hour_format_text, 2, NULL);
menu_analog_settings();
break;
case 1:
rb->set_option("Date format",
menu_digital_settings();
break;
case 2:
rb->set_option("Date Format",
&clock_settings.general.date_format,
RB_INT, date_format_text, 4, NULL);
break;
case 2:
rb->set_option("Show Counter", &clock_settings.general.show_counter,
RB_BOOL, noyes_text, 2, NULL);
break;
case 3:
confirm_reset();
rb->set_option("Backlight",
&clock_settings.general.backlight,
RB_INT, backlight_settings_text, 3, NULL);
apply_backlight_setting(clock_settings.general.backlight);
break;
case 4:
save_settings_wo_gui();
rb->splash(HZ, "Settings saved");
rb->set_option("Idle Poweroff",
&clock_settings.general.idle_poweroff,
RB_BOOL, idle_poweroff_text, 2, NULL);
break;
case 5:
rb->set_option("Save On Exit",
rb->set_option("Save on Exit",
&clock_settings.general.save_settings,
RB_BOOL, noyes_text, 2, NULL);
@ -188,64 +166,51 @@ static void menu_general_settings(void){
save_settings_wo_gui();
break;
case 6:
rb->set_option("Backlight Settings",
&clock_settings.general.backlight,
RB_INT, backlight_settings_text, 3, NULL);
apply_backlight_setting(clock_settings.general.backlight);
save_settings_wo_gui();
rb->splash(HZ, ID2P(LANG_SETTINGS_SAVED));
break;
case 7:
rb->set_option("Idle Poweroff (temporary)",
&clock_settings.general.idle_poweroff,
RB_BOOL, idle_poweroff_text, 2, NULL);
if (rb->yesno_pop_confirm(ID2P(LANG_RESET)))
{
clock_settings_reset(&clock_settings);
return 1;
}
break;
}
}
return 0;
}
/***********
* Main menu
**********/
bool main_menu(void){
int selection=0;
bool main_menu(void)
{
int selection = 0;
bool done = false;
bool exit_clock=false;
MENUITEM_STRINGLIST(menu,"Clock Menu",NULL,"View Clock","Mode Selector",
"Mode Settings","General Settings","Playback Control",
MENUITEM_STRINGLIST(menu, "Clock", NULL, "Mode",
"Settings","Playback Control",
"Quit");
while(!done){
switch(rb->do_menu(&menu, &selection, NULL, false)){
while (!done)
{
switch(rb->do_menu(&menu, &selection, NULL, false))
{
case 0:
done = true;
break;
case 1:
done=menu_mode_selector();
break;
case 1:
if (menu_general_settings())
done = true;
break;
case 2:
switch(clock_settings.mode){
case ANALOG: menu_analog_settings();break;
case DIGITAL: menu_digital_settings();break;
case BINARY: /* no settings */;break;
}
break;
case 3:
menu_general_settings();
break;
case 4:
playback_control(NULL);
break;
case 5:
case 3:
exit_clock = true;
done = true;
break;
default:
done=true;
break;

View file

@ -46,6 +46,7 @@ enum settings_file_status{
};
struct clock_settings clock_settings;
bool show_counter;
/* The settings as they exist on the hard disk, so that
* we can know at saving time if changes have been made */
@ -61,9 +62,7 @@ void clock_settings_reset(struct clock_settings* settings){
for(i=0;i<NB_CLOCK_MODES;i++){
settings->skin[i]=0;
}
settings->general.hour_format = H12;
settings->general.date_format = EUROPEAN;
settings->general.show_counter = true;
settings->general.save_settings = true;
settings->general.idle_poweroff=true;
settings->general.backlight = ROCKBOX_SETTING;

View file

@ -30,11 +30,6 @@ enum date_format{
JAPANESE,
};
enum hour_format{
H24,
H12
};
enum clock_modes{
ANALOG,
DIGITAL,
@ -50,9 +45,7 @@ enum backlight_handling{
struct general_settings{
int hour_format;/* 0:24h, 1:12h*/
int date_format;
bool show_counter;
bool save_settings;
bool idle_poweroff;
int backlight;
@ -78,6 +71,7 @@ struct clock_settings{
};
extern struct clock_settings clock_settings;
extern bool show_counter;
/* settings are saved to this location */
#define settings_filename PLUGIN_APPS_DIR "/.clock_settings"