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:
parent
ab161a3d89
commit
8d4efb6cf2
6 changed files with 60 additions and 95 deletions
|
@ -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 */
|
redraw=true;/* we'll set it to false afterwards if there was no action */
|
||||||
switch (button){
|
switch (button){
|
||||||
case ACTION_COUNTER_TOGGLE: /* start/stop counter */
|
case ACTION_COUNTER_TOGGLE: /* start/stop counter */
|
||||||
if(clock_settings.general.show_counter)
|
show_counter = true;
|
||||||
counter_toggle(&counter);
|
counter_toggle(&counter);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_COUNTER_RESET: /* reset counter */
|
case ACTION_COUNTER_RESET: /* reset counter */
|
||||||
if(clock_settings.general.show_counter)
|
if(show_counter)
|
||||||
|
{
|
||||||
counter_reset(&counter);
|
counter_reset(&counter);
|
||||||
|
show_counter = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_MODE_NEXT_REPEAT:
|
case ACTION_MODE_NEXT_REPEAT:
|
||||||
|
@ -179,7 +182,11 @@ enum plugin_status plugin_start(const void* parameter){
|
||||||
#endif
|
#endif
|
||||||
case ACTION_MENU:
|
case ACTION_MENU:
|
||||||
clock_draw_restore_colors();
|
clock_draw_restore_colors();
|
||||||
|
FOR_NB_SCREENS(i)
|
||||||
|
rb->viewportmanager_theme_enable(i, true, NULL);
|
||||||
exit_clock=main_menu();
|
exit_clock=main_menu();
|
||||||
|
FOR_NB_SCREENS(i)
|
||||||
|
rb->viewportmanager_theme_undo(i, false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exit_on_usb(button);
|
exit_on_usb(button);
|
||||||
|
|
|
@ -87,7 +87,7 @@ void clock_draw_restore_colors(void){
|
||||||
|
|
||||||
void clock_draw(struct screen* display, struct time* time,
|
void clock_draw(struct screen* display, struct time* time,
|
||||||
struct counter* counter){
|
struct counter* counter){
|
||||||
if(!clock_settings.general.show_counter)
|
if(!show_counter)
|
||||||
counter=0;
|
counter=0;
|
||||||
int skin=clock_settings.skin[clock_settings.mode];
|
int skin=clock_settings.skin[clock_settings.mode];
|
||||||
skin_set_background(display, clock_settings.mode, skin);
|
skin_set_background(display, clock_settings.mode, skin);
|
||||||
|
|
|
@ -50,13 +50,13 @@ void digital_clock_draw(struct screen* display,
|
||||||
else
|
else
|
||||||
display_colon=true;
|
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;
|
hour -= 12;
|
||||||
|
|
||||||
buffer_printf(buffer, buffer_pos, "%02d", hour);
|
buffer_printf(buffer, buffer_pos, "%02d", hour);
|
||||||
buffer_printf(buffer, buffer_pos, "%c", display_colon?':':' ');
|
buffer_printf(buffer, buffer_pos, "%c", display_colon?':':' ');
|
||||||
buffer_printf(buffer, buffer_pos, "%02d", time->minute);
|
buffer_printf(buffer, buffer_pos, "%02d", time->minute);
|
||||||
if(settings->general.hour_format==H12){
|
if(rb->global_settings->timeformat){
|
||||||
if(time->hour>=12){
|
if(time->hour>=12){
|
||||||
buffer_printf(buffer, buffer_pos, "P");/* PM */
|
buffer_printf(buffer, buffer_pos, "P");/* PM */
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -33,7 +33,7 @@ static const struct opt_items noyes_text[] = {
|
||||||
|
|
||||||
static const struct opt_items backlight_settings_text[] = {
|
static const struct opt_items backlight_settings_text[] = {
|
||||||
{ "Always Off", -1 },
|
{ "Always Off", -1 },
|
||||||
{ "Use Rockbox Setting", -1 },
|
{ "Use System Setting", -1 },
|
||||||
{ "Always On", -1 }
|
{ "Always On", -1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,17 +49,12 @@ static const struct opt_items date_format_text[] = {
|
||||||
{ "Japanese (Y-M-D)", -1 },
|
{ "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
|
* Select a mode, returs true when the mode has been selected
|
||||||
* (we go back to clock display then)
|
* (we go back to clock display then)
|
||||||
**************/
|
**************/
|
||||||
static bool menu_mode_selector(void){
|
static bool menu_mode_selector(void){
|
||||||
MENUITEM_STRINGLIST(menu,"Mode Selector",NULL, "Analog",
|
MENUITEM_STRINGLIST(menu,"Mode",NULL, "Analog",
|
||||||
"Digital", "Binary");
|
"Digital", "Binary");
|
||||||
if(rb->do_menu(&menu, &clock_settings.mode, NULL, false) >=0)
|
if(rb->do_menu(&menu, &clock_settings.mode, NULL, false) >=0)
|
||||||
return(true);
|
return(true);
|
||||||
|
@ -73,7 +68,7 @@ static void menu_analog_settings(void)
|
||||||
{
|
{
|
||||||
int selection=0, result=0;
|
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");
|
"Show Second Hand","Show Border");
|
||||||
|
|
||||||
while(result>=0){
|
while(result>=0){
|
||||||
|
@ -103,7 +98,7 @@ static void menu_analog_settings(void)
|
||||||
static void menu_digital_settings(void){
|
static void menu_digital_settings(void){
|
||||||
int selection=0, result=0;
|
int selection=0, result=0;
|
||||||
|
|
||||||
MENUITEM_STRINGLIST(menu,"Digital Mode Settings",NULL,"Show Seconds",
|
MENUITEM_STRINGLIST(menu,"Digital",NULL,"Show Seconds",
|
||||||
"Blinking Colon");
|
"Blinking Colon");
|
||||||
|
|
||||||
while(result>=0){
|
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
|
* General settings. Reset, save, etc
|
||||||
***********************************/
|
***********************************/
|
||||||
static void menu_general_settings(void){
|
static int menu_general_settings(void){
|
||||||
int selection=0, result=0;
|
int selection=0, result=0;
|
||||||
|
|
||||||
MENUITEM_STRINGLIST(menu,"General Settings",NULL,
|
MENUITEM_STRINGLIST(menu, "Clock Settings", NULL,
|
||||||
"Hour Format","Date Format","Show Counter",
|
"Analog", "Digital",
|
||||||
"Reset Settings","Save Settings Now",
|
"Date Format", "Backlight", "Idle Poweroff",
|
||||||
"Save On Exit","Backlight Settings",
|
"Save on Exit", "Save", "Reset");
|
||||||
"Idle Poweroff (temporary)");
|
|
||||||
|
|
||||||
while(result>=0){
|
while(result>=0){
|
||||||
result=rb->do_menu(&menu, &selection, NULL, false);
|
result=rb->do_menu(&menu, &selection, NULL, false);
|
||||||
switch(result){
|
switch(result){
|
||||||
case 0:
|
case 0:
|
||||||
rb->set_option("Hour format",
|
menu_analog_settings();
|
||||||
&clock_settings.general.hour_format,
|
|
||||||
RB_INT, hour_format_text, 2, NULL);
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
rb->set_option("Date format",
|
menu_digital_settings();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
rb->set_option("Date Format",
|
||||||
&clock_settings.general.date_format,
|
&clock_settings.general.date_format,
|
||||||
RB_INT, date_format_text, 4, NULL);
|
RB_INT, date_format_text, 4, NULL);
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
rb->set_option("Show Counter", &clock_settings.general.show_counter,
|
|
||||||
RB_BOOL, noyes_text, 2, NULL);
|
|
||||||
break;
|
|
||||||
case 3:
|
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;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
save_settings_wo_gui();
|
rb->set_option("Idle Poweroff",
|
||||||
rb->splash(HZ, "Settings saved");
|
&clock_settings.general.idle_poweroff,
|
||||||
|
RB_BOOL, idle_poweroff_text, 2, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
rb->set_option("Save On Exit",
|
rb->set_option("Save on Exit",
|
||||||
&clock_settings.general.save_settings,
|
&clock_settings.general.save_settings,
|
||||||
RB_BOOL, noyes_text, 2, NULL);
|
RB_BOOL, noyes_text, 2, NULL);
|
||||||
|
|
||||||
|
@ -188,64 +166,51 @@ static void menu_general_settings(void){
|
||||||
save_settings_wo_gui();
|
save_settings_wo_gui();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
rb->set_option("Backlight Settings",
|
save_settings_wo_gui();
|
||||||
&clock_settings.general.backlight,
|
rb->splash(HZ, ID2P(LANG_SETTINGS_SAVED));
|
||||||
RB_INT, backlight_settings_text, 3, NULL);
|
|
||||||
apply_backlight_setting(clock_settings.general.backlight);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
rb->set_option("Idle Poweroff (temporary)",
|
if (rb->yesno_pop_confirm(ID2P(LANG_RESET)))
|
||||||
&clock_settings.general.idle_poweroff,
|
{
|
||||||
RB_BOOL, idle_poweroff_text, 2, NULL);
|
clock_settings_reset(&clock_settings);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********
|
/***********
|
||||||
* Main menu
|
* Main menu
|
||||||
**********/
|
**********/
|
||||||
bool main_menu(void){
|
bool main_menu(void)
|
||||||
int selection=0;
|
{
|
||||||
|
int selection = 0;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
bool exit_clock=false;
|
bool exit_clock=false;
|
||||||
|
|
||||||
MENUITEM_STRINGLIST(menu,"Clock Menu",NULL,"View Clock","Mode Selector",
|
MENUITEM_STRINGLIST(menu, "Clock", NULL, "Mode",
|
||||||
"Mode Settings","General Settings","Playback Control",
|
"Settings","Playback Control",
|
||||||
"Quit");
|
"Quit");
|
||||||
|
while (!done)
|
||||||
while(!done){
|
{
|
||||||
switch(rb->do_menu(&menu, &selection, NULL, false)){
|
switch(rb->do_menu(&menu, &selection, NULL, false))
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
done = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
done=menu_mode_selector();
|
done=menu_mode_selector();
|
||||||
break;
|
break;
|
||||||
|
case 1:
|
||||||
|
if (menu_general_settings())
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
case 2:
|
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);
|
playback_control(NULL);
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
case 5:
|
|
||||||
exit_clock = true;
|
exit_clock = true;
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
done=true;
|
done=true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -46,6 +46,7 @@ enum settings_file_status{
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clock_settings clock_settings;
|
struct clock_settings clock_settings;
|
||||||
|
bool show_counter;
|
||||||
|
|
||||||
/* The settings as they exist on the hard disk, so that
|
/* The settings as they exist on the hard disk, so that
|
||||||
* we can know at saving time if changes have been made */
|
* 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++){
|
for(i=0;i<NB_CLOCK_MODES;i++){
|
||||||
settings->skin[i]=0;
|
settings->skin[i]=0;
|
||||||
}
|
}
|
||||||
settings->general.hour_format = H12;
|
|
||||||
settings->general.date_format = EUROPEAN;
|
settings->general.date_format = EUROPEAN;
|
||||||
settings->general.show_counter = true;
|
|
||||||
settings->general.save_settings = true;
|
settings->general.save_settings = true;
|
||||||
settings->general.idle_poweroff=true;
|
settings->general.idle_poweroff=true;
|
||||||
settings->general.backlight = ROCKBOX_SETTING;
|
settings->general.backlight = ROCKBOX_SETTING;
|
||||||
|
|
|
@ -30,11 +30,6 @@ enum date_format{
|
||||||
JAPANESE,
|
JAPANESE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum hour_format{
|
|
||||||
H24,
|
|
||||||
H12
|
|
||||||
};
|
|
||||||
|
|
||||||
enum clock_modes{
|
enum clock_modes{
|
||||||
ANALOG,
|
ANALOG,
|
||||||
DIGITAL,
|
DIGITAL,
|
||||||
|
@ -50,9 +45,7 @@ enum backlight_handling{
|
||||||
|
|
||||||
|
|
||||||
struct general_settings{
|
struct general_settings{
|
||||||
int hour_format;/* 0:24h, 1:12h*/
|
|
||||||
int date_format;
|
int date_format;
|
||||||
bool show_counter;
|
|
||||||
bool save_settings;
|
bool save_settings;
|
||||||
bool idle_poweroff;
|
bool idle_poweroff;
|
||||||
int backlight;
|
int backlight;
|
||||||
|
@ -78,6 +71,7 @@ struct clock_settings{
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct clock_settings clock_settings;
|
extern struct clock_settings clock_settings;
|
||||||
|
extern bool show_counter;
|
||||||
|
|
||||||
/* settings are saved to this location */
|
/* settings are saved to this location */
|
||||||
#define settings_filename PLUGIN_APPS_DIR "/.clock_settings"
|
#define settings_filename PLUGIN_APPS_DIR "/.clock_settings"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue