[libcalamaresui] Document style-string mapping

- while here, the static array of names doesn't need to be
  a class member, it is entirely internal.
- document how names are mapped to branding keys.
This commit is contained in:
Adriaan de Groot 2022-06-03 11:20:59 +02:00
parent 821a62ffbb
commit dc699db5f5
2 changed files with 20 additions and 4 deletions

View File

@ -85,12 +85,17 @@ const QStringList Branding::s_imageEntryStrings =
"productWelcome" "productWelcome"
}; };
const QStringList Branding::s_styleEntryStrings = /** @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", "sidebarBackground",
"sidebarText", "sidebarText",
"sidebarTextSelect", "sidebarTextSelect", // enum value TextCurrent
"sidebarTextHighlight" "sidebarTextHighlight", // enum value BackgroundCurrent
}; };
const QStringList Branding::s_uploadServerStrings = const QStringList Branding::s_uploadServerStrings =

View File

@ -72,6 +72,12 @@ public:
}; };
Q_ENUM( ImageEntry ) Q_ENUM( ImageEntry )
/** @brief Names of style entries, for use in code
*
* These names are mapped to names in the branding.desc file through
* an internal table s_styleEntryStrings, which defines which names
* in `branding.desc` key *style* are used for which entry.
*/
enum StyleEntry : short enum StyleEntry : short
{ {
SidebarBackground, SidebarBackground,
@ -256,6 +262,12 @@ public slots:
QString shortProductName() const { return string( ShortProductName ); } QString shortProductName() const { return string( ShortProductName ); }
QString shortVersionedName() const { return string( ShortVersionedName ); } QString shortVersionedName() const { return string( ShortVersionedName ); }
/** @brief Map an enum-value to the entry from the *style* key.
*
* e.g. StyleEntry::SidebarTextCurrent maps to the corresponding
* *style* entry, which is (confusingly) named "sidebarTextSelect"
* in the branding file.
*/
QString styleString( StyleEntry styleEntry ) const; QString styleString( StyleEntry styleEntry ) const;
QString imagePath( ImageEntry imageEntry ) const; QString imagePath( ImageEntry imageEntry ) const;
@ -267,7 +279,6 @@ private:
static const QStringList s_stringEntryStrings; static const QStringList s_stringEntryStrings;
static const QStringList s_imageEntryStrings; static const QStringList s_imageEntryStrings;
static const QStringList s_styleEntryStrings;
static const QStringList s_uploadServerStrings; static const QStringList s_uploadServerStrings;
QString m_descriptorPath; // Path to descriptor (e.g. "/etc/calamares/default/branding.desc") QString m_descriptorPath; // Path to descriptor (e.g. "/etc/calamares/default/branding.desc")