7#include "QskGraphicProvider.h"
10#include <qhashfunctions.h>
12static void qskRegisterIcon()
14 qRegisterMetaType< QskIcon >();
16#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
17 QMetaType::registerEqualsComparator< QskIcon >();
21Q_CONSTRUCTOR_FUNCTION( qskRegisterIcon )
24 : m_data( new Data() )
28QskIcon::QskIcon(
const QUrl& source )
30 , m_data( new Data() )
35 : m_data( new Data() )
37 if ( !graphic.isNull() )
41bool QskIcon::operator==(
const QskIcon& other )
const noexcept
43 if ( m_data == other.m_data )
46 if ( !m_source.isEmpty() || !other.m_source.isEmpty() )
47 return m_source == other.m_source;
49 if ( m_data->graphic && other.m_data->graphic )
50 return m_data->graphic == other.m_data->graphic;
55void QskIcon::setSource(
const QUrl& source )
57 if ( source != m_source )
68void QskIcon::setGraphic(
const QskGraphic& graphic )
73 if ( m_data->graphic )
74 *m_data->graphic = graphic;
81 if ( m_data->graphic ==
nullptr && !m_source.isEmpty() )
91 m_data->graphic =
new QskGraphic( Qsk::loadGraphic( m_source ) );
94 return m_data->graphic ? *m_data->graphic :
QskGraphic();
97QskHashValue QskIcon::hash( QskHashValue seed )
const
99 if ( !m_source.isEmpty() )
100 return qHash( m_source, seed );
102 return maybeGraphic().hash( seed );
105#ifndef QT_NO_DEBUG_STREAM
109QDebug operator<<( QDebug debug,
const QskIcon& icon )
111 QDebugStateSaver saver( debug );
114 debug <<
"Icon" <<
"( ";
115 if ( !icon.source().isEmpty() )
117 debug << icon.source();
121 const auto graphic = icon.maybeGraphic();
122 if ( !graphic.isNull() )
123 debug <<
"I:" << graphic.hash( 0 );
133#include "moc_QskIcon.cpp"
A paint device for scalable graphics.