From 2ca5ae5fc7a0bf752dc22026b627c0a3a742270b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 5 Sep 2016 17:21:44 +0200 Subject: gui/mappings: set smaller snap for XYZ splines Reported-by: @olegiy Issue: #436 --- gui/mapping-window.cpp | 92 +++++++++++++++++++++++++------------------------- gui/mapping-window.hpp | 8 ++++- 2 files changed, 53 insertions(+), 47 deletions(-) (limited to 'gui') diff --git a/gui/mapping-window.cpp b/gui/mapping-window.cpp index e47fe8e5..38ea48d8 100644 --- a/gui/mapping-window.cpp +++ b/gui/mapping-window.cpp @@ -29,56 +29,56 @@ MapWidget::MapWidget(Mappings& m) : void MapWidget::reload() { + + struct { + spline_widget* qfc; + Axis axis; + QCheckBox* checkbox; + bool altp; + } qfcs[] = { - struct { - spline_widget* qfc; - Axis axis; - QCheckBox* checkbox; - bool altp; - } qfcs[] = - { - { 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, 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++) + { 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, 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++) + { + const bool altp = qfcs[i].altp; + + Map& axis = m(qfcs[i].axis); + spline& conf = altp ? axis.spline_alt : axis.spline_main; + //const QString& name = altp ? axis.name2 : axis.name1; + //conf.set_bundle(make_bundle(name)); + qfcs[i].qfc->setConfig(&conf); + + if (altp) { - const bool altp = qfcs[i].altp; - - Map& axis = m(qfcs[i].axis); - spline& conf = altp ? axis.spline_alt : axis.spline_main; - //const QString& name = altp ? axis.name2 : axis.name1; - //conf.set_bundle(make_bundle(name)); - qfcs[i].qfc->setConfig(&conf); - - if (altp) - { - spline_widget& qfc = *qfcs[i].qfc; - connect(qfcs[i].checkbox, &QCheckBox::toggled, - this, - [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();}); - qfc.setEnabled(qfcs[i].checkbox->isChecked()); - qfc.force_redraw(); - } - - if (qfcs[i].axis >= 3) - qfcs[i].qfc->set_snap(1, 5); - else - qfcs[i].qfc->set_snap(1, 1); + spline_widget& qfc = *qfcs[i].qfc; + connect(qfcs[i].checkbox, &QCheckBox::toggled, + this, + [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();}); + qfc.setEnabled(qfcs[i].checkbox->isChecked()); + qfc.force_redraw(); } + + if (qfcs[i].axis >= 3) + qfcs[i].qfc->set_snap(1, 5); + else + qfcs[i].qfc->set_snap(.5, 2.5); } + } void MapWidget::closeEvent(QCloseEvent*) diff --git a/gui/mapping-window.hpp b/gui/mapping-window.hpp index cb589efc..7648c994 100644 --- a/gui/mapping-window.hpp +++ b/gui/mapping-window.hpp @@ -1,8 +1,13 @@ #pragma once -#include + #include "logic/mappings.hpp" #include "ui_mapping-window.h" +#include +#include +#include +#include + class MapWidget final : public QWidget { Q_OBJECT @@ -14,6 +19,7 @@ private: Mappings& m; main_settings s; + void closeEvent(QCloseEvent*) override; void save_dialog(); -- cgit v1.2.3