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:
hjk
2021-04-12 13:43:24 +02:00
parent ef108d7a06
commit 38b4536090
6 changed files with 22 additions and 25 deletions

View File

@@ -72,8 +72,8 @@ QmlProfilerSettings::QmlProfilerSettings()
flushInterval.setSettingsKey("Analyzer.QmlProfiler.FlushInterval");
flushInterval.setRange(1, 10000000);
flushInterval.setDefaultValue(1000);
flushInterval.setLabelText(tr("Flush interval (ms):", nullptr));
flushInterval.setEnabled(false); // Controled by flushEnabled.
flushInterval.setLabelText(tr("Flush interval (ms):"));
flushInterval.setEnabler(&flushEnabled);
registerAspect(&lastTraceFile);
lastTraceFile.setSettingsKey("Analyzer.QmlProfiler.LastTraceFile");
@@ -88,11 +88,6 @@ QmlProfilerSettings::QmlProfilerSettings()
"for example if multiple QML engines start and stop sequentially during a single run of\n"
"the program."));
connect(&flushEnabled, &BoolAspect::volatileValueChanged,
&flushInterval, &BaseAspect::setEnabled);
connect(&flushEnabled, &BoolAspect::valueChanged,
&flushInterval, &BaseAspect::setEnabled);
// Read stored values
readSettings(Core::ICore::settings());
}