From 5a95bf507fd7be505cdef63fac204204a1e5363a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 11 Apr 2019 14:26:16 +0200 Subject: [PATCH] [libcalamaresui] Improve WindowDimensions class - Make sure the class knows its own suffixes --- src/libcalamaresui/Branding.cpp | 13 ++++--------- src/libcalamaresui/Branding.h | 5 ++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index e24e80472..e31130520 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -78,8 +78,8 @@ const QStringList Branding::s_styleEntryStrings = "sidebarTextHighlight" }; -static const NamedEnumTable& -windowDimensions() +const NamedEnumTable& +Branding::WindowDimension::suffixes() { using Unit = Branding::WindowDimensionUnit; static const NamedEnumTable names{ @@ -323,11 +323,6 @@ Branding::initSimpleSettings( const YAML::Node& doc ) { QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen }, { QStringLiteral( "noexpand" ), WindowExpansion::Fixed } }; - static const NamedEnumTable< WindowDimensionUnit > dimensionNames{ - { QStringLiteral( "px" ), WindowDimensionUnit::Pixies }, - { QStringLiteral( "em" ), WindowDimensionUnit::Fonties } - }; - bool ok = false; m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false ); @@ -342,8 +337,8 @@ Branding::initSimpleSettings( const YAML::Node& doc ) auto l = windowSize.split( ',' ); if ( l.count() == 2 ) { - m_windowWidth = WindowDimension( dimensionNames, l[0] ); - m_windowHeight = WindowDimension( dimensionNames, l[1] ); + m_windowWidth = WindowDimension( l[0] ); + m_windowHeight = WindowDimension( l[1] ); } } if ( !m_windowWidth.isValid() ) diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 5063a1df1..197cb8ee2 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -89,8 +89,11 @@ public: class WindowDimension : public NamedSuffix { public: - using NamedSuffix::NamedSuffix; + static const NamedEnumTable< WindowDimensionUnit >& suffixes(); bool isValid() const; + + using NamedSuffix::NamedSuffix; + WindowDimension( const QString& s ) : NamedSuffix( suffixes(), s ) {} } ; static Branding* instance();