QskControl::maybeUnresized() added
This commit is contained in:
parent
309106965d
commit
b1f56594bc
@ -210,7 +210,9 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||
|
||||
#if 0
|
||||
// can we do something useful with overloading ???
|
||||
|
||||
QSGTransformNode* createTransformNode() override;
|
||||
void transformChanged() override;
|
||||
#endif
|
||||
|
||||
void implicitWidthChanged() override;
|
||||
@ -227,12 +229,13 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||
sizeof( QQuickItemPrivate::ExtraData ) -> 184
|
||||
sizeof( QQuickItemPrivate ) -> 320
|
||||
|
||||
( these numbers include pointers to optional extra data, but not
|
||||
the size for the extra data. So the effective memory footprint,
|
||||
is often even worse ).
|
||||
|
||||
sizeof( QskControlPrivate ) -> sizeof( QQuickItemPrivate ) + 32
|
||||
sizeof( QskSkinnable::PrivateData ) -> 40
|
||||
|
||||
( these numbers include pointers to optional extra data, that might
|
||||
increase the effective memory footprint, when being accurate ).
|
||||
|
||||
It might be possible to save some bytes, but in the end QskControl
|
||||
is heavy simply because of deriving from QQuickItem. So without
|
||||
patching Qt the only way to limit the memory footprint of an application
|
||||
@ -1648,6 +1651,26 @@ void QskControl::componentComplete()
|
||||
Inherited::componentComplete();
|
||||
}
|
||||
|
||||
bool QskControl::maybeUnresized() const
|
||||
{
|
||||
Q_D( const QskControl );
|
||||
|
||||
if ( d->width <= 0.0 && d->height <= 0.0 )
|
||||
{
|
||||
/*
|
||||
Unfortunately the list of items to-be-polished is not processed
|
||||
in top/down order and we might run into updatePolish() before
|
||||
having a proper size. But when the parentItem() is waiting
|
||||
for to-be-polished, we assume, that we will be resized then
|
||||
and run into another updatePolish() then.
|
||||
*/
|
||||
if ( d->polishOnResize && qskIsPolishScheduled( parentItem() ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QskControl::releaseResources()
|
||||
{
|
||||
Inherited::releaseResources();
|
||||
@ -1847,7 +1870,7 @@ void QskControl::updatePolish()
|
||||
|
||||
d->blockedPolish = false;
|
||||
|
||||
if ( d->autoLayoutChildren )
|
||||
if ( d->autoLayoutChildren && !maybeUnresized() )
|
||||
{
|
||||
const QRectF rect = layoutRect();
|
||||
|
||||
@ -1951,6 +1974,16 @@ QskControl* QskControl::owningControl() const
|
||||
return const_cast< QskControl* >( this );
|
||||
}
|
||||
|
||||
QRectF QskControl::layoutRect() const
|
||||
{
|
||||
Q_D( const QskControl );
|
||||
|
||||
if ( d->width <= 0.0 && d->height <= 0.0 )
|
||||
return QRectF();
|
||||
|
||||
return layoutRectForSize( size() );
|
||||
}
|
||||
|
||||
QRectF QskControl::layoutRectForSize( const QSizeF& size ) const
|
||||
{
|
||||
const QRectF r( 0.0, 0.0, size.width(), size.height() );
|
||||
|
@ -260,6 +260,8 @@ class QSK_EXPORT QskControl : public QQuickItem, public QskSkinnable
|
||||
virtual void aboutToShow(); // called in updatePolish
|
||||
virtual void updateLayout(); // called in updatePolish
|
||||
|
||||
bool maybeUnresized() const;
|
||||
|
||||
private:
|
||||
// don't use boundingRect - it seems to be deprecated
|
||||
QRectF boundingRect() const override final { return rect(); }
|
||||
@ -322,11 +324,6 @@ inline QSizeF QskControl::preferredSize() const
|
||||
return explicitSizeHint( Qt::PreferredSize );
|
||||
}
|
||||
|
||||
inline QRectF QskControl::layoutRect() const
|
||||
{
|
||||
return layoutRectForSize( size() );
|
||||
}
|
||||
|
||||
inline QskControl* qskControlCast( QObject* object )
|
||||
{
|
||||
return qobject_cast< QskControl* >( object );
|
||||
|
@ -246,6 +246,9 @@ bool QskTabView::event( QEvent* event )
|
||||
|
||||
void QskTabView::updateLayout()
|
||||
{
|
||||
if ( maybeUnresized() )
|
||||
return;
|
||||
|
||||
m_data->tabBar->setGeometry( subControlRect( TabBar ) );
|
||||
|
||||
#if 1
|
||||
|
@ -404,6 +404,7 @@ void QskGridBox::invalidate()
|
||||
|
||||
void QskGridBox::updateLayout()
|
||||
{
|
||||
if ( !maybeUnresized() )
|
||||
m_data->engine.setGeometries( layoutRect() );
|
||||
}
|
||||
|
||||
|
@ -198,6 +198,7 @@ void QskLinearBox::invalidate()
|
||||
|
||||
void QskLinearBox::updateLayout()
|
||||
{
|
||||
if ( !maybeUnresized() )
|
||||
m_data->engine.setGeometries( layoutRect() );
|
||||
}
|
||||
|
||||
@ -479,7 +480,6 @@ void QskLinearBox::insertItem(
|
||||
item->stackAfter( children.last() );
|
||||
}
|
||||
|
||||
|
||||
qskSetItemActive( this, item, true );
|
||||
|
||||
#if 1
|
||||
|
@ -408,6 +408,9 @@ QRectF QskStackBox::geometryForItemAt( int index ) const
|
||||
|
||||
void QskStackBox::updateLayout()
|
||||
{
|
||||
if ( maybeUnresized() )
|
||||
return;
|
||||
|
||||
const auto idx = m_data->currentIndex;
|
||||
|
||||
if ( idx >= 0 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user