Fix lost font selector

This commit is contained in:
jpirnay
2026-05-15 00:14:27 +02:00
parent 25e1a64eb8
commit b11ba14af3
5 changed files with 43 additions and 39 deletions
+4 -2
View File
@@ -100,7 +100,8 @@ inline const std::vector<SettingInfo> list = {
SettingInfo::DynamicEnum(StrId::STR_FONT_FAMILY, {StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS},
fontFamilyDynamicGetter, fontFamilyDynamicSetter, "fontFamily", StrId::STR_CAT_READER)
.withSubcategory(StrId::STR_MENU_READER_FONT)
.withSubmenu(StrId::STR_MENU_READER_FONT),
.withSubmenu(StrId::STR_MENU_READER_FONT)
.withSelectorActivity(),
SettingInfo::Enum(StrId::STR_FONT_SIZE, &CrossPointSettings::fontSize,
{StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE, StrId::STR_TINY},
"fontSize", StrId::STR_CAT_READER)
@@ -116,7 +117,8 @@ inline const std::vector<SettingInfo> list = {
SettingInfo::DynamicEnum(StrId::STR_TXT_FONT_FAMILY, {StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS},
txtFontFamilyDynamicGetter, txtFontFamilyDynamicSetter, "txtFontFamily",
StrId::STR_CAT_READER)
.withSubmenu(StrId::STR_MENU_TXT_FONT),
.withSubmenu(StrId::STR_MENU_TXT_FONT)
.withSelectorActivity(),
SettingInfo::Enum(StrId::STR_TXT_FONT_SIZE, &CrossPointSettings::txtFontSize,
{StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE, StrId::STR_TINY},
"txtFontSize", StrId::STR_CAT_READER)
+9
View File
@@ -221,9 +221,18 @@ struct SettingInfo {
}
bool isSeparator = false;
bool usesSelectorActivity = false; // Confirm opens a full-screen selector instead of inline cycling
StrId subcategory = StrId::STR_NONE_OPT; // Triggers a separator row on first use and on change
StrId submenu = StrId::STR_NONE_OPT; // Routes item into a submenu; hidden from main list
// Marks this entry as requiring a full-screen selector activity on Confirm
// (instead of inline value cycling). The SettingsActivity / SettingsSubmenuActivity
// intercept entries with this flag before toggleValue() is called.
SettingInfo& withSelectorActivity() {
usesSelectorActivity = true;
return *this;
}
// Inserts a separator row in the parent tab when this item's subcategory first appears or changes.
SettingInfo& withSubcategory(StrId sub) {
subcategory = sub;
+8 -17
View File
@@ -278,23 +278,14 @@ void SettingsActivity::toggleCurrentSetting() {
const auto& setting = (*currentSettings)[selectedSetting];
if (setting.isSeparator) return;
if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_FONT_FAMILY) {
startActivityForResult(
std::make_unique<FontSelectionActivity>(renderer, mappedInput, FontSelectionActivity::Target::EPUB),
[this](const ActivityResult&) {
SETTINGS.saveToFile();
needsHalfRefresh = true;
});
return;
}
if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_TXT_FONT_FAMILY) {
startActivityForResult(
std::make_unique<FontSelectionActivity>(renderer, mappedInput, FontSelectionActivity::Target::TXT),
[this](const ActivityResult&) {
SETTINGS.saveToFile();
needsHalfRefresh = true;
});
if (setting.usesSelectorActivity) {
const auto target = (setting.valueGetter == txtFontFamilyDynamicGetter) ? FontSelectionActivity::Target::TXT
: FontSelectionActivity::Target::EPUB;
startActivityForResult(std::make_unique<FontSelectionActivity>(renderer, mappedInput, target),
[this](const ActivityResult&) {
SETTINGS.saveToFile();
needsHalfRefresh = true;
});
return;
}
@@ -8,6 +8,7 @@
#include "CrossPointSettings.h"
#include "FontSelectionActivity.h"
#include "MappedInputManager.h"
#include "SdCardFontGlobals.h"
#include "SettingActionDispatch.h"
#include "components/UITheme.h"
#include "fontIds.h"
@@ -23,26 +24,6 @@ void SettingsSubmenuActivity::onActionSelected(int index) {
const auto& setting = menuItems[index];
if (setting.isSeparator) return;
if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_FONT_FAMILY) {
startActivityForResult(
std::make_unique<FontSelectionActivity>(renderer, mappedInput, FontSelectionActivity::Target::EPUB),
[this](const ActivityResult&) {
SETTINGS.saveToFile();
needsHalfRefresh = true;
});
return;
}
if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_TXT_FONT_FAMILY) {
startActivityForResult(
std::make_unique<FontSelectionActivity>(renderer, mappedInput, FontSelectionActivity::Target::TXT),
[this](const ActivityResult&) {
SETTINGS.saveToFile();
needsHalfRefresh = true;
});
return;
}
if (setting.type == SettingType::ACTION) {
MenuResult menuResult;
if (setting.action != SettingAction::None) {
@@ -69,6 +50,26 @@ std::string SettingsSubmenuActivity::getItemValueString(int index) const {
return MenuListActivity::getItemValueString(index);
}
void SettingsSubmenuActivity::toggleCurrentItem() {
if (selectedIndex < 0 || selectedIndex >= static_cast<int>(menuItems.size())) return;
const auto& setting = menuItems[selectedIndex];
if (setting.isSeparator) return;
if (setting.usesSelectorActivity) {
const auto target = (setting.valueGetter == txtFontFamilyDynamicGetter) ? FontSelectionActivity::Target::TXT
: FontSelectionActivity::Target::EPUB;
startActivityForResult(std::make_unique<FontSelectionActivity>(renderer, mappedInput, target),
[this](const ActivityResult&) {
SETTINGS.saveToFile();
needsHalfRefresh = true;
requestUpdate();
});
return;
}
MenuListActivity::toggleCurrentItem();
}
void SettingsSubmenuActivity::onSettingToggled(int /*index*/) { SETTINGS.saveToFile(); }
void SettingsSubmenuActivity::render(RenderLock&&) {
@@ -16,6 +16,7 @@ class SettingsSubmenuActivity final : public MenuListActivity {
// MenuListActivity overrides
void onEnter() override;
void toggleCurrentItem() override;
void onActionSelected(int index) override;
void onSettingToggled(int index) override;
std::string getItemValueString(int index) const override;