forked from qt-creator/qt-creator
Utils: Introduce a BaseAspect::setEnabler(BoolAspect *)
A convenience method to tie the enabled state of an aspect to some other bool aspect, to be used e.g. when settings item availability depends on some check box. Makes it harder to miss one of the three necessary steps. Change-Id: I8c120bb6846aea2a503614f7c73fa57a149cab41 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -309,6 +309,17 @@ void BaseAspect::setEnabled(bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Makes the enabled state of this aspect depend on the checked state of \a checker.
|
||||
*/
|
||||
void BaseAspect::setEnabler(BoolAspect *checker)
|
||||
{
|
||||
QTC_ASSERT(checker, return);
|
||||
setEnabled(checker->value());
|
||||
connect(checker, &BoolAspect::volatileValueChanged, this, &BaseAspect::setEnabled);
|
||||
connect(checker, &BoolAspect::valueChanged, this, &BaseAspect::setEnabled);
|
||||
}
|
||||
|
||||
bool BaseAspect::isReadOnly() const
|
||||
{
|
||||
return d->m_readOnly;
|
||||
|
||||
Reference in New Issue
Block a user