[libcalamaresui] Store resize configuration

- Use the named enums code for simplicity.
main
Adriaan de Groot 6 years ago
parent d25a17a45e
commit 819a57e458

@ -21,9 +21,10 @@
#include "GlobalStorage.h"
#include "utils/CalamaresUtils.h"
#include "utils/ImageRegistry.h"
#include "utils/Logger.h"
#include "utils/NamedEnum.h"
#include "utils/YamlUtils.h"
#include "utils/ImageRegistry.h"
#include <QDir>
#include <QFile>
@ -107,12 +108,11 @@ Branding::Branding( const QString& brandingFilePath,
bail( "The branding component name should match the name of the "
"component directory." );
initSimpleSettings( doc );
if ( !doc[ "strings" ].IsMap() )
bail( "Syntax error in strings map." );
m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false );
m_welcomeExpandingLogo = doc[ "welcomeExpandingLogo" ].as< bool >( true );
QVariantMap strings =
CalamaresUtils::yamlMapToVariant( doc[ "strings" ] ).toMap();
m_strings.clear();
@ -288,6 +288,25 @@ Branding::setGlobals( GlobalStorage* globalStorage ) const
}
void
Branding::initSimpleSettings( const YAML::Node& doc )
{
static const NamedEnumTable< WindowExpansion > weNames{
{ QStringLiteral( "normal" ), WindowExpansion::Normal },
{ QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen },
{ QStringLiteral( "noexpand" ), WindowExpansion::Fixed }
};
bool ok = false;
m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false );
m_welcomeExpandingLogo = doc[ "welcomeExpandingLogo" ].as< bool >( true );
m_windowExpansion = weNames.find( QString::fromStdString( doc[ "windowExpanding" ].as< std::string >() ), ok );
if ( !ok )
cWarning() << "Branding module-setting *windowExpanding* interpreted as" << weNames.find( m_windowExpansion, ok );
}
void
Branding::bail( const QString& message )
{

@ -27,6 +27,10 @@
#include <QStringList>
#include <QMap>
namespace YAML
{
class Node;
}
namespace Calamares
{
@ -63,7 +67,7 @@ public:
ProductIcon,
ProductWelcome
};
enum StyleEntry : short
{
SidebarBackground,
@ -72,6 +76,9 @@ public:
SidebarTextHighlight
};
/** @brief Setting for how much the main window may expand. */
enum class WindowExpansion { Normal, Fullscreen, Fixed } ;
static Branding* instance();
explicit Branding( const QString& brandingFilePath,
@ -115,8 +122,12 @@ private:
QString m_slideshowPath;
QString m_translationsPathPrefix;
/** @brief Initialize the simple settings below */
void initSimpleSettings( const YAML::Node& doc );
bool m_welcomeStyleCalamares;
bool m_welcomeExpandingLogo;
WindowExpansion m_windowExpansion;
};
template<typename U> inline QString operator*(U e) { return Branding::instance()->string( e ); }

Loading…
Cancel
Save