From 7356961f525aad084c6e487581eec764b96dd0d0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 3 Jun 2022 11:40:10 +0200 Subject: [PATCH] [libcalamares] Use the enum names as keys - this uses the Qt internals to map enum values to names, making the separate translation table unnecessary. Adjust default branding to use the new names. This makes code (using enum identifiers) and configuration (using string keys) consistent in naming. --- src/branding/default/branding.desc | 16 ++++++++-------- src/libcalamaresui/Branding.cpp | 17 +++-------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index b8757411f..7365a9e3c 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -170,20 +170,20 @@ images: # Colors for text and background components. # -# - sidebarBackground is the background of the sidebar -# - sidebarText is the (foreground) text color -# - sidebarTextHighlight sets the background of the selected (current) step. +# - SidebarBackground is the background of the sidebar +# - SidebarText is the (foreground) text color +# - SidebarBackgroundCurrent sets the background of the current step. # Optional, and defaults to the application palette. -# - sidebarSelect is the text color of the selected step. +# - SidebarTextCurrent is the text color of the current step. # # These colors can **also** be set through the stylesheet, if the # branding component also ships a stylesheet.qss. Then they are # the corresponding CSS attributes of #sidebarApp. style: - sidebarBackground: "#292F34" - sidebarText: "#FFFFFF" - sidebarTextSelect: "#292F34" - sidebarTextHighlight: "#D35400" + SidebarBackground: "#292F34" + SidebarText: "#FFFFFF" + SidebarTextCurrent: "#292F34" + SidebarBackgroundCurrent: "#D35400" ### SLIDESHOW # diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 82f29d835..e6ad7f621 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -85,19 +86,6 @@ const QStringList Branding::s_imageEntryStrings = "productWelcome" }; -/** @brief Mapping of enum values to key names - * - * The key names can be found in `branding.desc` and need to match - * that (and the branding schema). - */ -static const QStringList s_styleEntryStrings = -{ - "sidebarBackground", - "sidebarText", - "sidebarTextSelect", // enum value TextCurrent - "sidebarTextHighlight", // enum value BackgroundCurrent -}; - const QStringList Branding::s_uploadServerStrings = { "type", @@ -322,7 +310,8 @@ Branding::string( Branding::StringEntry stringEntry ) const QString Branding::styleString( Branding::StyleEntry styleEntry ) const { - return m_style.value( s_styleEntryStrings.value( styleEntry ) ); + const auto meta = QMetaEnum::fromType(); + return meta.valueToKey(styleEntry); }