Merge branch 'issue-1160'

FIXES #1160
This commit is contained in:
Adriaan de Groot 2019-05-27 16:38:35 +02:00
commit 06bd8749a2
3 changed files with 29 additions and 17 deletions

View File

@ -15,6 +15,10 @@ This release contains contributions from (alphabetically by first name):
- *branding* now supports os-release variables in the *strings* section,
which allows re-using (at runtime) information set in /etc/os-release .
This requires KDE Frameworks 5.58. #1150
- *branding* allows the use of FreeDesktop.org icon names for the
*productLogo* and *productIcon* keys. If a file is named there, then
the file is used, and otherwise the icon is looked up in the current
theme.
# 3.2.8 (2019-05-10) #

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Raul Rodrigo Segura (raurodse)
*
* Calamares is free software: you can redistribute it and/or modify
@ -29,6 +29,7 @@
#include <QDir>
#include <QFile>
#include <QIcon>
#include <QPixmap>
#include <QVariantMap>
@ -185,9 +186,16 @@ Branding::Branding( const QString& brandingFilePath,
loadStrings( m_images, doc, "images",
[&]( const QString& s ) -> QString
{
QFileInfo imageFi( componentDir.absoluteFilePath( expand( s ) ) );
const QString imageName( expand( s ) );
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() )
bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
return imageName; // Not turned into a path
}
return imageFi.absoluteFilePath();
}
);
@ -289,16 +297,22 @@ Branding::imagePath( Branding::ImageEntry imageEntry ) const
QPixmap
Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const
{
QPixmap pixmap =
ImageRegistry::instance()->pixmap( imagePath( imageEntry ), size );
if ( pixmap.isNull() )
const auto path = imagePath( imageEntry );
if ( path.contains( '/' ) )
{
Q_ASSERT( false );
return QPixmap();
}
QPixmap pixmap = ImageRegistry::instance()->pixmap( path, size );
Q_ASSERT( !pixmap.isNull() );
return pixmap;
}
else
{
auto icon = QIcon::fromTheme(path);
Q_ASSERT( !icon.isNull() );
return icon.pixmap( size );
}
}
QString
Branding::stylesheet() const

View File

@ -61,9 +61,9 @@ ImageRegistry::cacheKey( const QSize& size, float opacity, QColor tint )
QPixmap
ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, QColor tint )
{
Q_ASSERT( !(size.width() < 0 || size.height() < 0) );
if ( size.width() < 0 || size.height() < 0 )
{
Q_ASSERT( false );
return QPixmap();
}
@ -159,15 +159,9 @@ ImageRegistry::putInCache( const QString& image, const QSize& size, CalamaresUti
if ( s_cache.contains( image ) )
{
subcache = s_cache.value( image );
if ( subcache.contains( mode ) )
{
subsubcache = subcache.value( mode );
/* if ( subsubcache.contains( size.width() * size.height() ) )
{
Q_ASSERT( false );
}*/
}
}