takeHint added, removeHint with return code
This commit is contained in:
parent
896772c9b4
commit
0b8d857714
|
@ -115,12 +115,14 @@ void QskSkinHintTable::setHint( QskAspect::Aspect aspect, const QVariant& skinHi
|
||||||
m_hasStates = true;
|
m_hasStates = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinHintTable::removeHint( QskAspect::Aspect aspect )
|
bool QskSkinHintTable::removeHint( QskAspect::Aspect aspect )
|
||||||
{
|
{
|
||||||
if ( m_hints == nullptr )
|
if ( m_hints == nullptr )
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if ( m_hints->erase( aspect ) )
|
const bool erased = m_hints->erase( aspect );
|
||||||
|
|
||||||
|
if ( erased )
|
||||||
{
|
{
|
||||||
if ( aspect.isAnimator() )
|
if ( aspect.isAnimator() )
|
||||||
m_animatorCount--;
|
m_animatorCount--;
|
||||||
|
@ -131,6 +133,34 @@ void QskSkinHintTable::removeHint( QskAspect::Aspect aspect )
|
||||||
m_hints = nullptr;
|
m_hints = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return erased;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant QskSkinHintTable::takeHint( QskAspect::Aspect aspect )
|
||||||
|
{
|
||||||
|
if ( m_hints )
|
||||||
|
{
|
||||||
|
auto it = m_hints->find( aspect );
|
||||||
|
if ( it != m_hints->end() )
|
||||||
|
{
|
||||||
|
const auto value = it->second;
|
||||||
|
m_hints->erase( it );
|
||||||
|
|
||||||
|
if ( aspect.isAnimator() )
|
||||||
|
m_animatorCount--;
|
||||||
|
|
||||||
|
if ( m_hints->empty() )
|
||||||
|
{
|
||||||
|
delete m_hints;
|
||||||
|
m_hints = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinHintTable::clear()
|
void QskSkinHintTable::clear()
|
||||||
|
|
|
@ -33,7 +33,7 @@ class QSK_EXPORT QskSkinHintTable
|
||||||
void setColor( QskAspect::Aspect, QRgb );
|
void setColor( QskAspect::Aspect, QRgb );
|
||||||
|
|
||||||
void setColor( QskAspect::Aspect, const QColor& );
|
void setColor( QskAspect::Aspect, const QColor& );
|
||||||
QColor color( QskAspect::Aspect aspect ) const;
|
QColor color( QskAspect::Aspect ) const;
|
||||||
|
|
||||||
void setMetric( QskAspect::Aspect, qreal metric );
|
void setMetric( QskAspect::Aspect, qreal metric );
|
||||||
qreal metric( QskAspect::Aspect ) const;
|
qreal metric( QskAspect::Aspect ) const;
|
||||||
|
@ -62,7 +62,9 @@ class QSK_EXPORT QskSkinHintTable
|
||||||
|
|
||||||
void setHint( QskAspect::Aspect, const QVariant& );
|
void setHint( QskAspect::Aspect, const QVariant& );
|
||||||
const QVariant& hint( QskAspect::Aspect ) const;
|
const QVariant& hint( QskAspect::Aspect ) const;
|
||||||
void removeHint( QskAspect::Aspect );
|
|
||||||
|
bool removeHint( QskAspect::Aspect );
|
||||||
|
QVariant takeHint( QskAspect::Aspect );
|
||||||
|
|
||||||
bool hasHint( QskAspect::Aspect ) const;
|
bool hasHint( QskAspect::Aspect ) const;
|
||||||
|
|
||||||
|
@ -160,7 +162,8 @@ inline qreal QskSkinHintTable::metric( QskAspect::Aspect aspect ) const
|
||||||
return hint( aspect | QskAspect::Metric ).toReal();
|
return hint( aspect | QskAspect::Metric ).toReal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskSkinHintTable::setMargins( QskAspect::Aspect aspect, const QskMargins& margins )
|
inline void QskSkinHintTable::setMargins(
|
||||||
|
QskAspect::Aspect aspect, const QskMargins& margins )
|
||||||
{
|
{
|
||||||
setHint( aspect | QskAspect::Metric, QVariant::fromValue( margins ) );
|
setHint( aspect | QskAspect::Metric, QVariant::fromValue( margins ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue