reset hint fixed

This commit is contained in:
Uwe Rathmann 2019-12-14 16:40:18 +01:00
parent 4e438df051
commit cb5f7df765
2 changed files with 29 additions and 28 deletions

View File

@ -142,14 +142,9 @@ void QskControl::setBackground( const QskGradient& gradient )
void QskControl::resetBackground() void QskControl::resetBackground()
{ {
using namespace QskAspect; using namespace QskAspect;
const Aspect aspect = Control | Color;
auto& table = hintTable(); if ( resetHint( Control | Color ) )
if ( table.hint( aspect ).isValid() )
{ {
table.removeHint( aspect );
update(); update();
Q_EMIT backgroundChanged(); Q_EMIT backgroundChanged();
} }
@ -195,25 +190,17 @@ void QskControl::setMargins( const QMarginsF& margins )
void QskControl::resetMargins() void QskControl::resetMargins()
{ {
using namespace QskAspect; using namespace QskAspect;
const Aspect aspect = Control | Metric | Margin;
const auto oldMargin = marginsHint( aspect ); if ( resetHint( Control | Metric | Margin ) )
auto& table = hintTable();
if ( table.hint( aspect ).isValid() )
{ {
table.removeHint( aspect ); resetImplicitSize();
if ( marginsHint( aspect ) != oldMargin )
{
resetImplicitSize();
Q_D( const QskControl ); Q_D( const QskControl );
if ( polishOnResize() || d->autoLayoutChildren ) if ( polishOnResize() || d->autoLayoutChildren )
polish(); polish();
qskSendEventTo( this, QEvent::ContentsRectChange ); qskSendEventTo( this, QEvent::ContentsRectChange );
Q_EMIT marginsChanged(); Q_EMIT marginsChanged();
}
} }
} }

View File

@ -421,15 +421,29 @@ QskAnimationHint QskSkinnable::effectiveAnimation(
bool QskSkinnable::resetHint( QskAspect::Aspect aspect ) 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() ) /*
{ To be able to indicate, when the resolved value has changed
// return true, if the value has changed we retrieve the value before and after removing the hint from
return value != storedHint( aspect ); 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( QVariant QskSkinnable::effectiveHint(