From cb5f7df76531446548bf1b8d5fc1ccb7f361e8b2 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sat, 14 Dec 2019 16:40:18 +0100 Subject: [PATCH] reset hint fixed --- src/controls/QskControl.cpp | 29 ++++++++--------------------- src/controls/QskSkinnable.cpp | 28 +++++++++++++++++++++------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/controls/QskControl.cpp b/src/controls/QskControl.cpp index 42f445d3..aa01ba3c 100644 --- a/src/controls/QskControl.cpp +++ b/src/controls/QskControl.cpp @@ -142,14 +142,9 @@ void QskControl::setBackground( const QskGradient& gradient ) void QskControl::resetBackground() { using namespace QskAspect; - const Aspect aspect = Control | Color; - auto& table = hintTable(); - - if ( table.hint( aspect ).isValid() ) + if ( resetHint( Control | Color ) ) { - table.removeHint( aspect ); - update(); Q_EMIT backgroundChanged(); } @@ -195,25 +190,17 @@ void QskControl::setMargins( const QMarginsF& margins ) void QskControl::resetMargins() { using namespace QskAspect; - const Aspect aspect = Control | Metric | Margin; - const auto oldMargin = marginsHint( aspect ); - - auto& table = hintTable(); - if ( table.hint( aspect ).isValid() ) + if ( resetHint( Control | Metric | Margin ) ) { - table.removeHint( aspect ); - if ( marginsHint( aspect ) != oldMargin ) - { - resetImplicitSize(); + resetImplicitSize(); - Q_D( const QskControl ); - if ( polishOnResize() || d->autoLayoutChildren ) - polish(); + Q_D( const QskControl ); + if ( polishOnResize() || d->autoLayoutChildren ) + polish(); - qskSendEventTo( this, QEvent::ContentsRectChange ); - Q_EMIT marginsChanged(); - } + qskSendEventTo( this, QEvent::ContentsRectChange ); + Q_EMIT marginsChanged(); } } diff --git a/src/controls/QskSkinnable.cpp b/src/controls/QskSkinnable.cpp index 0a6a1552..301ba87d 100644 --- a/src/controls/QskSkinnable.cpp +++ b/src/controls/QskSkinnable.cpp @@ -421,15 +421,29 @@ QskAnimationHint QskSkinnable::effectiveAnimation( bool QskSkinnable::resetHint( QskAspect::Aspect aspect ) { - const auto value = m_data->hintTable.takeHint( aspect ); + if ( !m_data->hintTable.hasHint( aspect ) ) + return false; - if ( value.isValid() ) - { - // return true, if the value has changed - return value != storedHint( aspect ); - } + /* + To be able to indicate, when the resolved value has changed + we retrieve the value before and after removing the hint from + the local table. An implementation with less lookups + should be possible, but as reset is a low frequently called + operation, we prefer to keep the implementation simple. + */ - return false; + auto a = aspect; + a.setSubControl( effectiveSubcontrol( a.subControl() ) ); + a.setPlacement( effectivePlacement() ); + + if ( a.state() == QskAspect::NoState ) + a = a | skinState(); + + const auto oldHint = storedHint( a ); + + m_data->hintTable.removeHint( aspect ); + + return oldHint != storedHint( a ); } QVariant QskSkinnable::effectiveHint(