From 54d0222c537d218addd446e95a9fa70f9e948810 Mon Sep 17 00:00:00 2001 From: philmoz Date: Tue, 7 Mar 2023 12:58:06 +1100 Subject: [PATCH] chore(color): LVGL update, translation strings for theme file carousel (#3278) * Use StaticText instead of 'paint' function for 'loading' message in theme file carousel, Add message strings to translation files. * Update translation. * Update translation. * Update translation. * Update translation. * Update translation. * Update translation. * Update translation. --- radio/src/gui/colorlcd/file_carosell.cpp | 46 ++++++++++-------------- radio/src/gui/colorlcd/file_carosell.h | 4 +-- radio/src/translations.cpp | 1 + radio/src/translations.h | 1 + radio/src/translations/cn.h | 3 +- radio/src/translations/cz.h | 3 +- radio/src/translations/da.h | 3 +- radio/src/translations/de.h | 3 +- radio/src/translations/en.h | 1 + radio/src/translations/es.h | 1 + radio/src/translations/fi.h | 1 + radio/src/translations/fr.h | 1 + radio/src/translations/it.h | 3 +- radio/src/translations/jp.h | 3 +- radio/src/translations/nl.h | 1 + radio/src/translations/pl.h | 1 + radio/src/translations/pt.h | 1 + radio/src/translations/se.h | 1 + radio/src/translations/tw.h | 3 +- 19 files changed, 43 insertions(+), 38 deletions(-) diff --git a/radio/src/gui/colorlcd/file_carosell.cpp b/radio/src/gui/colorlcd/file_carosell.cpp index 4a527817f..41e1869ce 100644 --- a/radio/src/gui/colorlcd/file_carosell.cpp +++ b/radio/src/gui/colorlcd/file_carosell.cpp @@ -25,8 +25,6 @@ extern inline tmr10ms_t getTicks() return g_tmr10ms; } - - FileCarosell::FileCarosell(Window *parent, const rect_t &rect, std::vector fileNames) : FormGroup(parent, rect, NO_FOCUS | FORM_NO_BORDER), @@ -34,13 +32,10 @@ FileCarosell::FileCarosell(Window *parent, const rect_t &rect, fp(new FilePreview(this, {0, 0, rect.w, rect.h}, false)) { timer = getTicks(); + message = new StaticText(this, {0, rect.h/2, rect.w, PAGE_LINE_HEIGHT}, "", 0, CENTERED | FONT(L) | COLOR_THEME_PRIMARY1); setSelected(0); } -FileCarosell::~FileCarosell() -{ -} - void FileCarosell::setFileNames(std::vector fileNames) { _fileNames = fileNames; @@ -51,23 +46,20 @@ void FileCarosell::setFileNames(std::vector fileNames) void FileCarosell::setSelected(int n) { - if (n == selected) return; + if (n != selected) { + selected = n; + + if (n >= 0 && n < (int)_fileNames.size()) { + fp->setFile(_fileNames[selected].c_str()); + } else + fp->setFile(""); + } - selected = n; - - if (n >= 0 && n < (int)_fileNames.size()) { - fp->setFile(_fileNames[selected].c_str()); - } else - fp->setFile(""); -} - -void FileCarosell::paint(BitmapBuffer *dc) -{ - if (selected == -1 || _fileNames.size() == 0) { - const char *message = selected == -1 && _fileNames.size() > 0 - ? "Loading..." - : "No theme image"; - dc->drawText(width() / 2, height() / 2, message, FONT(L) + CENTERED); + if (selected == -1) { + lv_obj_clear_flag(message->getLvObj(), LV_OBJ_FLAG_HIDDEN); + message->setText(_fileNames.size() > 0 ? STR_LOADING : STR_NO_THEME_IMAGE); + } else { + lv_obj_add_flag(message->getLvObj(), LV_OBJ_FLAG_HIDDEN); } } @@ -75,15 +67,13 @@ void FileCarosell::checkEvents() { FormGroup::checkEvents(); + uint32_t newTicks = getTicks(); + // if we are paused then just update time. we will begin the carosell after // timeout period once unpaused if (_paused) { - timer = getTicks(); - return; - } - - uint32_t newTicks = getTicks(); - if (newTicks - timer > pageInterval && _fileNames.size()) { + timer = newTicks; + } else if (newTicks - timer > pageInterval && _fileNames.size()) { int newSelected = (selected + 1) % _fileNames.size(); setSelected(newSelected); timer = newTicks; diff --git a/radio/src/gui/colorlcd/file_carosell.h b/radio/src/gui/colorlcd/file_carosell.h index 0fe4cebb9..e5006a9b3 100644 --- a/radio/src/gui/colorlcd/file_carosell.h +++ b/radio/src/gui/colorlcd/file_carosell.h @@ -32,7 +32,6 @@ class FileCarosell : public FormGroup public: FileCarosell(Window *parent, const rect_t &rect, std::vector fileNames); - ~FileCarosell(); inline void setSelected(int n); void setFileNames(std::vector fileNames); @@ -42,8 +41,6 @@ class FileCarosell : public FormGroup _paused = pause; } - void paint(BitmapBuffer *dc) override; - protected: bool _paused = false; int selected = -1; @@ -51,4 +48,5 @@ class FileCarosell : public FormGroup FilePreview *fp; uint32_t timer; uint32_t pageInterval = PAGE_INTERVAL; + StaticText* message; }; diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 813035df1..ad397ecea 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -724,6 +724,7 @@ const char STR_LOADING[] = TR_LOADING; const char STR_DELETE_THEME[] = TR_DELETE_THEME; const char STR_SAVE_THEME[] = TR_SAVE_THEME; const char STR_EDIT_COLOR[] = TR_EDIT_COLOR; +const char STR_NO_THEME_IMAGE[] = TR_NO_THEME_IMAGE; #endif #if !defined(COLORLCD) diff --git a/radio/src/translations.h b/radio/src/translations.h index eeb2c784a..50df14f0a 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -745,6 +745,7 @@ extern const char STR_LOADING[]; extern const char STR_DELETE_THEME[]; extern const char STR_SAVE_THEME[]; extern const char STR_EDIT_COLOR[]; +extern const char STR_NO_THEME_IMAGE[]; #endif extern const char STR_EXECUTE_FILE[]; extern const char STR_DELETE_FILE[]; diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index 768c81301..81ae821bb 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -742,7 +742,8 @@ #define TR_LOADING "加载中..." #define TR_DELETE_THEME "删除主题?" #define TR_SAVE_THEME "保存主题?" -#define TR_EDIT_COLOR "Edit Color" +#define TR_EDIT_COLOR "编辑颜色" +#define TR_NO_THEME_IMAGE "没有预览图" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "快速选择模型" diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index 0f3cc2d7a..5ba87d862 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -742,7 +742,8 @@ #define TR_LOADING "Načítání..." #define TR_DELETE_THEME "Smazat motiv?" #define TR_SAVE_THEME "Uložit motiv?" -#define TR_EDIT_COLOR "Edit Color" +#define TR_EDIT_COLOR "Upravit barvu" +#define TR_NO_THEME_IMAGE "Náhled motivu nedostupný" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Rychlý výběr modelu" diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index 403767e1f..3aeb958f9 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -748,7 +748,8 @@ #define TR_LOADING "Indlæser..." #define TR_DELETE_THEME "Slet tema?" #define TR_SAVE_THEME "Gem tema?" -#define TR_EDIT_COLOR "Edit Color" +#define TR_EDIT_COLOR "Rediger farve" +#define TR_NO_THEME_IMAGE "Ingen billede for tema" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Hurtigvalg af model" diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index 6bb84b4c7..e125ff945 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -740,7 +740,8 @@ #define TR_LOADING "Wird geladen..." #define TR_DELETE_THEME "Theme löschen?" #define TR_SAVE_THEME "Theme speichern?" -#define TR_EDIT_COLOR "Edit Color" +#define TR_EDIT_COLOR "Farbe bearbeiten" +#define TR_NO_THEME_IMAGE "Kein Theme Bild" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "schnelle Modellauswahl" diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index b86a3d446..c448dce1d 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -742,6 +742,7 @@ #define TR_DELETE_THEME "Delete Theme?" #define TR_SAVE_THEME "Save Theme?" #define TR_EDIT_COLOR "Edit Color" +#define TR_NO_THEME_IMAGE "No theme image" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Model quick select" diff --git a/radio/src/translations/es.h b/radio/src/translations/es.h index 0196bb585..f0d64d394 100644 --- a/radio/src/translations/es.h +++ b/radio/src/translations/es.h @@ -743,6 +743,7 @@ #define TR_DELETE_THEME "Delete Theme?" #define TR_SAVE_THEME "Save Theme?" #define TR_EDIT_COLOR "Edit Color" +#define TR_NO_THEME_IMAGE "No theme image" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Model quick select" diff --git a/radio/src/translations/fi.h b/radio/src/translations/fi.h index 44ce7bc7b..22b414d38 100644 --- a/radio/src/translations/fi.h +++ b/radio/src/translations/fi.h @@ -755,6 +755,7 @@ #define TR_DELETE_THEME "Delete Theme?" #define TR_SAVE_THEME "Save Theme?" #define TR_EDIT_COLOR "Edit Color" +#define TR_NO_THEME_IMAGE "No theme image" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Mallin pikavalinta" diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index ee0e41037..dc3ac26f4 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -752,6 +752,7 @@ #define TR_DELETE_THEME "Delete Theme?" #define TR_SAVE_THEME "Save Theme?" #define TR_EDIT_COLOR "Edit Color" +#define TR_NO_THEME_IMAGE "No theme image" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Model quick select" diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index 7ead09d0b..6662dcb2f 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -743,7 +743,8 @@ #define TR_LOADING "Caricamento..." #define TR_DELETE_THEME "Cancello Tema?" #define TR_SAVE_THEME "Salvo Tema?" -#define TR_EDIT_COLOR "Edit Color" +#define TR_EDIT_COLOR "Edita colore" +#define TR_NO_THEME_IMAGE "Nessuna immagine trovata" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Selezione veloce modello" diff --git a/radio/src/translations/jp.h b/radio/src/translations/jp.h index 806a105d5..c5276d2e8 100644 --- a/radio/src/translations/jp.h +++ b/radio/src/translations/jp.h @@ -742,7 +742,8 @@ #define TR_LOADING "読み込み中..." #define TR_DELETE_THEME "テーマを削除しますか?" #define TR_SAVE_THEME "テーマを保存しますか?" -#define TR_EDIT_COLOR "Edit Color" +#define TR_EDIT_COLOR "カラー編集" +#define TR_NO_THEME_IMAGE "テーマ画像はありません" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "モデル クイックセレクト" diff --git a/radio/src/translations/nl.h b/radio/src/translations/nl.h index 116801d33..52334fe24 100644 --- a/radio/src/translations/nl.h +++ b/radio/src/translations/nl.h @@ -747,6 +747,7 @@ #define TR_DELETE_THEME "Delete Theme?" #define TR_SAVE_THEME "Save Theme?" #define TR_EDIT_COLOR "Edit Color" +#define TR_NO_THEME_IMAGE "No theme image" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Model quick select" diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index 93694eb5a..28032d198 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -740,6 +740,7 @@ #define TR_DELETE_THEME "Usunąć motyw?" #define TR_SAVE_THEME "Zapisać motyw?" #define TR_EDIT_COLOR "Edit Color" +#define TR_NO_THEME_IMAGE "No theme image" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Szybki wybór modelu" diff --git a/radio/src/translations/pt.h b/radio/src/translations/pt.h index 5f10712ad..b1bec2054 100644 --- a/radio/src/translations/pt.h +++ b/radio/src/translations/pt.h @@ -747,6 +747,7 @@ #define TR_DELETE_THEME "Delete Theme?" #define TR_SAVE_THEME "Save Theme?" #define TR_EDIT_COLOR "Edit Color" +#define TR_NO_THEME_IMAGE "No theme image" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Model quick select" diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index cd0d4e524..2d0500acb 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -764,6 +764,7 @@ #define TR_DELETE_THEME "Radera tema?" #define TR_SAVE_THEME "Spara tema?" #define TR_EDIT_COLOR "Edit Color" +#define TR_NO_THEME_IMAGE "Ingen temabild" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "Snabbval av modell" diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index baef797ec..1d724d768 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -741,7 +741,8 @@ #define TR_LOADING "加載中..." #define TR_DELETE_THEME "刪除主題?" #define TR_SAVE_THEME "保存主題?" -#define TR_EDIT_COLOR "Edit Color" +#define TR_EDIT_COLOR "编辑颜色" +#define TR_NO_THEME_IMAGE "没有预览图" #if defined(COLORLCD) #define TR_MODEL_QUICK_SELECT "快速選擇模型"