summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-09-05 08:10:29 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-09-05 08:12:53 +0200
commita1783d425448394e6962f75f7aadd22b85318c59 (patch)
tree7dbbb38417f27da6a5d23457a18f6100ad9af634
parent590ed20fe73848607ff40f2620c413f8ec5ac0ee (diff)
qfc, mapping: disallow editing and change color when checkbox disabled
Sponsored-by: TrackHat
-rw-r--r--facetracknoir/curve-config.cpp36
-rw-r--r--qfunctionconfigurator/qfunctionconfigurator.cpp3
-rw-r--r--qfunctionconfigurator/qfunctionconfigurator.h5
3 files changed, 30 insertions, 14 deletions
diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp
index e199d005..2e9065b4 100644
--- a/facetracknoir/curve-config.cpp
+++ b/facetracknoir/curve-config.cpp
@@ -20,23 +20,24 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) :
struct {
QFunctionConfigurator* qfc;
Axis axis;
+ QCheckBox* checkbox;
bool altp;
} qfcs[] =
{
- { ui.rxconfig, Yaw, false },
- { ui.ryconfig, Pitch, false},
- { ui.rzconfig, Roll, false },
- { ui.txconfig, TX, false },
- { ui.tyconfig, TY, false },
- { ui.tzconfig, TZ, false },
+ { ui.rxconfig, Yaw, nullptr, false },
+ { ui.ryconfig, Pitch, nullptr, false },
+ { ui.rzconfig, Roll, nullptr, false },
+ { ui.txconfig, TX, nullptr, false },
+ { ui.tyconfig, TY, nullptr, false },
+ { ui.tzconfig, TZ, nullptr, false },
- { ui.rxconfig_alt, Yaw, true },
- { ui.ryconfig_alt, Pitch, true},
- { ui.rzconfig_alt, Roll, true },
- { ui.txconfig_alt, TX, true },
- { ui.tyconfig_alt, TY, true },
- { ui.tzconfig_alt, TZ, true },
- { nullptr, Yaw, false }
+ { ui.rxconfig_alt, Yaw, ui.rx_altp, true },
+ { ui.ryconfig_alt, Pitch, ui.ry_altp, true },
+ { ui.rzconfig_alt, Roll, ui.rz_altp, true },
+ { ui.txconfig_alt, TX, ui.tx_altp, true },
+ { ui.tyconfig_alt, TY, ui.ty_altp, true },
+ { ui.tzconfig_alt, TZ, ui.tz_altp, true },
+ { nullptr, Yaw, nullptr, false }
};
for (int i = 0; qfcs[i].qfc; i++)
@@ -45,7 +46,14 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) :
Mapping& axis = m(qfcs[i].axis);
Map* conf = altp ? &axis.curveAlt : &axis.curve;
const auto& name = qfcs[i].altp ? axis.name2 : axis.name1;
-
+ if (altp)
+ {
+ QFunctionConfigurator& qfc = *qfcs[i].qfc;
+ connect(qfcs[i].checkbox, &QCheckBox::toggled,
+ [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();});
+ qfc.setEnabled(qfcs[i].checkbox->isChecked());
+ qfc.force_redraw();
+ }
qfcs[i].qfc->setConfig(conf, name);
}
}
diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp
index 144b69e1..8a61c8f6 100644
--- a/qfunctionconfigurator/qfunctionconfigurator.cpp
+++ b/qfunctionconfigurator/qfunctionconfigurator.cpp
@@ -151,7 +151,10 @@ void QFunctionConfigurator::paintEvent(QPaintEvent *e)
QPainter p(this);
if (_background.isNull())
+ {
+ _draw_function = true;
drawBackground();
+ }
if (_draw_function) {
_draw_function = false;
diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h
index 59c8ffeb..845dd29c 100644
--- a/qfunctionconfigurator/qfunctionconfigurator.h
+++ b/qfunctionconfigurator/qfunctionconfigurator.h
@@ -34,6 +34,11 @@ public:
spline_color = color;
update();
}
+ void force_redraw()
+ {
+ _background = QPixmap();
+ update();
+ }
protected slots:
void paintEvent(QPaintEvent *e);
void mousePressEvent(QMouseEvent *e);