ui: use "palette" wording instead of theme as much as possible

This commit is contained in:
Lemmy
2026-05-10 00:57:23 -04:00
parent acfe9d5109
commit 7de0769677
7 changed files with 41 additions and 41 deletions
+5 -5
View File
@@ -1156,13 +1156,13 @@
"label": "Theme Mode",
"description": "Choose dark, light, or auto based on time of day"
},
"theme-source": {
"label": "Theme Source",
"palette-source": {
"label": "Palette Source",
"description": "Where to derive the color palette from"
},
"theme-palette": {
"label": "Theme Palette",
"description": "Choose the bundled palette used for built-in themes"
"builtin-palette": {
"label": "Builtin Palette",
"description": "Choose a palette from the bundled catalog"
},
"wallpaper-generation-scheme": {
"label": "Wallpaper Generation Scheme",
+1 -1
View File
@@ -1279,7 +1279,7 @@ void ConfigService::parseTableInto(const toml::table& tbl, Config& config, bool
if (auto* themeTbl = tbl["theme"].as_table()) {
auto& theme = config.theme;
if (auto v = (*themeTbl)["source"].value<std::string>()) {
if (auto parsed = enumFromKey(kThemeSources, *v)) {
if (auto parsed = enumFromKey(kPaletteSources, *v)) {
theme.source = *parsed;
}
}
+7 -7
View File
@@ -546,18 +546,18 @@ struct HooksConfig {
std::optional<HookKind> hookKindFromKey(std::string_view key);
std::string_view hookKindKey(HookKind kind);
enum class ThemeSource : std::uint8_t {
enum class PaletteSource : std::uint8_t {
Builtin = 0,
Wallpaper = 1,
Community = 2,
Custom = 3,
};
constexpr EnumOption<ThemeSource> kThemeSources[] = {
{ThemeSource::Builtin, "builtin", "settings.options.theme.source.built-in"},
{ThemeSource::Wallpaper, "wallpaper", "settings.options.theme.source.wallpaper"},
{ThemeSource::Community, "community", "settings.options.theme.source.community"},
{ThemeSource::Custom, "custom", "settings.options.theme.source.custom"},
constexpr EnumOption<PaletteSource> kPaletteSources[] = {
{PaletteSource::Builtin, "builtin", "settings.options.theme.source.built-in"},
{PaletteSource::Wallpaper, "wallpaper", "settings.options.theme.source.wallpaper"},
{PaletteSource::Community, "community", "settings.options.theme.source.community"},
{PaletteSource::Custom, "custom", "settings.options.theme.source.custom"},
};
enum class ThemeMode : std::uint8_t {
@@ -584,7 +584,7 @@ struct ThemeConfig {
bool operator==(const TemplatesConfig&) const = default;
};
ThemeSource source = ThemeSource::Builtin;
PaletteSource source = PaletteSource::Builtin;
std::string builtinPalette = "Noctalia";
std::string communityPalette = "Oxocarbon";
std::string customPalette;
+9 -9
View File
@@ -248,20 +248,20 @@ namespace settings {
entries.push_back(makeEntry("appearance", "theme", tr("settings.schema.appearance.theme-mode.label"),
tr("settings.schema.appearance.theme-mode.description"), {"theme", "mode"},
asSegmented(enumSelect(kThemeModes, cfg.theme.mode)), "dark light auto colors"));
entries.push_back(makeEntry("appearance", "theme", tr("settings.schema.appearance.theme-source.label"),
tr("settings.schema.appearance.theme-source.description"), {"theme", "source"},
asSegmented(enumSelect(kThemeSources, cfg.theme.source)), "palette colors"));
if (cfg.theme.source == ThemeSource::Builtin) {
entries.push_back(makeEntry("appearance", "theme", tr("settings.schema.appearance.theme-palette.label"),
tr("settings.schema.appearance.theme-palette.description"), {"theme", "builtin"},
entries.push_back(makeEntry("appearance", "theme", tr("settings.schema.appearance.palette-source.label"),
tr("settings.schema.appearance.palette-source.description"), {"theme", "source"},
asSegmented(enumSelect(kPaletteSources, cfg.theme.source)), "palette colors"));
if (cfg.theme.source == PaletteSource::Builtin) {
entries.push_back(makeEntry("appearance", "theme", tr("settings.schema.appearance.builtin-palette.label"),
tr("settings.schema.appearance.builtin-palette.description"), {"theme", "builtin"},
builtinPaletteSelect(cfg.theme.builtinPalette), "builtin palette colors"));
} else if (cfg.theme.source == ThemeSource::Wallpaper) {
} else if (cfg.theme.source == PaletteSource::Wallpaper) {
entries.push_back(makeEntry("appearance", "theme",
tr("settings.schema.appearance.wallpaper-generation-scheme.label"),
tr("settings.schema.appearance.wallpaper-generation-scheme.description"),
{"theme", "wallpaper_scheme"}, wallpaperSchemeSelect(cfg.theme.wallpaperScheme),
"wallpaper palette generator scheme material you m3 colors"));
} else if (cfg.theme.source == ThemeSource::Community) {
} else if (cfg.theme.source == PaletteSource::Community) {
SettingControl communityPaletteControl = TextSetting{cfg.theme.communityPalette, "Oxocarbon"};
if (!env.communityPalettes.empty()) {
communityPaletteControl = SearchPickerSetting{
@@ -276,7 +276,7 @@ namespace settings {
tr("settings.schema.appearance.community-palette.description"),
{"theme", "community_palette"}, std::move(communityPaletteControl),
"community palette colors"));
} else if (cfg.theme.source == ThemeSource::Custom) {
} else if (cfg.theme.source == PaletteSource::Custom) {
SettingControl customPaletteControl = TextSetting{cfg.theme.customPalette, ""};
if (!env.customPalettes.empty()) {
customPaletteControl = SearchPickerSetting{
+13 -13
View File
@@ -38,7 +38,7 @@ namespace {
std::string_view value;
};
constexpr SelectOption kSetupThemeSources[] = {
constexpr SelectOption kSetupPaletteSources[] = {
{"settings.options.theme.source.built-in", "builtin"},
{"settings.options.theme.source.wallpaper", "wallpaper"},
};
@@ -55,7 +55,7 @@ namespace {
{"theme.scheme.muted", "muted"},
};
constexpr std::string_view kDefaultThemeSource = "builtin";
constexpr std::string_view kDefaultPaletteSource = "builtin";
constexpr std::string_view kDefaultBuiltinPalette = "Noctalia";
std::unique_ptr<Label> makeLabel(std::string_view text, float fontSize, const ColorSpec& color, bool bold = false) {
@@ -302,28 +302,28 @@ void SetupWizardPanel::create() {
// Theme source row
{
auto row = makeRow(scale);
auto label = makeLabel(i18n::tr("settings.schema.appearance.theme-source.label"), Style::fontSizeBody * scale,
auto label = makeLabel(i18n::tr("settings.schema.appearance.palette-source.label"), Style::fontSizeBody * scale,
colorSpecFromRole(ColorRole::OnSurface));
label->setFlexGrow(1.0f);
row->addChild(std::move(label));
auto select = std::make_unique<Select>();
select->setOptions(labelsFromOptions(kSetupThemeSources));
m_themeSource = ThemeSource::Builtin;
select->setOptions(labelsFromOptions(kSetupPaletteSources));
m_paletteSource = PaletteSource::Builtin;
m_builtinPalette = std::string(kDefaultBuiltinPalette);
m_config->setOverride({"theme", "source"}, std::string(kDefaultThemeSource));
m_config->setOverride({"theme", "source"}, std::string(kDefaultPaletteSource));
m_config->setOverride({"theme", "builtin"}, m_builtinPalette);
select->setSelectedIndex(selectedOptionIndex(kSetupThemeSources, kDefaultThemeSource));
select->setSelectedIndex(selectedOptionIndex(kSetupPaletteSources, kDefaultPaletteSource));
select->setFontSize(Style::fontSizeBody * scale);
select->setControlHeight(Style::controlHeight * scale);
select->setHorizontalPadding(Style::spaceMd * scale);
select->setMinWidth(220.0f * scale);
select->setOnSelectionChanged([this](std::size_t index, std::string_view /*label*/) {
if (index >= std::size(kSetupThemeSources)) {
if (index >= std::size(kSetupPaletteSources)) {
return;
}
const std::string source(kSetupThemeSources[index].value);
m_themeSource = source == "wallpaper" ? ThemeSource::Wallpaper : ThemeSource::Builtin;
const std::string source(kSetupPaletteSources[index].value);
m_paletteSource = source == "wallpaper" ? PaletteSource::Wallpaper : PaletteSource::Builtin;
m_config->setOverride({"theme", "source"}, source);
configureThemeOptionSelect();
});
@@ -407,7 +407,7 @@ void SetupWizardPanel::configureThemeOptionSelect() {
m_themeOptionSelect->setOnSelectionChanged(nullptr);
const auto& cfg = m_config->config();
if (m_themeSource == ThemeSource::Wallpaper) {
if (m_paletteSource == PaletteSource::Wallpaper) {
m_themeOptionLabel->setText(i18n::tr("setup-wizard.wallpaper-scheme"));
m_themeOptionSelect->setOptions(labelsFromOptions(kWallpaperSchemes));
m_themeOptionSelect->setSelectedIndex(selectedOptionIndex(kWallpaperSchemes, cfg.theme.wallpaperScheme));
@@ -440,8 +440,8 @@ void SetupWizardPanel::commit() {
if (m_telemetryToggle != nullptr) {
m_config->setOverride({"shell", "telemetry_enabled"}, m_telemetryToggle->checked());
}
if (m_themeSource == ThemeSource::Builtin) {
m_config->setOverride({"theme", "source"}, std::string(kDefaultThemeSource));
if (m_paletteSource == PaletteSource::Builtin) {
m_config->setOverride({"theme", "source"}, std::string(kDefaultPaletteSource));
m_config->setOverride({"theme", "builtin"},
m_builtinPalette.empty() ? std::string(kDefaultBuiltinPalette) : m_builtinPalette);
}
+2 -2
View File
@@ -14,7 +14,7 @@ class Renderer;
class Select;
class Toggle;
class WaylandConnection;
enum class ThemeSource : std::uint8_t;
enum class PaletteSource : std::uint8_t;
class SetupWizardPanel : public Panel {
public:
@@ -48,7 +48,7 @@ private:
Label* m_themeOptionLabel = nullptr;
Select* m_themeOptionSelect = nullptr;
Label* m_wallpaperLabel = nullptr;
ThemeSource m_themeSource{};
PaletteSource m_paletteSource{};
bool m_configuringThemeOptionSelect = false;
std::string m_builtinPalette;
std::string m_wallpaperDir;
+4 -4
View File
@@ -267,7 +267,7 @@ namespace noctalia::theme {
void ThemeService::onConfigReload() { resolveAndSet(/*animate=*/true); }
void ThemeService::onWallpaperChange() {
if (m_config.config().theme.source == ThemeSource::Wallpaper) {
if (m_config.config().theme.source == PaletteSource::Wallpaper) {
resolveAndSet(/*animate=*/true);
}
}
@@ -374,7 +374,7 @@ namespace noctalia::theme {
void ThemeService::resolveAndSet(bool animate) {
const auto& cfg = m_config.config().theme;
std::optional<ResolvedTheme> resolved;
if (cfg.source == ThemeSource::Custom && !cfg.customPalette.empty()) {
if (cfg.source == PaletteSource::Custom && !cfg.customPalette.empty()) {
const auto path = customPalettePath(cfg.customPalette);
if (std::filesystem::exists(path)) {
if (auto parsed = parseCommunityPaletteJson(path)) {
@@ -384,9 +384,9 @@ namespace noctalia::theme {
if (!resolved.has_value()) {
kLog.warn("custom palette '{}' not found or invalid; falling back to builtin", cfg.customPalette);
}
} else if (cfg.source == ThemeSource::Wallpaper) {
} else if (cfg.source == PaletteSource::Wallpaper) {
resolved = resolveWallpaper(cfg, m_config.getDefaultWallpaperPath());
} else if (cfg.source == ThemeSource::Community && !cfg.communityPalette.empty()) {
} else if (cfg.source == PaletteSource::Community && !cfg.communityPalette.empty()) {
const auto cachePath = communityPaletteCachePath(cfg.communityPalette);
if (std::filesystem::exists(cachePath)) {
if (auto parsed = parseCommunityPaletteJson(cachePath)) {