[libcalamaresui] Improve WindowDimensions class

- Make sure the class knows its own suffixes
main
Adriaan de Groot 6 years ago
parent 6560c194ad
commit 5a95bf507f

@ -78,8 +78,8 @@ const QStringList Branding::s_styleEntryStrings =
"sidebarTextHighlight" "sidebarTextHighlight"
}; };
static const NamedEnumTable<Branding::WindowDimensionUnit>& const NamedEnumTable<Branding::WindowDimensionUnit>&
windowDimensions() Branding::WindowDimension::suffixes()
{ {
using Unit = Branding::WindowDimensionUnit; using Unit = Branding::WindowDimensionUnit;
static const NamedEnumTable<Unit> names{ static const NamedEnumTable<Unit> names{
@ -323,11 +323,6 @@ Branding::initSimpleSettings( const YAML::Node& doc )
{ QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen }, { QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen },
{ QStringLiteral( "noexpand" ), WindowExpansion::Fixed } { QStringLiteral( "noexpand" ), WindowExpansion::Fixed }
}; };
static const NamedEnumTable< WindowDimensionUnit > dimensionNames{
{ QStringLiteral( "px" ), WindowDimensionUnit::Pixies },
{ QStringLiteral( "em" ), WindowDimensionUnit::Fonties }
};
bool ok = false; bool ok = false;
m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false ); m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false );
@ -342,8 +337,8 @@ Branding::initSimpleSettings( const YAML::Node& doc )
auto l = windowSize.split( ',' ); auto l = windowSize.split( ',' );
if ( l.count() == 2 ) if ( l.count() == 2 )
{ {
m_windowWidth = WindowDimension( dimensionNames, l[0] ); m_windowWidth = WindowDimension( l[0] );
m_windowHeight = WindowDimension( dimensionNames, l[1] ); m_windowHeight = WindowDimension( l[1] );
} }
} }
if ( !m_windowWidth.isValid() ) if ( !m_windowWidth.isValid() )

@ -89,8 +89,11 @@ public:
class WindowDimension : public NamedSuffix<WindowDimensionUnit, WindowDimensionUnit::None> class WindowDimension : public NamedSuffix<WindowDimensionUnit, WindowDimensionUnit::None>
{ {
public: public:
using NamedSuffix::NamedSuffix; static const NamedEnumTable< WindowDimensionUnit >& suffixes();
bool isValid() const; bool isValid() const;
using NamedSuffix::NamedSuffix;
WindowDimension( const QString& s ) : NamedSuffix( suffixes(), s ) {}
} ; } ;
static Branding* instance(); static Branding* instance();

Loading…
Cancel
Save