QQuickImagePrivate can be used now
This commit is contained in:
parent
dc14dda5ea
commit
4e8ede8130
|
@ -5,13 +5,14 @@
|
||||||
|
|
||||||
#include "Image.h"
|
#include "Image.h"
|
||||||
|
|
||||||
// QQuickImagePrivate is not exported, so we
|
QSK_QT_PRIVATE_BEGIN
|
||||||
// we can't derive here
|
#include <private/qquickimage_p_p.h>
|
||||||
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
class Image::PrivateData
|
class ImagePrivate : public QQuickImagePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PrivateData()
|
ImagePrivate()
|
||||||
: sourceSizeAdjustment( false )
|
: sourceSizeAdjustment( false )
|
||||||
, deferredUpdates( true )
|
, deferredUpdates( true )
|
||||||
, dirtyPolish( false )
|
, dirtyPolish( false )
|
||||||
|
@ -27,8 +28,7 @@ class Image::PrivateData
|
||||||
};
|
};
|
||||||
|
|
||||||
Image::Image( QQuickItem* parent )
|
Image::Image( QQuickItem* parent )
|
||||||
: Inherited( parent )
|
: QQuickImage( *( new ImagePrivate() ), parent )
|
||||||
, m_data( new PrivateData() )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,50 +36,48 @@ Image::~Image()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::setVisible( bool on )
|
|
||||||
{
|
|
||||||
// QQuickItem::setVisible is no slot
|
|
||||||
Inherited::setVisible( on );
|
|
||||||
}
|
|
||||||
|
|
||||||
void Image::show()
|
void Image::show()
|
||||||
{
|
{
|
||||||
Inherited::setVisible( true );
|
setVisible( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::hide()
|
void Image::hide()
|
||||||
{
|
{
|
||||||
Inherited::setVisible( false );
|
setVisible( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::setSourceSizeAdjustment( bool on )
|
void Image::setSourceSizeAdjustment( bool on )
|
||||||
{
|
{
|
||||||
if ( on != m_data->sourceSizeAdjustment )
|
Q_D( Image );
|
||||||
|
|
||||||
|
if ( on != d->sourceSizeAdjustment )
|
||||||
{
|
{
|
||||||
m_data->sourceSizeAdjustment = on;
|
d->sourceSizeAdjustment = on;
|
||||||
Q_EMIT sourceSizeAdjustmentChanged();
|
Q_EMIT sourceSizeAdjustmentChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::sourceSizeAdjustment() const
|
bool Image::sourceSizeAdjustment() const
|
||||||
{
|
{
|
||||||
return m_data->sourceSizeAdjustment;
|
return d_func()->sourceSizeAdjustment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::setDeferredUpdates( bool on )
|
void Image::setDeferredUpdates( bool on )
|
||||||
{
|
{
|
||||||
if ( on != m_data->deferredUpdates )
|
Q_D( Image );
|
||||||
|
|
||||||
|
if ( on != d->deferredUpdates )
|
||||||
{
|
{
|
||||||
m_data->deferredUpdates = on;
|
d->deferredUpdates = on;
|
||||||
|
|
||||||
if ( !on )
|
if ( !on )
|
||||||
{
|
{
|
||||||
// when having blocked updates we reschedule them
|
// when having blocked updates we reschedule them
|
||||||
|
|
||||||
if ( m_data->dirtyPolish )
|
if ( d->dirtyPolish )
|
||||||
polish();
|
polish();
|
||||||
|
|
||||||
if ( m_data->dirtyUpdate )
|
if ( d->dirtyUpdate )
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,18 +85,20 @@ void Image::setDeferredUpdates( bool on )
|
||||||
|
|
||||||
bool Image::deferredUpdates() const
|
bool Image::deferredUpdates() const
|
||||||
{
|
{
|
||||||
return m_data->deferredUpdates;
|
return d_func()->deferredUpdates;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::setSourceSize( const QSize& size )
|
void Image::setSourceSize( const QSize& size )
|
||||||
{
|
{
|
||||||
if ( !( size.isEmpty() && sourceSize().isEmpty() ) )
|
if ( !( size.isEmpty() && sourceSize().isEmpty() ) )
|
||||||
QQuickImage::setSourceSize( size );
|
Inherited::setSourceSize( size );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::componentComplete()
|
void Image::componentComplete()
|
||||||
{
|
{
|
||||||
if ( m_data->deferredUpdates && m_data->sourceSizeAdjustment )
|
Q_D( const Image );
|
||||||
|
|
||||||
|
if ( d->deferredUpdates && d->sourceSizeAdjustment )
|
||||||
{
|
{
|
||||||
// QQuickImage::componentComplete() calls load
|
// QQuickImage::componentComplete() calls load
|
||||||
// long before we have the final geometry
|
// long before we have the final geometry
|
||||||
|
@ -119,12 +119,14 @@ void Image::itemChange( QQuickItem::ItemChange change,
|
||||||
|
|
||||||
if ( change == ItemVisibleHasChanged )
|
if ( change == ItemVisibleHasChanged )
|
||||||
{
|
{
|
||||||
|
Q_D( const Image );
|
||||||
|
|
||||||
if ( value.boolValue )
|
if ( value.boolValue )
|
||||||
{
|
{
|
||||||
if ( m_data->dirtyPolish )
|
if ( d->dirtyPolish )
|
||||||
polish();
|
polish();
|
||||||
|
|
||||||
if ( m_data->dirtyUpdate )
|
if ( d->dirtyUpdate )
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,9 +158,11 @@ void Image::geometryChanged(
|
||||||
|
|
||||||
void Image::adjustSourceSize( const QSizeF& size )
|
void Image::adjustSourceSize( const QSizeF& size )
|
||||||
{
|
{
|
||||||
if ( m_data->sourceSizeAdjustment )
|
Q_D( const Image );
|
||||||
|
|
||||||
|
if ( d->sourceSizeAdjustment )
|
||||||
{
|
{
|
||||||
if ( m_data->deferredUpdates )
|
if ( d->deferredUpdates )
|
||||||
{
|
{
|
||||||
setImplicitSize( size.width(), size.height() );
|
setImplicitSize( size.width(), size.height() );
|
||||||
polish();
|
polish();
|
||||||
|
@ -172,35 +176,39 @@ void Image::adjustSourceSize( const QSizeF& size )
|
||||||
|
|
||||||
void Image::updatePolish()
|
void Image::updatePolish()
|
||||||
{
|
{
|
||||||
if ( m_data->deferredUpdates )
|
Q_D( Image );
|
||||||
|
|
||||||
|
if ( d->deferredUpdates )
|
||||||
{
|
{
|
||||||
if ( !isVisible() )
|
if ( !isVisible() )
|
||||||
{
|
{
|
||||||
m_data->dirtyPolish = true;
|
d->dirtyPolish = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_data->sourceSizeAdjustment )
|
if ( d->sourceSizeAdjustment )
|
||||||
setSourceSize( QSize( int( width() ), int( height() ) ) );
|
setSourceSize( QSize( int( width() ), int( height() ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data->dirtyPolish = false;
|
d->dirtyPolish = false;
|
||||||
|
|
||||||
Inherited::updatePolish();
|
Inherited::updatePolish();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* Image::updatePaintNode( QSGNode* oldNode, UpdatePaintNodeData* data )
|
QSGNode* Image::updatePaintNode( QSGNode* oldNode, UpdatePaintNodeData* data )
|
||||||
{
|
{
|
||||||
if ( m_data->deferredUpdates )
|
Q_D( Image );
|
||||||
|
|
||||||
|
if ( d->deferredUpdates )
|
||||||
{
|
{
|
||||||
if ( !isVisible() )
|
if ( !isVisible() )
|
||||||
{
|
{
|
||||||
m_data->dirtyUpdate = true;
|
d->dirtyUpdate = true;
|
||||||
return oldNode;
|
return oldNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data->dirtyUpdate = false;
|
d->dirtyUpdate = false;
|
||||||
|
|
||||||
return Inherited::updatePaintNode( oldNode, data );
|
return Inherited::updatePaintNode( oldNode, data );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ QSK_QT_PRIVATE_BEGIN
|
||||||
|
|
||||||
QSK_QT_PRIVATE_END
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
#include <memory>
|
class ImagePrivate;
|
||||||
|
|
||||||
class Image : public QQuickImage
|
class Image : public QQuickImage
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,12 @@ class Image : public QQuickImage
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void show();
|
void show();
|
||||||
void hide();
|
void hide();
|
||||||
|
|
||||||
|
#ifdef Q_MOC_RUN
|
||||||
|
// methods from QQuickItem, we want to be available as string based slots
|
||||||
void setVisible( bool );
|
void setVisible( bool );
|
||||||
|
void setEnabled( bool );
|
||||||
|
#endif
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void sourceSizeAdjustmentChanged();
|
void sourceSizeAdjustmentChanged();
|
||||||
|
@ -75,6 +80,5 @@ class Image : public QQuickImage
|
||||||
private:
|
private:
|
||||||
void adjustSourceSize( const QSizeF& );
|
void adjustSourceSize( const QSizeF& );
|
||||||
|
|
||||||
class PrivateData;
|
Q_DECLARE_PRIVATE( Image )
|
||||||
std::unique_ptr< PrivateData > m_data;
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue