From 052bd016a0dbfdee6e609e95be68630c184d4c09 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 16 Apr 2026 16:53:18 +0200 Subject: [PATCH] Change Labels for Webui --- src/SettingsList.h | 27 +++++++++++-------- src/activities/ActivityManager.cpp | 4 +++ src/activities/ActivityManager.h | 2 +- src/activities/home/HomeActivity.cpp | 12 ++++++--- .../network/CrossPointWebServerActivity.cpp | 1 + 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/SettingsList.h b/src/SettingsList.h index f108e2ec..439539ca 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -134,18 +134,29 @@ inline const std::vector list = { StrId::STR_CAT_SYSTEM), SettingInfo::Toggle(StrId::STR_SHOW_FILE_EXTENSIONS, &CrossPointSettings::showFileExtensions, "showFileExtensions", StrId::STR_CAT_SYSTEM), + + // Will be dealt with separately , so do receive none of the main categories to be visible in the web UI but not the + // device UI + SettingInfo::Toggle(StrId::STR_USE_CLOCK, &CrossPointSettings::useClock, "useClock", StrId::STR_CLOCK), SettingInfo::Enum(StrId::STR_CLOCK_FORMAT, &CrossPointSettings::clockFormat12h, {StrId::STR_24H, StrId::STR_12H}, - "clockFormat12h", StrId::STR_CAT_SYSTEM), + "clockFormat12h", StrId::STR_CLOCK), SettingInfo::Enum(StrId::STR_TIMEZONE, &CrossPointSettings::timeZone, {StrId::STR_TZ_UTC, StrId::STR_TZ_CET, StrId::STR_TZ_EET, StrId::STR_TZ_MSK, StrId::STR_TZ_UTC_PLUS4, StrId::STR_TZ_IST, StrId::STR_TZ_UTC_PLUS7, StrId::STR_TZ_UTC_PLUS8, StrId::STR_TZ_UTC_PLUS9, StrId::STR_TZ_AEST, StrId::STR_TZ_NZST, StrId::STR_TZ_UTC_MINUS3, StrId::STR_TZ_EST, StrId::STR_TZ_CST, StrId::STR_TZ_MST, StrId::STR_TZ_PST}, - "timeZone", StrId::STR_CAT_SYSTEM), - SettingInfo::Toggle(StrId::STR_USE_CLOCK, &CrossPointSettings::useClock, "useClock", StrId::STR_CAT_SYSTEM), - SettingInfo::Toggle(StrId::STR_USE_WEATHER, &CrossPointSettings::useWeather, "useWeather", StrId::STR_CAT_SYSTEM), + "timeZone", StrId::STR_CLOCK), + // Weather + SettingInfo::Toggle(StrId::STR_USE_WEATHER, &CrossPointSettings::useWeather, "useWeather", StrId::STR_WEATHER), // --- KOReader Sync (web-only, uses KOReaderCredentialStore) --- + SettingInfo::DynamicString( + StrId::STR_SYNC_SERVER_URL, [] { return KOREADER_STORE.getServerUrl(); }, + [](const std::string& v) { + KOREADER_STORE.setServerUrl(v); + KOREADER_STORE.saveToFile(); + }, + "koServerUrl", StrId::STR_KOREADER_SYNC), SettingInfo::DynamicString( StrId::STR_KOREADER_USERNAME, [] { return KOREADER_STORE.getUsername(); }, [](const std::string& v) { @@ -161,13 +172,6 @@ inline const std::vector list = { }, "koPassword", StrId::STR_KOREADER_SYNC) .withObfuscated(), - SettingInfo::DynamicString( - StrId::STR_SYNC_SERVER_URL, [] { return KOREADER_STORE.getServerUrl(); }, - [](const std::string& v) { - KOREADER_STORE.setServerUrl(v); - KOREADER_STORE.saveToFile(); - }, - "koServerUrl", StrId::STR_KOREADER_SYNC), SettingInfo::DynamicEnum( StrId::STR_DOCUMENT_MATCHING, {StrId::STR_FILENAME, StrId::STR_BINARY}, [] { return static_cast(KOREADER_STORE.getMatchMethod()); }, @@ -185,6 +189,7 @@ inline const std::vector list = { SettingInfo::String(StrId::STR_PASSWORD, SETTINGS.opdsPassword, sizeof(SETTINGS.opdsPassword), "opdsPassword", StrId::STR_OPDS_BROWSER) .withObfuscated(), + // --- Status Bar Settings (web-only, uses StatusBarSettingsActivity) --- SettingInfo::Toggle(StrId::STR_CHAPTER_PAGE_COUNT, &CrossPointSettings::statusBarChapterPageCount, "statusBarChapterPageCount", StrId::STR_CUSTOMISE_STATUS_BAR), diff --git a/src/activities/ActivityManager.cpp b/src/activities/ActivityManager.cpp index 08dc0386..d1c0da40 100644 --- a/src/activities/ActivityManager.cpp +++ b/src/activities/ActivityManager.cpp @@ -177,7 +177,9 @@ void ActivityManager::loop() { } if (requestedUpdate) { + taskENTER_CRITICAL(nullptr); requestedUpdate = false; + taskEXIT_CRITICAL(nullptr); // Using direct notification to signal the render task to update // Increment counter so multiple rapid calls won't be lost if (renderTaskHandle) { @@ -299,7 +301,9 @@ void ActivityManager::requestUpdate(bool immediate) { } else { // Deferring the update until current loop is finished // This is to avoid multiple updates being requested in the same loop + taskENTER_CRITICAL(nullptr); requestedUpdate = true; + taskEXIT_CRITICAL(nullptr); } } void ActivityManager::requestUpdateAndWait() { diff --git a/src/activities/ActivityManager.h b/src/activities/ActivityManager.h index b09f968c..b59f6e96 100644 --- a/src/activities/ActivityManager.h +++ b/src/activities/ActivityManager.h @@ -60,7 +60,7 @@ class ActivityManager { // Whether to trigger a render after the current loop() // This variable must only be set by the main loop, to avoid race conditions - bool requestedUpdate = false; + volatile bool requestedUpdate = false; // When true, input events are consumed (discarded) until all buttons are released // and no press/release events remain. Armed automatically on activity transitions diff --git a/src/activities/home/HomeActivity.cpp b/src/activities/home/HomeActivity.cpp index a010c778..e8cd0d91 100644 --- a/src/activities/home/HomeActivity.cpp +++ b/src/activities/home/HomeActivity.cpp @@ -345,13 +345,17 @@ void HomeActivity::render(RenderLock&&) { } if (hasOpdsUrl) { - // Insert OPDS Browser after Recents (and Global Bookmarks if present) menuItems.insert(menuItems.begin() + insertAfterRecents, tr(STR_OPDS_BROWSER)); menuIcons.insert(menuIcons.begin() + insertAfterRecents, Library); } - const HomeScreenLayout layout = - computeHomeScreenLayout(metrics, contentRect.height, static_cast(menuItems.size())); + const int totalItems = static_cast(recentBooks.size() + menuItems.size()); + if (selectorIndex >= totalItems) { + selectorIndex = std::max(0, totalItems - 1); + } + + const int menuCount = static_cast(menuItems.size()); + const HomeScreenLayout layout = computeHomeScreenLayout(metrics, contentRect.height, menuCount); GUI.drawRecentBookCover(renderer, Rect{contentRect.x, metrics.homeTopPadding, contentRect.width, layout.recentTileHeight}, @@ -362,7 +366,7 @@ void HomeActivity::render(RenderLock&&) { renderer, Rect{contentRect.x, metrics.homeTopPadding + layout.recentTileHeight + layout.recentToMenuGap, contentRect.width, layout.menuHeight}, - static_cast(menuItems.size()), selectorIndex - recentBooks.size(), + menuCount, selectorIndex - static_cast(recentBooks.size()), [&menuItems](int index) { return std::string(menuItems[index]); }, [&menuIcons](int index) { return menuIcons[index]; }); diff --git a/src/activities/network/CrossPointWebServerActivity.cpp b/src/activities/network/CrossPointWebServerActivity.cpp index 03dec966..335cd0f4 100644 --- a/src/activities/network/CrossPointWebServerActivity.cpp +++ b/src/activities/network/CrossPointWebServerActivity.cpp @@ -96,6 +96,7 @@ void CrossPointWebServerActivity::onExit() { } LOG_DBG("WEBACT", "Free heap at onExit end: %d bytes", ESP.getFreeHeap()); + requestUpdate(); } void CrossPointWebServerActivity::onNetworkModeSelected(const NetworkMode mode) {