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()
{
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();
}
}

View File

@ -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(