using qvg files to get rid of the qsvg dependency

This commit is contained in:
Uwe Rathmann 2022-11-24 09:06:39 +01:00
parent 1150c8693d
commit bfdecc0413
19 changed files with 21 additions and 44 deletions

View File

@ -6,10 +6,8 @@
#include "GraphicProvider.h"
#include <QskGraphic.h>
#include <QskGraphicIO.h>
#include <QSvgRenderer>
#include <QPainter>
#include <QImage>
#include <QFile>
const inline QString pathName( const QString& baseName, const QString& suffix )
@ -23,7 +21,7 @@ const inline QString pathName( const QString& baseName, const QString& suffix )
const QskGraphic* GraphicProvider::loadGraphic( const QString& id ) const
{
static QString scope = QStringLiteral( ":/images/" );
static QString scope = QStringLiteral( ":/images/qvg/" );
QString baseName = scope;
baseName += id.toLower().replace( ' ', '-' );
@ -31,30 +29,12 @@ const QskGraphic* GraphicProvider::loadGraphic( const QString& id ) const
auto path = pathName( baseName, QString() );
if ( path.isEmpty() )
path = pathName( baseName, ".png" );
if ( path.isEmpty() )
path = pathName( baseName, ".svg" );
path = pathName( baseName, ".qvg" );
QskGraphic graphic;
if ( !path.isEmpty() )
{
if ( path.endsWith( ".png" ) )
{
graphic = QskGraphic::fromImage( QImage( path ) );
}
else
{
QSvgRenderer renderer;
if ( renderer.load( path ) )
{
QPainter painter( &graphic );
renderer.render( &painter );
painter.end();
}
}
}
graphic = QskGraphicIO::read( path );
return graphic.isNull() ? nullptr : new QskGraphic( graphic );
}

View File

@ -1,20 +1,20 @@
<RCC>
<qresource prefix="/">
<file>images/main-icon.svg</file>
<file>images/dashboard.svg</file>
<file>images/rooms.svg</file>
<file>images/devices.svg</file>
<file>images/statistics.svg</file>
<file>images/storage.svg</file>
<file>images/members.svg</file>
<file>images/logout.svg</file>
<file>images/indoor-temperature.svg</file>
<file>images/humidity.svg</file>
<file>images/up.svg</file>
<file>images/down.svg</file>
<file>images/lamps.svg</file>
<file>images/music-system.svg</file>
<file>images/ac.svg</file>
<file>images/router.svg</file>
<qresource>
<file>images/qvg/main-icon.qvg</file>
<file>images/qvg/dashboard.qvg</file>
<file>images/qvg/rooms.qvg</file>
<file>images/qvg/devices.qvg</file>
<file>images/qvg/statistics.qvg</file>
<file>images/qvg/storage.qvg</file>
<file>images/qvg/members.qvg</file>
<file>images/qvg/logout.qvg</file>
<file>images/qvg/indoor-temperature.qvg</file>
<file>images/qvg/humidity.qvg</file>
<file>images/qvg/up.qvg</file>
<file>images/qvg/down.qvg</file>
<file>images/qvg/lamps.qvg</file>
<file>images/qvg/music-system.qvg</file>
<file>images/qvg/ac.qvg</file>
<file>images/qvg/router.qvg</file>
</qresource>
</RCC>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +1,5 @@
CONFIG += qskexample
QT += svg
QT += quick_private # TODO: examples should not use private headers
SOURCES += \
Box.cpp \
BoxWithButtons.cpp \