UI: fix initial toggle state after #20670

albatross
Adeeb Shihadeh 2021-04-14 21:02:34 -07:00
parent 1adf34f033
commit a60effc112
1 changed files with 7 additions and 5 deletions

View File

@ -116,13 +116,15 @@ class ParamControl : public ToggleControl {
Q_OBJECT
public:
ParamControl(const QString &param, const QString &title, const QString &desc, const QString &icon, QWidget *parent = nullptr) : ToggleControl(title, desc, icon, parent) {
// set initial state from param
if (Params().getBool(param.toStdString().c_str())) {
ParamControl(const QString &param, const QString &title, const QString &desc, const QString &icon, QWidget *parent = nullptr) : ToggleControl(title, desc, icon, false, parent) {
if (params.getBool(param.toStdString().c_str())) {
toggle.togglePosition();
}
QObject::connect(this, &ToggleControl::toggleFlipped, [=](int state) {
Params().putBool(param.toStdString().c_str(), (bool)state);
QObject::connect(this, &ToggleControl::toggleFlipped, [=](bool state) {
params.putBool(param.toStdString().c_str(), state);
});
}
private:
Params params;
};