2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2014-10-10 18:18:35 +02:00
|
|
|
*
|
2015-05-07 16:10:04 +02:00
|
|
|
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
2019-05-27 15:26:57 +02:00
|
|
|
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org>
|
2018-05-22 11:47:14 +02:00
|
|
|
* Copyright 2018, Raul Rodrigo Segura (raurodse)
|
2014-10-10 18:18:35 +02:00
|
|
|
*
|
|
|
|
* Calamares is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Branding.h"
|
|
|
|
|
2014-11-16 04:19:53 +01:00
|
|
|
#include "GlobalStorage.h"
|
2019-01-14 12:06:04 +01:00
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
2019-01-11 17:35:06 +01:00
|
|
|
#include "utils/ImageRegistry.h"
|
2014-10-10 18:18:35 +02:00
|
|
|
#include "utils/Logger.h"
|
2019-01-11 17:35:06 +01:00
|
|
|
#include "utils/NamedEnum.h"
|
2019-04-29 12:04:55 +02:00
|
|
|
#include "utils/Yaml.h"
|
2014-10-10 18:18:35 +02:00
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
2019-05-27 15:26:57 +02:00
|
|
|
#include <QIcon>
|
2014-10-16 16:57:52 +02:00
|
|
|
#include <QPixmap>
|
2014-11-16 04:19:53 +01:00
|
|
|
#include <QVariantMap>
|
2014-10-10 18:18:35 +02:00
|
|
|
|
2019-05-20 16:20:31 +02:00
|
|
|
#include <functional>
|
|
|
|
|
2019-05-20 22:11:11 +02:00
|
|
|
#ifdef WITH_KOSRelease
|
|
|
|
#include <KMacroExpander>
|
|
|
|
#include <KOSRelease>
|
|
|
|
#endif
|
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
namespace Calamares
|
|
|
|
{
|
|
|
|
|
|
|
|
Branding* Branding::s_instance = nullptr;
|
|
|
|
|
|
|
|
Branding*
|
|
|
|
Branding::instance()
|
|
|
|
{
|
|
|
|
return s_instance;
|
|
|
|
}
|
|
|
|
|
2014-10-16 16:14:48 +02:00
|
|
|
|
2016-09-01 14:21:05 +02:00
|
|
|
const QStringList Branding::s_stringEntryStrings =
|
2014-10-16 16:14:48 +02:00
|
|
|
{
|
|
|
|
"productName",
|
|
|
|
"version",
|
|
|
|
"shortVersion",
|
|
|
|
"versionedName",
|
2014-11-16 05:14:57 +01:00
|
|
|
"shortVersionedName",
|
2014-11-19 16:50:15 +01:00
|
|
|
"shortProductName",
|
2015-04-01 18:03:17 +02:00
|
|
|
"bootloaderEntryName",
|
|
|
|
"productUrl",
|
2015-04-01 19:00:52 +02:00
|
|
|
"supportUrl",
|
|
|
|
"knownIssuesUrl",
|
|
|
|
"releaseNotesUrl"
|
2014-10-16 16:14:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-01 14:21:05 +02:00
|
|
|
const QStringList Branding::s_imageEntryStrings =
|
2014-10-16 16:14:48 +02:00
|
|
|
{
|
|
|
|
"productLogo",
|
2015-06-20 00:18:14 +02:00
|
|
|
"productIcon",
|
|
|
|
"productWelcome"
|
2014-10-16 16:14:48 +02:00
|
|
|
};
|
|
|
|
|
2016-09-01 14:21:05 +02:00
|
|
|
const QStringList Branding::s_styleEntryStrings =
|
2015-03-19 16:26:22 +01:00
|
|
|
{
|
|
|
|
"sidebarBackground",
|
|
|
|
"sidebarText",
|
2016-01-07 04:02:56 +01:00
|
|
|
"sidebarTextSelect",
|
|
|
|
"sidebarTextHighlight"
|
2015-03-19 16:26:22 +01:00
|
|
|
};
|
|
|
|
|
2019-04-11 14:26:16 +02:00
|
|
|
const NamedEnumTable<Branding::WindowDimensionUnit>&
|
|
|
|
Branding::WindowDimension::suffixes()
|
2019-01-14 12:06:04 +01:00
|
|
|
{
|
|
|
|
using Unit = Branding::WindowDimensionUnit;
|
|
|
|
static const NamedEnumTable<Unit> names{
|
|
|
|
{"px", Unit::Pixies},
|
|
|
|
{"em", Unit::Fonties}
|
|
|
|
};
|
|
|
|
|
|
|
|
return names;
|
|
|
|
}
|
2014-10-10 18:18:35 +02:00
|
|
|
|
2019-05-20 17:00:43 +02:00
|
|
|
/** @brief Load the @p map with strings from @p doc
|
2019-05-20 15:49:13 +02:00
|
|
|
*
|
2019-05-20 17:00:43 +02:00
|
|
|
* Each key-value pair from the sub-map in @p doc identified by @p key
|
|
|
|
* is inserted into the @p map, but the value is first transformed by
|
|
|
|
* the @p transform function, which may change strings.
|
2019-05-20 15:49:13 +02:00
|
|
|
*/
|
|
|
|
static void
|
2019-05-20 17:00:43 +02:00
|
|
|
loadStrings( QMap<QString, QString>& map, const YAML::Node& doc, const std::string& key, const std::function< QString(const QString&) >& transform )
|
2019-05-20 15:49:13 +02:00
|
|
|
{
|
2019-05-20 17:00:43 +02:00
|
|
|
if ( !doc[ key ].IsMap() )
|
|
|
|
throw YAML::Exception( YAML::Mark(), std::string("Branding configuration is not a map: ") + key );
|
|
|
|
|
|
|
|
const auto& config = CalamaresUtils::yamlMapToVariant( doc[ key ] ).toMap();
|
|
|
|
|
2019-05-20 15:49:13 +02:00
|
|
|
map.clear();
|
|
|
|
for ( auto it = config.constBegin(); it != config.constEnd(); ++it )
|
2019-05-20 16:20:31 +02:00
|
|
|
map.insert( it.key(), transform( it.value().toString() ) );
|
2019-05-20 15:49:13 +02:00
|
|
|
}
|
|
|
|
|
2019-05-20 16:20:31 +02:00
|
|
|
/** @brief Load the @p map with strings from @p config
|
|
|
|
*
|
|
|
|
* If os-release is supported (with KF5 CoreAddons >= 5.58) then
|
|
|
|
* special substitutions can be done as well. See the branding
|
|
|
|
* documentation for details.
|
|
|
|
*/
|
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
Branding::Branding( const QString& brandingFilePath,
|
|
|
|
QObject* parent )
|
|
|
|
: QObject( parent )
|
|
|
|
, m_descriptorPath( brandingFilePath )
|
2019-08-09 16:28:29 +02:00
|
|
|
, m_slideshowAPI( 1 )
|
2017-06-27 12:05:26 +02:00
|
|
|
, m_welcomeStyleCalamares( false )
|
2017-07-11 15:32:09 +02:00
|
|
|
, m_welcomeExpandingLogo( true )
|
2014-10-10 18:18:35 +02:00
|
|
|
{
|
|
|
|
cDebug() << "Using Calamares branding file at" << brandingFilePath;
|
2019-05-31 17:06:35 +02:00
|
|
|
|
|
|
|
QDir componentDir( componentDirectory() );
|
|
|
|
if ( !componentDir.exists() )
|
|
|
|
bail( "Bad component directory path." );
|
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
QFile file( brandingFilePath );
|
|
|
|
if ( file.exists() && file.open( QFile::ReadOnly | QFile::Text ) )
|
|
|
|
{
|
|
|
|
QByteArray ba = file.readAll();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
YAML::Node doc = YAML::Load( ba.constData() );
|
|
|
|
Q_ASSERT( doc.IsMap() );
|
|
|
|
|
2014-10-16 16:14:48 +02:00
|
|
|
m_componentName = QString::fromStdString( doc[ "componentName" ]
|
2014-10-10 18:18:35 +02:00
|
|
|
.as< std::string >() );
|
2019-05-31 17:06:35 +02:00
|
|
|
if ( m_componentName != componentDir.dirName() )
|
2014-10-16 16:14:48 +02:00
|
|
|
bail( "The branding component name should match the name of the "
|
|
|
|
"component directory." );
|
|
|
|
|
2019-01-11 17:35:06 +01:00
|
|
|
initSimpleSettings( doc );
|
|
|
|
|
2019-05-20 22:11:11 +02:00
|
|
|
#ifdef WITH_KOSRelease
|
2019-05-21 17:10:32 +02:00
|
|
|
// Copy the os-release information into a QHash for use by KMacroExpander.
|
2019-05-20 22:11:11 +02:00
|
|
|
KOSRelease relInfo;
|
2019-05-21 13:21:47 +02:00
|
|
|
|
2019-05-20 22:54:54 +02:00
|
|
|
QHash< QString, QString > relMap{
|
|
|
|
std::initializer_list< std::pair< QString, QString > > {
|
|
|
|
{ QStringLiteral( "NAME" ), relInfo.name() },
|
|
|
|
{ QStringLiteral( "VERSION" ), relInfo.version() },
|
|
|
|
{ QStringLiteral( "ID" ), relInfo.id() },
|
|
|
|
{ QStringLiteral( "ID_LIKE" ), relInfo.idLike().join( ' ' ) },
|
|
|
|
{ QStringLiteral( "VERSION_CODENAME" ), relInfo.versionCodename() },
|
|
|
|
{ QStringLiteral( "VERSION_ID" ), relInfo.versionId() },
|
|
|
|
{ QStringLiteral( "PRETTY_NAME" ), relInfo.prettyName() },
|
|
|
|
{ QStringLiteral( "HOME_URL" ), relInfo.homeUrl() },
|
|
|
|
{ QStringLiteral( "DOCUMENTATION_URL" ), relInfo.documentationUrl() },
|
|
|
|
{ QStringLiteral( "SUPPORT_URL" ), relInfo.supportUrl() },
|
|
|
|
{ QStringLiteral( "BUG_REPORT_URL" ), relInfo.bugReportUrl() },
|
|
|
|
{ QStringLiteral( "PRIVACY_POLICY_URL" ), relInfo.privacyPolicyUrl() },
|
|
|
|
{ QStringLiteral( "BUILD_ID" ), relInfo.buildId() },
|
|
|
|
{ QStringLiteral( "VARIANT" ), relInfo.variant() },
|
|
|
|
{ QStringLiteral( "VARIANT_ID" ), relInfo.variantId() },
|
|
|
|
{ QStringLiteral( "LOGO" ), relInfo.logo() }
|
|
|
|
} };
|
2019-05-21 17:10:32 +02:00
|
|
|
auto expand = [&]( const QString& s ) -> QString { return KMacroExpander::expandMacros( s, relMap, QLatin1Char( '@' ) ); };
|
2019-05-20 22:11:11 +02:00
|
|
|
#else
|
2019-05-21 17:10:32 +02:00
|
|
|
auto expand = []( const QString& s ) -> QString { return s; };
|
2019-05-20 22:11:11 +02:00
|
|
|
#endif
|
2019-05-21 17:10:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Massage the strings, images and style sections.
|
|
|
|
loadStrings( m_strings, doc, "strings", expand );
|
2019-05-20 17:00:43 +02:00
|
|
|
loadStrings( m_images, doc, "images",
|
2019-05-20 16:26:30 +02:00
|
|
|
[&]( const QString& s ) -> QString
|
|
|
|
{
|
2019-05-31 17:22:03 +02:00
|
|
|
// See also image()
|
2019-05-27 15:26:57 +02:00
|
|
|
const QString imageName( expand( s ) );
|
|
|
|
QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) );
|
2019-05-20 16:26:30 +02:00
|
|
|
if ( !imageFi.exists() )
|
2019-05-27 15:26:57 +02:00
|
|
|
{
|
|
|
|
const auto icon = QIcon::fromTheme( imageName );
|
|
|
|
// Not found, bail out with the filename used
|
|
|
|
if ( icon.isNull() )
|
|
|
|
bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
|
|
|
|
return imageName; // Not turned into a path
|
|
|
|
}
|
2019-05-20 16:26:30 +02:00
|
|
|
return imageFi.absoluteFilePath();
|
|
|
|
}
|
2019-05-20 17:00:43 +02:00
|
|
|
);
|
|
|
|
loadStrings( m_style, doc, "style",
|
|
|
|
[]( const QString& s ) -> QString { return s; }
|
|
|
|
);
|
2014-10-16 16:14:48 +02:00
|
|
|
|
2015-01-23 14:02:40 +01:00
|
|
|
if ( doc[ "slideshow" ].IsSequence() )
|
2014-10-10 18:18:35 +02:00
|
|
|
{
|
2015-01-23 14:02:40 +01:00
|
|
|
QStringList slideShowPictures;
|
|
|
|
doc[ "slideshow" ] >> slideShowPictures;
|
|
|
|
for ( int i = 0; i < slideShowPictures.count(); ++i )
|
|
|
|
{
|
|
|
|
QString pathString = slideShowPictures[ i ];
|
|
|
|
QFileInfo imageFi( componentDir.absoluteFilePath( pathString ) );
|
|
|
|
if ( !imageFi.exists() )
|
|
|
|
bail( QString( "Slideshow file %1 does not exist." )
|
|
|
|
.arg( imageFi.absoluteFilePath() ) );
|
|
|
|
|
|
|
|
slideShowPictures[ i ] = imageFi.absoluteFilePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
//FIXME: implement a GenericSlideShow.qml that uses these slideShowPictures
|
2014-10-10 18:18:35 +02:00
|
|
|
}
|
2015-01-23 14:02:40 +01:00
|
|
|
else if ( doc[ "slideshow" ].IsScalar() )
|
|
|
|
{
|
|
|
|
QString slideshowPath = QString::fromStdString( doc[ "slideshow" ]
|
|
|
|
.as< std::string >() );
|
|
|
|
QFileInfo slideshowFi( componentDir.absoluteFilePath( slideshowPath ) );
|
|
|
|
if ( !slideshowFi.exists() ||
|
|
|
|
!slideshowFi.fileName().toLower().endsWith( ".qml" ) )
|
|
|
|
bail( QString( "Slideshow file %1 does not exist or is not a valid QML file." )
|
|
|
|
.arg( slideshowFi.absoluteFilePath() ) );
|
|
|
|
m_slideshowPath = slideshowFi.absoluteFilePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bail( "Syntax error in slideshow sequence." );
|
2019-06-17 10:58:14 +02:00
|
|
|
|
|
|
|
int api = doc[ "slideshowAPI" ].IsScalar() ? doc[ "slideshowAPI" ].as<int>() : -1;
|
|
|
|
if ( ( api < 1 ) || ( api > 2 ) )
|
|
|
|
{
|
|
|
|
cWarning() << "Invalid or missing *slideshowAPI* in branding file.";
|
|
|
|
api = 1;
|
|
|
|
}
|
|
|
|
m_slideshowAPI = api;
|
2014-10-10 18:18:35 +02:00
|
|
|
}
|
|
|
|
catch ( YAML::Exception& e )
|
|
|
|
{
|
2018-02-26 20:07:06 +01:00
|
|
|
CalamaresUtils::explainYamlException( e, ba, file.fileName() );
|
2019-05-20 16:37:20 +02:00
|
|
|
bail( e.what() );
|
2014-10-10 18:18:35 +02:00
|
|
|
}
|
2015-05-07 16:10:04 +02:00
|
|
|
|
|
|
|
QDir translationsDir( componentDir.filePath( "lang" ) );
|
|
|
|
if ( !translationsDir.exists() )
|
2018-03-08 14:14:04 +01:00
|
|
|
cWarning() << "the branding component" << componentDir.absolutePath() << "does not ship translations.";
|
2015-05-07 16:10:04 +02:00
|
|
|
m_translationsPathPrefix = translationsDir.absolutePath();
|
|
|
|
m_translationsPathPrefix.append( QString( "%1calamares-%2" )
|
|
|
|
.arg( QDir::separator() )
|
|
|
|
.arg( m_componentName ) );
|
2014-10-10 18:18:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-26 20:07:06 +01:00
|
|
|
cWarning() << "Cannot read branding file" << file.fileName();
|
2014-10-10 18:18:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s_instance = this;
|
2017-06-17 21:14:02 +02:00
|
|
|
if ( m_componentName.isEmpty() )
|
|
|
|
{
|
2018-02-12 16:46:57 +01:00
|
|
|
cWarning() << "Failed to load component from" << brandingFilePath;
|
2017-06-17 21:14:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cDebug() << "Loaded branding component" << m_componentName;
|
|
|
|
}
|
2014-10-10 18:18:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
Branding::componentDirectory() const
|
|
|
|
{
|
|
|
|
QFileInfo fi ( m_descriptorPath );
|
|
|
|
return fi.absoluteDir().absolutePath();
|
|
|
|
}
|
|
|
|
|
2014-10-16 16:14:48 +02:00
|
|
|
|
|
|
|
QString
|
|
|
|
Branding::string( Branding::StringEntry stringEntry ) const
|
|
|
|
{
|
|
|
|
return m_strings.value( s_stringEntryStrings.value( stringEntry ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-19 17:58:18 +01:00
|
|
|
QString
|
|
|
|
Branding::styleString( Branding::StyleEntry styleEntry ) const
|
|
|
|
{
|
|
|
|
return m_style.value( s_styleEntryStrings.value( styleEntry ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-16 16:14:48 +02:00
|
|
|
QString
|
2014-10-16 16:57:52 +02:00
|
|
|
Branding::imagePath( Branding::ImageEntry imageEntry ) const
|
2014-10-16 16:14:48 +02:00
|
|
|
{
|
|
|
|
return m_images.value( s_imageEntryStrings.value( imageEntry ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-16 16:57:52 +02:00
|
|
|
QPixmap
|
|
|
|
Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const
|
|
|
|
{
|
2019-05-27 15:35:56 +02:00
|
|
|
const auto path = imagePath( imageEntry );
|
|
|
|
if ( path.contains( '/' ) )
|
|
|
|
{
|
|
|
|
QPixmap pixmap = ImageRegistry::instance()->pixmap( path, size );
|
2014-10-16 16:57:52 +02:00
|
|
|
|
2019-05-27 15:35:56 +02:00
|
|
|
Q_ASSERT( !pixmap.isNull() );
|
|
|
|
return pixmap;
|
|
|
|
}
|
|
|
|
else
|
2014-10-16 16:57:52 +02:00
|
|
|
{
|
2019-05-27 15:35:56 +02:00
|
|
|
auto icon = QIcon::fromTheme(path);
|
|
|
|
|
|
|
|
Q_ASSERT( !icon.isNull() );
|
|
|
|
return icon.pixmap( size );
|
2014-10-16 16:57:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-31 17:22:03 +02:00
|
|
|
QPixmap
|
|
|
|
Branding::image(const QString& imageName, const QSize& size) const
|
|
|
|
{
|
|
|
|
QDir componentDir( componentDirectory() );
|
|
|
|
QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) );
|
|
|
|
if ( !imageFi.exists() )
|
|
|
|
{
|
|
|
|
const auto icon = QIcon::fromTheme( imageName );
|
|
|
|
// Not found, bail out with the filename used
|
|
|
|
if ( icon.isNull() )
|
|
|
|
return QPixmap();
|
|
|
|
return icon.pixmap( size );
|
|
|
|
}
|
|
|
|
return ImageRegistry::instance()->pixmap( imageFi.absoluteFilePath(), size );
|
|
|
|
}
|
|
|
|
|
2019-05-21 13:21:47 +02:00
|
|
|
QString
|
|
|
|
Branding::stylesheet() const
|
|
|
|
{
|
|
|
|
QFileInfo fi( m_descriptorPath );
|
|
|
|
QFileInfo importQSSPath( fi.absoluteDir().filePath( "stylesheet.qss" ) );
|
|
|
|
if ( importQSSPath.exists() && importQSSPath.isReadable() )
|
|
|
|
{
|
|
|
|
QFile stylesheetFile( importQSSPath.filePath() );
|
|
|
|
stylesheetFile.open( QFile::ReadOnly );
|
|
|
|
return stylesheetFile.readAll();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cWarning() << "The branding component" << fi.absoluteDir().absolutePath() << "does not ship stylesheet.qss.";
|
|
|
|
return QString();
|
|
|
|
}
|
2014-10-16 16:57:52 +02:00
|
|
|
|
2014-11-16 04:19:53 +01:00
|
|
|
void
|
|
|
|
Branding::setGlobals( GlobalStorage* globalStorage ) const
|
|
|
|
{
|
|
|
|
QVariantMap brandingMap;
|
2016-09-01 14:21:05 +02:00
|
|
|
for ( const QString& key : s_stringEntryStrings )
|
2014-11-16 05:14:57 +01:00
|
|
|
brandingMap.insert( key, m_strings.value( key ) );
|
2014-11-16 04:19:53 +01:00
|
|
|
globalStorage->insert( "branding", brandingMap );
|
|
|
|
}
|
|
|
|
|
2019-01-14 12:06:04 +01:00
|
|
|
bool
|
|
|
|
Branding::WindowDimension::isValid() const
|
|
|
|
{
|
|
|
|
return ( unit() != none ) && ( value() > 0 );
|
|
|
|
}
|
2014-11-16 04:19:53 +01:00
|
|
|
|
2019-01-14 15:30:44 +01:00
|
|
|
|
|
|
|
/// @brief Guard against cases where the @p key doesn't exist in @p doc
|
|
|
|
static inline QString
|
|
|
|
getString( const YAML::Node& doc, const char* key )
|
|
|
|
{
|
|
|
|
if ( doc[key] )
|
|
|
|
return QString::fromStdString( doc[key].as< std::string >() );
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2019-01-11 17:35:06 +01:00
|
|
|
void
|
|
|
|
Branding::initSimpleSettings( const YAML::Node& doc )
|
|
|
|
{
|
2019-01-14 12:06:04 +01:00
|
|
|
static const NamedEnumTable< WindowExpansion > expansionNames{
|
2019-01-11 17:35:06 +01:00
|
|
|
{ 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 );
|
2019-01-14 15:30:44 +01:00
|
|
|
m_windowExpansion = expansionNames.find( getString( doc, "windowExpanding" ), ok );
|
2019-01-11 17:35:06 +01:00
|
|
|
if ( !ok )
|
2019-01-14 12:06:04 +01:00
|
|
|
cWarning() << "Branding module-setting *windowExpanding* interpreted as" << expansionNames.find( m_windowExpansion, ok );
|
|
|
|
|
2019-01-14 15:30:44 +01:00
|
|
|
QString windowSize = getString( doc, "windowSize" );
|
2019-01-14 12:06:04 +01:00
|
|
|
if ( !windowSize.isEmpty() )
|
|
|
|
{
|
|
|
|
auto l = windowSize.split( ',' );
|
|
|
|
if ( l.count() == 2 )
|
|
|
|
{
|
2019-04-11 14:26:16 +02:00
|
|
|
m_windowWidth = WindowDimension( l[0] );
|
|
|
|
m_windowHeight = WindowDimension( l[1] );
|
2019-01-14 12:06:04 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-14 13:42:41 +01:00
|
|
|
if ( !m_windowWidth.isValid() )
|
2019-01-14 12:06:04 +01:00
|
|
|
m_windowWidth = WindowDimension( CalamaresUtils::windowPreferredWidth, WindowDimensionUnit::Pixies );
|
2019-01-14 13:42:41 +01:00
|
|
|
if ( !m_windowHeight.isValid() )
|
2019-01-14 12:06:04 +01:00
|
|
|
m_windowHeight = WindowDimension( CalamaresUtils::windowPreferredHeight, WindowDimensionUnit::Pixies );
|
2019-01-11 17:35:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-11 12:35:38 +02:00
|
|
|
[[noreturn]] void
|
2014-10-16 16:14:48 +02:00
|
|
|
Branding::bail( const QString& message )
|
|
|
|
{
|
2018-02-13 11:14:45 +01:00
|
|
|
cError() << "FATAL in"
|
2014-10-16 16:14:48 +02:00
|
|
|
<< m_descriptorPath
|
|
|
|
<< "\n" + message;
|
|
|
|
::exit( EXIT_FAILURE );
|
|
|
|
}
|
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
}
|