blocking of LayoutRequest events to QskControlPrivate

This commit is contained in:
Uwe Rathmann 2019-09-04 08:08:13 +02:00
parent b80b9b709c
commit 74c349e6c6
4 changed files with 29 additions and 27 deletions

View File

@ -44,6 +44,7 @@ QskControlPrivate::QskControlPrivate()
, autoLayoutChildren( false )
, focusPolicy( Qt::NoFocus )
, isWheelEnabled( false )
, blockLayoutRequestEvents( true )
{
}
@ -52,14 +53,25 @@ QskControlPrivate::~QskControlPrivate()
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()
{
Q_Q( QskControl );
if ( !q->explicitSizeHint( Qt::PreferredSize ).isValid() )
if ( !q_func()->explicitSizeHint( Qt::PreferredSize ).isValid() )
{
// when we have no PreferredSize we fall back
// to the implicit size
// when we have no explit size, the implicit size matters
layoutConstraintChanged();
}
}

View File

@ -35,6 +35,7 @@ class QskControlPrivate : public QskQuickItemPrivate
QSizeF implicitSizeHint() const override final;
void implicitSizeChanged() override final;
void layoutConstraintChanged() override final;
private:
Q_DECLARE_PUBLIC( QskControl )
@ -51,6 +52,8 @@ class QskControlPrivate : public QskQuickItemPrivate
uint focusPolicy : 4;
bool isWheelEnabled : 1;
mutable bool blockLayoutRequestEvents : 1;
};
#endif

View File

@ -26,7 +26,6 @@ QskQuickItemPrivate::QskQuickItemPrivate()
, blockedImplicitSize( true )
, clearPreviousNodes( false )
, isInitiallyPainted( false )
, blockLayoutRequestEvents( true )
{
if ( controlFlags & QskQuickItem::DeferredLayout )
{
@ -55,8 +54,7 @@ QskQuickItemPrivate::~QskQuickItemPrivate()
void QskQuickItemPrivate::mirrorChange()
{
Q_Q( QskQuickItem );
qskSendEventTo( q, QEvent::LayoutDirectionChange );
qskSendEventTo( q_func(), QEvent::LayoutDirectionChange );
}
void QskQuickItemPrivate::updateControlFlags( QskQuickItem::Flags flags )
@ -83,18 +81,8 @@ void QskQuickItemPrivate::updateControlFlags( QskQuickItem::Flags flags )
void QskQuickItemPrivate::layoutConstraintChanged()
{
if ( !blockLayoutRequestEvents )
{
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;
}
if ( auto item = q_func()->parentItem() )
qskSendEventTo( item, QEvent::LayoutRequest );
}
void QskQuickItemPrivate::implicitSizeChanged()
@ -170,8 +158,6 @@ void QskQuickItemPrivate::setImplicitSize( qreal w, qreal h, bool doNotify )
if ( doNotify )
{
// calling implicitSizeChanged only once, TODO ...
if ( doWidth )
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()
{
Inherited::implicitWidthChanged();

View File

@ -25,9 +25,8 @@ class QskQuickItemPrivate : public QQuickItemPrivate
void updateControlFlags( QskQuickItem::Flags );
protected:
void layoutConstraintChanged();
virtual void layoutConstraintChanged();
virtual void implicitSizeChanged();
virtual QSizeF implicitSizeHint() const = 0;
private:
void cleanupNodes();
@ -42,6 +41,7 @@ class QskQuickItemPrivate : public QQuickItemPrivate
void updateImplicitSize( bool doNotify );
void setImplicitSize( qreal width, qreal height, bool doNotify );
virtual QSizeF implicitSizeHint() const = 0;
private:
Q_DECLARE_PUBLIC( QskQuickItem )
@ -56,9 +56,6 @@ class QskQuickItemPrivate : public QQuickItemPrivate
bool clearPreviousNodes : 1;
bool isInitiallyPainted : 1;
protected:
mutable bool blockLayoutRequestEvents : 1;
};
#endif