This commit is contained in:
Uwe Rathmann 2022-11-24 09:10:49 +01:00
commit 86cb02466c
21 changed files with 28 additions and 49 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 \

View File

@ -22,7 +22,7 @@ int main( int argc, char* argv[] )
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
QskFocusIndicator* focusIndicator = new QskFocusIndicator();
auto focusIndicator = new QskFocusIndicator();
focusIndicator->setObjectName( "FocusIndicator" );
MainWindow window;

View File

@ -125,11 +125,9 @@ namespace
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
registerUncreatableType< T >( className );
#else
// the class name without the "Qsk" prefix
/*
According to the QML naming rules uncreatables have to
start with a lowercase letter ( since Qt6 ) , while namespaces
start with a lowercase letter ( since Qt6 ), while namespaces
and creatable items usually start with a upper letter.
This results in an odd naming scheme for the enums defined inside of gadgets.
@ -140,7 +138,11 @@ namespace
enums are removed from the first and everything else than the enums from
the second. TODO ...
*/
registerUncreatableMetaObject( T::staticMetaObject, className );
if ( T::staticMetaObject.enumeratorCount() > 0 )
{
registerUncreatableMetaObject( T::staticMetaObject, className );
}
QByteArray name = className;
name.data()[0] = std::tolower( name.data()[0] );