mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
3djc/horus fix3924 (#3932)
* Forbid delete category when not empty. Add confirmation This fixes #3924 and #3823 * Cosmetics
This commit is contained in:
parent
4513cf89f2
commit
b56a65cc1a
14 changed files with 59 additions and 12 deletions
|
@ -31,7 +31,12 @@ enum ModelSelectMode {
|
|||
MODE_MOVE_MODEL,
|
||||
};
|
||||
|
||||
uint8_t selectMode;
|
||||
enum ModelDeleteMode {
|
||||
MODE_DELETE_MODEL,
|
||||
MODE_DELETE_CATEGORY,
|
||||
};
|
||||
|
||||
uint8_t selectMode, deleteMode;
|
||||
ModelsList modelslist;
|
||||
|
||||
ModelsCategory * currentCategory;
|
||||
|
@ -108,6 +113,7 @@ void onModelSelectMenu(const char * result)
|
|||
else if (result == STR_DELETE_MODEL) {
|
||||
POPUP_CONFIRMATION(STR_DELETEMODEL);
|
||||
SET_WARNING_INFO(currentModel->name, LEN_MODEL_FILENAME, 0);
|
||||
deleteMode = MODE_DELETE_MODEL;
|
||||
}
|
||||
else if (result == STR_CREATE_MODEL) {
|
||||
storageCheck(true);
|
||||
|
@ -141,9 +147,15 @@ void onModelSelectMenu(const char * result)
|
|||
editNameCursorPos = 0;
|
||||
}
|
||||
else if (result == STR_DELETE_CATEGORY) {
|
||||
modelslist.removeCategory(currentCategory);
|
||||
modelslist.save();
|
||||
setCurrentCategory(currentCategoryIndex > 0 ? currentCategoryIndex-1 : currentCategoryIndex);
|
||||
if (currentCategory->size() > 0){
|
||||
POPUP_WARNING(STR_DELETE_ERROR);
|
||||
SET_WARNING_INFO(STR_CAT_NOT_EMPTY, sizeof(TR_CAT_NOT_EMPTY), 0);
|
||||
}
|
||||
else {
|
||||
POPUP_CONFIRMATION(STR_DELETEMODEL);
|
||||
SET_WARNING_INFO(currentCategory->name, LEN_MODEL_FILENAME, 0);
|
||||
deleteMode = MODE_DELETE_CATEGORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,14 +196,22 @@ bool menuModelSelect(event_t event)
|
|||
{
|
||||
if (warningResult) {
|
||||
warningResult = 0;
|
||||
int modelIndex = MODEL_INDEX();
|
||||
modelslist.removeModel(currentCategory, currentModel);
|
||||
s_copyMode = 0;
|
||||
event = EVT_REFRESH;
|
||||
if (modelIndex > 0) {
|
||||
modelIndex--;
|
||||
if (deleteMode == MODE_DELETE_CATEGORY) {
|
||||
TRACE("DELETE CATEGORY");
|
||||
modelslist.removeCategory(currentCategory);
|
||||
modelslist.save();
|
||||
setCurrentCategory(currentCategoryIndex > 0 ? currentCategoryIndex-1 : currentCategoryIndex);
|
||||
}
|
||||
else if (deleteMode == MODE_DELETE_MODEL){
|
||||
int modelIndex = MODEL_INDEX();
|
||||
modelslist.removeModel(currentCategory, currentModel);
|
||||
s_copyMode = 0;
|
||||
event = EVT_REFRESH;
|
||||
if (modelIndex > 0) {
|
||||
modelIndex--;
|
||||
}
|
||||
setCurrentModel(modelIndex);
|
||||
}
|
||||
setCurrentModel(modelIndex);
|
||||
}
|
||||
|
||||
switch(event) {
|
||||
|
|
|
@ -489,6 +489,9 @@ const pm_char STR_MODELS_PATH[] PROGMEM = MODELS_PATH;
|
|||
const pm_char STR_MODELS_EXT[] PROGMEM = MODELS_EXT;
|
||||
#endif
|
||||
|
||||
|
||||
const pm_char STR_DELETE_ERROR[] PROGMEM = TR_DELETE_ERROR;
|
||||
const pm_char STR_CAT_NOT_EMPTY[] PROGMEM = TR_CAT_NOT_EMPTY;
|
||||
const pm_char STR_WARNING[] PROGMEM = TR_WARNING;
|
||||
const pm_char STR_THROTTLEWARN[] PROGMEM = TR_THROTTLEWARN;
|
||||
const pm_char STR_ALARMSWARN[] PROGMEM = TR_ALARMSWARN;
|
||||
|
|
|
@ -698,7 +698,7 @@ extern const pm_char STR_RESET_BTN[];
|
|||
#if defined(SDCARD)
|
||||
extern const pm_char STR_BACKUP_MODEL[];
|
||||
extern const pm_char STR_RESTORE_MODEL[];
|
||||
extern const pm_char STR_SDCARD_ERROR[];
|
||||
extern const pm_char STR_DELETE_ERROR[];
|
||||
extern const pm_char STR_NO_SDCARD[];
|
||||
extern const pm_char STR_SDCARD_FULL[];
|
||||
extern const pm_char STR_INCOMPATIBLE[];
|
||||
|
@ -709,6 +709,8 @@ extern const pm_char STR_RESET_BTN[];
|
|||
#define STR_UPDATE_LIST STR_DELAYDOWN
|
||||
#endif
|
||||
|
||||
extern const pm_char STR_SDCARD_ERROR[];
|
||||
extern const pm_char STR_CAT_NOT_EMPTY[];
|
||||
extern const pm_char STR_WARNING[];
|
||||
extern const pm_char STR_STORAGE_WARNING[];
|
||||
extern const pm_char STR_EEPROM_CONVERTING[];
|
||||
|
|
|
@ -919,6 +919,8 @@
|
|||
#define TR_BACKUP_MODEL "Zálohovat na SD"
|
||||
#define TR_DELETE_MODEL "Smaž model"
|
||||
#define TR_RESTORE_MODEL "Obnov model z SD"
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR "Chyba SD karty"
|
||||
#define TR_NO_SDCARD "Není SD karta"
|
||||
#define TR_SDCARD_FULL "Plná SD karta"
|
||||
|
|
|
@ -922,6 +922,8 @@
|
|||
#define TR_BACKUP_MODEL "Modell auf SD-Karte" //9XR-Pro
|
||||
#define TR_DELETE_MODEL "Modell löschen" // TODO merged into DELETEMODEL?
|
||||
#define TR_RESTORE_MODEL "Modell Restore"
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR "SD-Kartenfehler"
|
||||
#define TR_NO_SDCARD "Keine SD-Karte"
|
||||
#define TR_SDCARD_FULL "SD-Karte voll"
|
||||
|
|
|
@ -888,6 +888,8 @@
|
|||
#define TR_BACKUP_MODEL "Backup model"
|
||||
#define TR_DELETE_MODEL "Delete model"
|
||||
#define TR_RESTORE_MODEL "Restore model"
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR TR("SD error", "SD card error")
|
||||
#define TR_NO_SDCARD "No SD card"
|
||||
#define TR_SDCARD_FULL "SD card full"
|
||||
|
|
|
@ -867,6 +867,8 @@
|
|||
#define TR_BACKUP_MODEL "Copia Sgdad Mod."
|
||||
#define TR_DELETE_MODEL "Borrar Modelo"
|
||||
#define TR_RESTORE_MODEL "Restaurar Modelo"
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR "SDCARD Error"
|
||||
#define TR_NO_SDCARD "No SDCARD"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
|
|
|
@ -867,6 +867,8 @@
|
|||
#define TR_BACKUP_MODEL "Backup Model"
|
||||
#define TR_DELETE_MODEL "Delete Model"
|
||||
#define TR_RESTORE_MODEL "Restore Model"
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR "SDCARD Error"
|
||||
#define TR_NO_SDCARD "No SDCARD"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
|
|
|
@ -899,6 +899,8 @@
|
|||
#define TR_BACKUP_MODEL "Archiver modèle"
|
||||
#define TR_DELETE_MODEL "Supprimer modèle"
|
||||
#define TR_RESTORE_MODEL "Restaurer modèle"
|
||||
#define TR_DELETE_ERROR "Effacement impossible"
|
||||
#define TR_CAT_NOT_EMPTY "Categorie non vide"
|
||||
#define TR_SDCARD_ERROR "Erreur carte SD"
|
||||
#define TR_NO_SDCARD "Carte SD indisponible"
|
||||
#define TR_SDCARD_FULL "Carte SD pleine"
|
||||
|
|
|
@ -902,6 +902,8 @@
|
|||
#define TR_BACKUP_MODEL "Salva Modello"
|
||||
#define TR_DELETE_MODEL TR("Elim. Modello","Elimina Modello") // TODO merged into DELETEMODEL?
|
||||
#define TR_RESTORE_MODEL TR("Ripr. Modello","Ripristina Modello")
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR "Errore SD"
|
||||
#define TR_NO_SDCARD "No SDCARD"
|
||||
#define TR_SDCARD_FULL "SD Card Piena"
|
||||
|
|
|
@ -896,6 +896,8 @@
|
|||
#define TR_BACKUP_MODEL "Backup Model"
|
||||
#define TR_DELETE_MODEL "Wis Model"
|
||||
#define TR_RESTORE_MODEL "Model Terugzetten"
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR "SD-Kaart fout"
|
||||
#define TR_NO_SDCARD "Geen SD-Kaart"
|
||||
#define TR_SDCARD_FULL "SD-Kaart vol"
|
||||
|
|
|
@ -904,6 +904,8 @@
|
|||
#define TR_BACKUP_MODEL "Zbackupuj model"
|
||||
#define TR_DELETE_MODEL "Skasuj model"
|
||||
#define TR_RESTORE_MODEL "Odtwórz model"
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR "Błąd karty SD"
|
||||
#define TR_NO_SDCARD "Brak karty SD"
|
||||
#define TR_SDCARD_FULL "Karta Pełna "
|
||||
|
|
|
@ -862,6 +862,8 @@
|
|||
#define TR_BACKUP_MODEL "Salvar Modelo"
|
||||
#define TR_DELETE_MODEL "Apagar Modelo"
|
||||
#define TR_RESTORE_MODEL "Restaura Modelo"
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR "SDCARD Erro"
|
||||
#define TR_NO_SDCARD "Sem SDCARD"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
|
|
|
@ -915,6 +915,8 @@
|
|||
#define TR_BACKUP_MODEL "Modell-backup"
|
||||
#define TR_DELETE_MODEL "Ta Bort Modell"
|
||||
#define TR_RESTORE_MODEL "Återställ Modell"
|
||||
#define TR_DELETE_ERROR "Delete error"
|
||||
#define TR_CAT_NOT_EMPTY "Category is not empty"
|
||||
#define TR_SDCARD_ERROR "SDCARD-fel"
|
||||
#define TR_NO_SDCARD "SDCARD saknas"
|
||||
#define TR_SDCARD_FULL "SD-kort Fullt"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue