Merge pull request #1976 from calamares/fix-color-names
[libcalamaresui] Fix color names
This commit is contained in:
commit
9fdae8c76f
@ -170,20 +170,20 @@ images:
|
|||||||
|
|
||||||
# Colors for text and background components.
|
# Colors for text and background components.
|
||||||
#
|
#
|
||||||
# - sidebarBackground is the background of the sidebar
|
# - SidebarBackground is the background of the sidebar
|
||||||
# - sidebarText is the (foreground) text color
|
# - SidebarText is the (foreground) text color
|
||||||
# - sidebarTextHighlight sets the background of the selected (current) step.
|
# - SidebarBackgroundCurrent sets the background of the current step.
|
||||||
# Optional, and defaults to the application palette.
|
# 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
|
# These colors can **also** be set through the stylesheet, if the
|
||||||
# branding component also ships a stylesheet.qss. Then they are
|
# branding component also ships a stylesheet.qss. Then they are
|
||||||
# the corresponding CSS attributes of #sidebarApp.
|
# the corresponding CSS attributes of #sidebarApp.
|
||||||
style:
|
style:
|
||||||
sidebarBackground: "#292F34"
|
SidebarBackground: "#292F34"
|
||||||
sidebarText: "#FFFFFF"
|
SidebarText: "#FFFFFF"
|
||||||
sidebarTextSelect: "#292F34"
|
SidebarTextCurrent: "#292F34"
|
||||||
sidebarTextHighlight: "#D35400"
|
SidebarBackgroundCurrent: "#D35400"
|
||||||
|
|
||||||
### SLIDESHOW
|
### SLIDESHOW
|
||||||
#
|
#
|
||||||
|
@ -66,7 +66,7 @@ Rectangle {
|
|||||||
Layout.fillWidth: true;
|
Layout.fillWidth: true;
|
||||||
height: 35
|
height: 35
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
||||||
color: Branding.styleString( Branding.SidebarTextHighlight );
|
color: Branding.styleString( Branding.SidebarBackground );
|
||||||
visible: true;
|
visible: true;
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@ -74,7 +74,7 @@ Rectangle {
|
|||||||
height: 35
|
height: 35
|
||||||
width: parent.width / 2;
|
width: parent.width / 2;
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
color: Branding.styleString( Branding.SidebarTextHighlight );
|
color: Branding.styleString( Branding.SidebarBackgroundCurrent );
|
||||||
visible: true;
|
visible: true;
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@ -87,7 +87,7 @@ Rectangle {
|
|||||||
anchors.horizontalCenter: parent.horizontalCenter;
|
anchors.horizontalCenter: parent.horizontalCenter;
|
||||||
x: parent.x + 4;
|
x: parent.x + 4;
|
||||||
text: qsTr("About")
|
text: qsTr("About")
|
||||||
color: Branding.styleString( Branding.SidebarTextSelect );
|
color: Branding.styleString( Branding.SidebarTextCurrent );
|
||||||
font.pointSize : 9
|
font.pointSize : 9
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ Rectangle {
|
|||||||
height: 35
|
height: 35
|
||||||
width: parent.width / 2;
|
width: parent.width / 2;
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
color: Branding.styleString( Branding.SidebarTextHighlight );
|
color: Branding.styleString( Branding.SidebarBackgroundCurrent );
|
||||||
visible: debug.enabled
|
visible: debug.enabled
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@ -113,7 +113,7 @@ Rectangle {
|
|||||||
anchors.horizontalCenter: parent.horizontalCenter;
|
anchors.horizontalCenter: parent.horizontalCenter;
|
||||||
x: parent.x + 4;
|
x: parent.x + 4;
|
||||||
text: qsTr("Debug")
|
text: qsTr("Debug")
|
||||||
color: Branding.styleString( Branding.SidebarTextSelect );
|
color: Branding.styleString( Branding.SidebarTextCurrent );
|
||||||
font.pointSize : 9
|
font.pointSize : 9
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QMetaEnum>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
@ -85,14 +86,6 @@ const QStringList Branding::s_imageEntryStrings =
|
|||||||
"productWelcome"
|
"productWelcome"
|
||||||
};
|
};
|
||||||
|
|
||||||
const QStringList Branding::s_styleEntryStrings =
|
|
||||||
{
|
|
||||||
"sidebarBackground",
|
|
||||||
"sidebarText",
|
|
||||||
"sidebarTextSelect",
|
|
||||||
"sidebarTextHighlight"
|
|
||||||
};
|
|
||||||
|
|
||||||
const QStringList Branding::s_uploadServerStrings =
|
const QStringList Branding::s_uploadServerStrings =
|
||||||
{
|
{
|
||||||
"type",
|
"type",
|
||||||
@ -102,6 +95,36 @@ const QStringList Branding::s_uploadServerStrings =
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
// *INDENT-ON*
|
// *INDENT-ON*
|
||||||
|
|
||||||
|
/** @brief Check that all the entries in the @p style map make sense
|
||||||
|
*
|
||||||
|
* This will catch typo's in key names.
|
||||||
|
*/
|
||||||
|
static bool
|
||||||
|
validateStyleEntries( const QMap< QString, QString >& style )
|
||||||
|
{
|
||||||
|
using SE = Branding::StyleEntry;
|
||||||
|
|
||||||
|
Logger::Once o;
|
||||||
|
bool valid = true;
|
||||||
|
|
||||||
|
const auto meta = QMetaEnum::fromType< SE >();
|
||||||
|
QSet< QString > validNames;
|
||||||
|
for ( SE i : { SE::SidebarBackground, SE::SidebarBackgroundCurrent, SE::SidebarText, SE::SidebarTextCurrent } )
|
||||||
|
{
|
||||||
|
validNames.insert( meta.valueToKey( i ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( const auto& k : style.keys() )
|
||||||
|
{
|
||||||
|
if ( !validNames.contains( k ) )
|
||||||
|
{
|
||||||
|
cWarning() << o << "Unknown branding *style* entry" << k;
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
const NamedEnumTable< Branding::WindowDimensionUnit >&
|
const NamedEnumTable< Branding::WindowDimensionUnit >&
|
||||||
Branding::WindowDimension::suffixes()
|
Branding::WindowDimension::suffixes()
|
||||||
@ -296,6 +319,7 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
|
|||||||
{
|
{
|
||||||
cDebug() << "Loaded branding component" << m_componentName;
|
cDebug() << "Loaded branding component" << m_componentName;
|
||||||
}
|
}
|
||||||
|
validateStyleEntries( m_style );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -317,7 +341,8 @@ Branding::string( Branding::StringEntry stringEntry ) const
|
|||||||
QString
|
QString
|
||||||
Branding::styleString( Branding::StyleEntry styleEntry ) const
|
Branding::styleString( Branding::StyleEntry styleEntry ) const
|
||||||
{
|
{
|
||||||
return m_style.value( s_styleEntryStrings.value( styleEntry ) );
|
const auto meta = QMetaEnum::fromType< Branding::StyleEntry >();
|
||||||
|
return m_style.value( meta.valueToKey( styleEntry ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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")
|
||||||
|
Loading…
Reference in New Issue
Block a user