summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-10-20 06:26:17 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-10-20 06:26:17 +0200
commit957a2bf95fed2362d50de64721642dbc0bd8f911 (patch)
tree452d6d3f2d2c650cf463b278a1cd13729ea1295c
parent1f6ca4d1ded3146f1e358007528d9f1ab2b522ec (diff)
options, migration: simplify
-rw-r--r--logic/main-settings.cpp14
-rw-r--r--migration/20171020_00-max-pitch-output.cpp8
-rw-r--r--options/group.cpp3
3 files changed, 18 insertions, 7 deletions
diff --git a/logic/main-settings.cpp b/logic/main-settings.cpp
index 5cb6e64e..b1b9a132 100644
--- a/logic/main-settings.cpp
+++ b/logic/main-settings.cpp
@@ -60,6 +60,16 @@ key_opts::key_opts(bundle b, const QString& name) :
button(b, QString("button-%1").arg(name), -1)
{}
+using max_clamp = axis_opts::max_clamp;
+
+static max_clamp get_max_x(Axis k)
+{
+ if (k == Pitch)
+ return max_clamp::r90;
+ if (k >= Yaw)
+ return max_clamp::r180;
+ return max_clamp::t30;
+}
axis_opts::axis_opts(bundle b_settings_window, bundle b_mapping_window, QString pfx, Axis idx) :
b_settings_window(b_settings_window),
@@ -68,8 +78,8 @@ axis_opts::axis_opts(bundle b_settings_window, bundle b_mapping_window, QString
src(b_settings_window, n(pfx, "source-index"), idx),
invert(b_settings_window, n(pfx, "invert-sign"), false),
altp(b_mapping_window, n(pfx, "alt-axis-sign"), false),
- clamp_x(b_mapping_window, n(pfx, "max-value"), idx >= Yaw ? r180 : t30),
- clamp_y(b_mapping_window, n(pfx, "max-output-value"), idx >= Yaw ? o_r180 : o_t75)
+ clamp_x(b_mapping_window, n(pfx, "max-value"), get_max_x(idx)),
+ clamp_y(b_mapping_window, n(pfx, "max-output-value"), idx >= Yaw ? o_r90 : o_t75)
{}
QString axis_opts::n(QString pfx, QString name)
diff --git a/migration/20171020_00-max-pitch-output.cpp b/migration/20171020_00-max-pitch-output.cpp
index e7ed474a..a5467b28 100644
--- a/migration/20171020_00-max-pitch-output.cpp
+++ b/migration/20171020_00-max-pitch-output.cpp
@@ -37,7 +37,7 @@ struct max_pitch_output : migration
bundle b = make_bundle("opentrack-mappings");
- if (b->contains(name) && b->get<QVariant>(name) != QVariant::Invalid)
+ if (b->contains(name))
return false;
}
@@ -51,9 +51,9 @@ struct max_pitch_output : migration
for (const spline& spl : { pitch_spline_1, pitch_spline_2 })
for (QPointF& point : spl.get_points())
if (point.y() - 1e-2 > 90)
- return false;
+ return true;
- return true;
+ return false;
}
void run() override
@@ -61,7 +61,7 @@ struct max_pitch_output : migration
main_settings s;
axis_opts& pitch_opts = s.a_pitch;
- pitch_opts.clamp_y = axis_opts::o_r90;
+ pitch_opts.clamp_y = axis_opts::o_r180;
s.b_map->save();
}
diff --git a/options/group.cpp b/options/group.cpp
index 964ad791..2d5588a1 100644
--- a/options/group.cpp
+++ b/options/group.cpp
@@ -62,7 +62,8 @@ void group::put(const QString &s, const QVariant &d)
bool group::contains(const QString &s) const
{
- return kvs.find(s) != kvs.cend();
+ const auto it = kvs.find(s);
+ return it != kvs.cend() && it->second != QVariant::Invalid;
}
bool group::is_portable_installation()