[plasmalnf] Search for theme screenshots

- Search in branding dir, and ., for relative paths,
 - Absolute paths used as-is.
 - Document search as such.
main
Adriaan de Groot 7 years ago
parent bfb37e6b37
commit fa933b9a16

@ -22,10 +22,39 @@
#include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h"
#include "Branding.h"
#include <QDir>
#include <QFileInfo>
#include <QHBoxLayout>
#include <QLabel>
#include <QRadioButton>
#include <QString>
/**
* Massage the given @p path to the most-likely
* path that actually contains a screenshot. For
* empty image paths, returns the QRC path for an
* empty screenshot. Returns blank if the path
* doesn't exist anywhere in the search paths.
*/
static QString _munge_imagepath( const QString& path )
{
if ( path.isEmpty() )
return ":/view-preview.png";
if ( path.startsWith( '/' ) )
return path;
if ( QFileInfo::exists( path ) )
return path;
QFileInfo fi( QDir( Calamares::Branding::instance()->componentDirectory() ), path );
if ( fi.exists() )
return fi.absoluteFilePath();
return QString();
}
ThemeWidget::ThemeWidget(const ThemeInfo& info, QWidget* parent)
: QWidget( parent )
@ -42,7 +71,7 @@ ThemeWidget::ThemeWidget(const ThemeInfo& info, QWidget* parent)
qMax(12 * CalamaresUtils::defaultFontHeight(), 120),
qMax(8 * CalamaresUtils::defaultFontHeight(), 80) };
QPixmap image( info.imagePath.isEmpty() ? ":/view-preview.png" : info.imagePath );
QPixmap image( _munge_imagepath( info.imagePath ) );
if ( image.isNull() )
{
// Not found or not specified, so convert the name into some (horrible, likely)

@ -32,6 +32,10 @@ lnftool: "/usr/bin/lookandfeeltool"
# Themes with no image set at all get a "missing screenshot" image; if the
# image file is not found, they get a color swatch based on the image name.
#
# The image may be an absolute path. If it is a relative path, though,
# it is searched in the current directory and in the branding directory
# (i.e. relative to the directory where your branding.desc lives).
#
# Valid forms of entries in the *themes* key:
# - A single string (unquoted), which is the theme id
# - A pair of *theme* and *image* keys, e.g.

Loading…
Cancel
Save