blocking of LayoutRequest events to QskControlPrivate
This commit is contained in:
parent
b80b9b709c
commit
74c349e6c6
|
@ -44,6 +44,7 @@ QskControlPrivate::QskControlPrivate()
|
||||||
, autoLayoutChildren( false )
|
, autoLayoutChildren( false )
|
||||||
, focusPolicy( Qt::NoFocus )
|
, focusPolicy( Qt::NoFocus )
|
||||||
, isWheelEnabled( false )
|
, isWheelEnabled( false )
|
||||||
|
, blockLayoutRequestEvents( true )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,14 +53,25 @@ QskControlPrivate::~QskControlPrivate()
|
||||||
delete [] explicitSizeHints;
|
delete [] explicitSizeHints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskControlPrivate::layoutConstraintChanged()
|
||||||
|
{
|
||||||
|
if ( !blockLayoutRequestEvents )
|
||||||
|
{
|
||||||
|
Inherited::layoutConstraintChanged();
|
||||||
|
|
||||||
|
/*
|
||||||
|
We don't send further LayoutRequest events until someone
|
||||||
|
actively requests a layout relevant information
|
||||||
|
*/
|
||||||
|
blockLayoutRequestEvents = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QskControlPrivate::implicitSizeChanged()
|
void QskControlPrivate::implicitSizeChanged()
|
||||||
{
|
{
|
||||||
Q_Q( QskControl );
|
if ( !q_func()->explicitSizeHint( Qt::PreferredSize ).isValid() )
|
||||||
if ( !q->explicitSizeHint( Qt::PreferredSize ).isValid() )
|
|
||||||
{
|
{
|
||||||
// when we have no PreferredSize we fall back
|
// when we have no explit size, the implicit size matters
|
||||||
// to the implicit size
|
|
||||||
|
|
||||||
layoutConstraintChanged();
|
layoutConstraintChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ class QskControlPrivate : public QskQuickItemPrivate
|
||||||
|
|
||||||
QSizeF implicitSizeHint() const override final;
|
QSizeF implicitSizeHint() const override final;
|
||||||
void implicitSizeChanged() override final;
|
void implicitSizeChanged() override final;
|
||||||
|
void layoutConstraintChanged() override final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DECLARE_PUBLIC( QskControl )
|
Q_DECLARE_PUBLIC( QskControl )
|
||||||
|
@ -51,6 +52,8 @@ class QskControlPrivate : public QskQuickItemPrivate
|
||||||
|
|
||||||
uint focusPolicy : 4;
|
uint focusPolicy : 4;
|
||||||
bool isWheelEnabled : 1;
|
bool isWheelEnabled : 1;
|
||||||
|
|
||||||
|
mutable bool blockLayoutRequestEvents : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,7 +26,6 @@ QskQuickItemPrivate::QskQuickItemPrivate()
|
||||||
, blockedImplicitSize( true )
|
, blockedImplicitSize( true )
|
||||||
, clearPreviousNodes( false )
|
, clearPreviousNodes( false )
|
||||||
, isInitiallyPainted( false )
|
, isInitiallyPainted( false )
|
||||||
, blockLayoutRequestEvents( true )
|
|
||||||
{
|
{
|
||||||
if ( controlFlags & QskQuickItem::DeferredLayout )
|
if ( controlFlags & QskQuickItem::DeferredLayout )
|
||||||
{
|
{
|
||||||
|
@ -55,8 +54,7 @@ QskQuickItemPrivate::~QskQuickItemPrivate()
|
||||||
|
|
||||||
void QskQuickItemPrivate::mirrorChange()
|
void QskQuickItemPrivate::mirrorChange()
|
||||||
{
|
{
|
||||||
Q_Q( QskQuickItem );
|
qskSendEventTo( q_func(), QEvent::LayoutDirectionChange );
|
||||||
qskSendEventTo( q, QEvent::LayoutDirectionChange );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskQuickItemPrivate::updateControlFlags( QskQuickItem::Flags flags )
|
void QskQuickItemPrivate::updateControlFlags( QskQuickItem::Flags flags )
|
||||||
|
@ -83,18 +81,8 @@ void QskQuickItemPrivate::updateControlFlags( QskQuickItem::Flags flags )
|
||||||
|
|
||||||
void QskQuickItemPrivate::layoutConstraintChanged()
|
void QskQuickItemPrivate::layoutConstraintChanged()
|
||||||
{
|
{
|
||||||
if ( !blockLayoutRequestEvents )
|
if ( auto item = q_func()->parentItem() )
|
||||||
{
|
qskSendEventTo( item, QEvent::LayoutRequest );
|
||||||
Q_Q( QskQuickItem );
|
|
||||||
if ( auto item = q->parentItem() )
|
|
||||||
qskSendEventTo( item, QEvent::LayoutRequest );
|
|
||||||
|
|
||||||
/*
|
|
||||||
We don't send further LayoutRequest events until someone
|
|
||||||
actively requests a layout relevant information
|
|
||||||
*/
|
|
||||||
blockLayoutRequestEvents = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskQuickItemPrivate::implicitSizeChanged()
|
void QskQuickItemPrivate::implicitSizeChanged()
|
||||||
|
@ -170,8 +158,6 @@ void QskQuickItemPrivate::setImplicitSize( qreal w, qreal h, bool doNotify )
|
||||||
|
|
||||||
if ( doNotify )
|
if ( doNotify )
|
||||||
{
|
{
|
||||||
// calling implicitSizeChanged only once, TODO ...
|
|
||||||
|
|
||||||
if ( doWidth )
|
if ( doWidth )
|
||||||
Inherited::implicitWidthChanged();
|
Inherited::implicitWidthChanged();
|
||||||
|
|
||||||
|
@ -180,6 +166,10 @@ void QskQuickItemPrivate::setImplicitSize( qreal w, qreal h, bool doNotify )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
In case of the application interferes by calling
|
||||||
|
setImplicitWidth or setImplicitHeight manually:
|
||||||
|
*/
|
||||||
void QskQuickItemPrivate::implicitWidthChanged()
|
void QskQuickItemPrivate::implicitWidthChanged()
|
||||||
{
|
{
|
||||||
Inherited::implicitWidthChanged();
|
Inherited::implicitWidthChanged();
|
||||||
|
|
|
@ -25,9 +25,8 @@ class QskQuickItemPrivate : public QQuickItemPrivate
|
||||||
void updateControlFlags( QskQuickItem::Flags );
|
void updateControlFlags( QskQuickItem::Flags );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void layoutConstraintChanged();
|
virtual void layoutConstraintChanged();
|
||||||
virtual void implicitSizeChanged();
|
virtual void implicitSizeChanged();
|
||||||
virtual QSizeF implicitSizeHint() const = 0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void cleanupNodes();
|
void cleanupNodes();
|
||||||
|
@ -42,6 +41,7 @@ class QskQuickItemPrivate : public QQuickItemPrivate
|
||||||
void updateImplicitSize( bool doNotify );
|
void updateImplicitSize( bool doNotify );
|
||||||
|
|
||||||
void setImplicitSize( qreal width, qreal height, bool doNotify );
|
void setImplicitSize( qreal width, qreal height, bool doNotify );
|
||||||
|
virtual QSizeF implicitSizeHint() const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DECLARE_PUBLIC( QskQuickItem )
|
Q_DECLARE_PUBLIC( QskQuickItem )
|
||||||
|
@ -56,9 +56,6 @@ class QskQuickItemPrivate : public QQuickItemPrivate
|
||||||
bool clearPreviousNodes : 1;
|
bool clearPreviousNodes : 1;
|
||||||
|
|
||||||
bool isInitiallyPainted : 1;
|
bool isInitiallyPainted : 1;
|
||||||
|
|
||||||
protected:
|
|
||||||
mutable bool blockLayoutRequestEvents : 1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue