diff options
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_settings.c')
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.c | 80 |
1 files changed, 50 insertions, 30 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index 3868d759f6..d361cc818e 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c | |||
@@ -259,6 +259,7 @@ static const struct opt_items globaloff[2] = { | |||
259 | #define BACKLIGHT_OPTION_DEFAULT "Use setting" | 259 | #define BACKLIGHT_OPTION_DEFAULT "Use setting" |
260 | #endif | 260 | #endif |
261 | 261 | ||
262 | static void mpeg_settings(void); | ||
262 | static long mpeg_menu_sysevent_id; | 263 | static long mpeg_menu_sysevent_id; |
263 | 264 | ||
264 | void mpeg_menu_sysevent_clear(void) | 265 | void mpeg_menu_sysevent_clear(void) |
@@ -831,9 +832,8 @@ static int show_start_menu(uint32_t duration) | |||
831 | struct hms hms; | 832 | struct hms hms; |
832 | 833 | ||
833 | MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_menu_sysevent_callback, | 834 | MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_menu_sysevent_callback, |
834 | "Play from beginning", resume_str, | 835 | "Play from beginning", resume_str, "Set start time", |
835 | "Set start time", "Settings", | 836 | "Settings", "Quit mpegplayer"); |
836 | "Quit mpegplayer"); | ||
837 | 837 | ||
838 | ts_to_hms(settings.resume_time, &hms); | 838 | ts_to_hms(settings.resume_time, &hms); |
839 | hms_format(hms_str, sizeof(hms_str), &hms); | 839 | hms_format(hms_str, sizeof(hms_str), &hms); |
@@ -872,9 +872,9 @@ static int show_start_menu(uint32_t duration) | |||
872 | break; | 872 | break; |
873 | 873 | ||
874 | case MPEG_START_SETTINGS: | 874 | case MPEG_START_SETTINGS: |
875 | if (mpeg_menu(MPEG_MENU_HIDE_QUIT_ITEM) != MPEG_MENU_QUIT) | 875 | mpeg_settings(); |
876 | break; | 876 | break; |
877 | /* Fall-through */ | 877 | |
878 | default: | 878 | default: |
879 | result = MPEG_START_QUIT; | 879 | result = MPEG_START_QUIT; |
880 | menu_quit = true; | 880 | menu_quit = true; |
@@ -916,6 +916,44 @@ int mpeg_start_menu(uint32_t duration) | |||
916 | } | 916 | } |
917 | } | 917 | } |
918 | 918 | ||
919 | int mpeg_menu(void) | ||
920 | { | ||
921 | int result; | ||
922 | |||
923 | MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_menu_sysevent_callback, | ||
924 | "Settings", "Resume playback", "Quit mpegplayer"); | ||
925 | |||
926 | rb->button_clear_queue(); | ||
927 | |||
928 | mpeg_menu_sysevent_clear(); | ||
929 | |||
930 | result = rb->do_menu(&menu, NULL, NULL, false); | ||
931 | |||
932 | switch (result) | ||
933 | { | ||
934 | case MPEG_MENU_SETTINGS: | ||
935 | mpeg_settings(); | ||
936 | break; | ||
937 | |||
938 | case MPEG_MENU_RESUME: | ||
939 | break; | ||
940 | |||
941 | case MPEG_MENU_QUIT: | ||
942 | break; | ||
943 | |||
944 | default: | ||
945 | break; | ||
946 | } | ||
947 | |||
948 | if (mpeg_menu_sysevent() != 0) | ||
949 | result = MPEG_MENU_QUIT; | ||
950 | |||
951 | rb->lcd_clear_display(); | ||
952 | rb->lcd_update(); | ||
953 | |||
954 | return result; | ||
955 | } | ||
956 | |||
919 | /** MPEG Menu **/ | 957 | /** MPEG Menu **/ |
920 | static void display_options(void) | 958 | static void display_options(void) |
921 | { | 959 | { |
@@ -1078,25 +1116,16 @@ static void clear_resume_count(void) | |||
1078 | configfile_update_entry(SETTINGS_FILENAME, "Resume count", 0); | 1116 | configfile_update_entry(SETTINGS_FILENAME, "Resume count", 0); |
1079 | } | 1117 | } |
1080 | 1118 | ||
1081 | int mpeg_menu(unsigned flags) | 1119 | static void mpeg_settings(void) |
1082 | { | 1120 | { |
1083 | int selected = 0; | 1121 | int selected = 0; |
1084 | int result; | 1122 | int result; |
1085 | bool menu_quit = false; | 1123 | bool menu_quit = false; |
1086 | static char clear_str[32]; | 1124 | static char clear_str[32]; |
1087 | 1125 | ||
1088 | MENUITEM_STRINGLIST(menu_with_quit, "Mpegplayer Menu", | 1126 | MENUITEM_STRINGLIST(menu, "Settings", mpeg_menu_sysevent_callback, |
1089 | mpeg_menu_sysevent_callback, | ||
1090 | "Display Options", "Audio Options", | ||
1091 | "Resume Options", clear_str, "Quit mpegplayer"); | ||
1092 | MENUITEM_STRINGLIST(menu_without_quit, "Settings", | ||
1093 | mpeg_menu_sysevent_callback, | ||
1094 | "Display Options", "Audio Options", | 1127 | "Display Options", "Audio Options", |
1095 | "Resume Options", clear_str); | 1128 | "Resume Options", clear_str); |
1096 | const struct menu_item_ex *menu = &menu_with_quit; | ||
1097 | |||
1098 | if (flags & MPEG_MENU_HIDE_QUIT_ITEM) | ||
1099 | menu = &menu_without_quit; | ||
1100 | 1129 | ||
1101 | rb->button_clear_queue(); | 1130 | rb->button_clear_queue(); |
1102 | 1131 | ||
@@ -1112,39 +1141,30 @@ int mpeg_menu(unsigned flags) | |||
1112 | 1141 | ||
1113 | switch (result) | 1142 | switch (result) |
1114 | { | 1143 | { |
1115 | case MPEG_MENU_DISPLAY_SETTINGS: | 1144 | case MPEG_SETTING_DISPLAY_SETTINGS: |
1116 | display_options(); | 1145 | display_options(); |
1117 | break; | 1146 | break; |
1118 | 1147 | ||
1119 | case MPEG_MENU_AUDIO_SETTINGS: | 1148 | case MPEG_SETTING_AUDIO_SETTINGS: |
1120 | audio_options(); | 1149 | audio_options(); |
1121 | break; | 1150 | break; |
1122 | 1151 | ||
1123 | case MPEG_MENU_ENABLE_START_MENU: | 1152 | case MPEG_SETTING_ENABLE_START_MENU: |
1124 | resume_options(); | 1153 | resume_options(); |
1125 | break; | 1154 | break; |
1126 | 1155 | ||
1127 | case MPEG_MENU_CLEAR_RESUMES: | 1156 | case MPEG_SETTING_CLEAR_RESUMES: |
1128 | clear_resume_count(); | 1157 | clear_resume_count(); |
1129 | break; | 1158 | break; |
1130 | 1159 | ||
1131 | case MPEG_MENU_QUIT: | ||
1132 | default: | 1160 | default: |
1133 | menu_quit = true; | 1161 | menu_quit = true; |
1134 | break; | 1162 | break; |
1135 | } | 1163 | } |
1136 | 1164 | ||
1137 | if (mpeg_menu_sysevent() != 0) | 1165 | if (mpeg_menu_sysevent() != 0) |
1138 | { | ||
1139 | result = MPEG_MENU_QUIT; | ||
1140 | menu_quit = true; | 1166 | menu_quit = true; |
1141 | } | ||
1142 | } | 1167 | } |
1143 | |||
1144 | rb->lcd_clear_display(); | ||
1145 | rb->lcd_update(); | ||
1146 | |||
1147 | return result; | ||
1148 | } | 1168 | } |
1149 | 1169 | ||
1150 | void init_settings(const char* filename) | 1170 | void init_settings(const char* filename) |