Refactor setup hardware, trainer and calibration
This commit is contained in:
@@ -32,15 +32,17 @@ class AutoCheckBox: public QCheckBox
|
||||
QCheckBox(parent),
|
||||
field(nullptr),
|
||||
panel(nullptr),
|
||||
lock(false)
|
||||
lock(false),
|
||||
invert(false)
|
||||
{
|
||||
connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
|
||||
connect(this, &AutoCheckBox::toggled, this, &AutoCheckBox::onToggled);
|
||||
}
|
||||
|
||||
void setField(bool & field, GenericPanel * panel = nullptr)
|
||||
void setField(bool & field, GenericPanel * panel = nullptr, bool invert = false)
|
||||
{
|
||||
this->field = &field;
|
||||
this->panel = panel;
|
||||
this->invert = invert;
|
||||
updateValue();
|
||||
}
|
||||
|
||||
@@ -49,11 +51,17 @@ class AutoCheckBox: public QCheckBox
|
||||
QCheckBox::setEnabled(enabled);
|
||||
}
|
||||
|
||||
void setInvert(bool invert)
|
||||
{
|
||||
this->invert = invert;
|
||||
updateValue();
|
||||
}
|
||||
|
||||
void updateValue()
|
||||
{
|
||||
if (field) {
|
||||
lock = true;
|
||||
setChecked(*field);
|
||||
setChecked(invert ? !(*field) : *field);
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
@@ -67,8 +75,9 @@ class AutoCheckBox: public QCheckBox
|
||||
if (panel && panel->lock)
|
||||
return;
|
||||
if (field && !lock) {
|
||||
*field = checked;
|
||||
emit currentDataChanged(checked);
|
||||
const bool val = invert ? !checked : checked;
|
||||
*field = val;
|
||||
emit currentDataChanged(val);
|
||||
if (panel)
|
||||
emit panel->modified();
|
||||
}
|
||||
@@ -78,4 +87,5 @@ class AutoCheckBox: public QCheckBox
|
||||
bool *field = nullptr;
|
||||
GenericPanel *panel = nullptr;
|
||||
bool lock = false;
|
||||
bool invert = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user