summaryrefslogtreecommitdiffhomepage
path: root/migration
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-10-13 18:53:28 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-10-13 18:53:28 +0200
commit9da6dff1800d6b6598e6ad04465ee8b9cabb4167 (patch)
tree2f1692597748ce37d2ce147e8ed9f0c7d71d00e9 /migration
parent535e81402a65fa410e98899cd1780784d2f9815a (diff)
tracker/pt, options: fix threshold slider
It's only the tie_setting(slider_value, QSlider) that has race-free slider updates. Needed to update the threshold slider representation. Remove the tie_setting(int, QSlider) overload since it doesn't have the logic. Add a migration. Add base_value::notify() for use-cases like the checkbox updating the label.
Diffstat (limited to 'migration')
-rw-r--r--migration/20171013_00-tracker-pt-threshold.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/migration/20171013_00-tracker-pt-threshold.cpp b/migration/20171013_00-tracker-pt-threshold.cpp
new file mode 100644
index 00000000..4408ccc0
--- /dev/null
+++ b/migration/20171013_00-tracker-pt-threshold.cpp
@@ -0,0 +1,54 @@
+/* Copyright (c) 2017, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
+#include "migration.hpp"
+#include "options/options.hpp"
+#include "compat/util.hpp"
+//#include "tracker-pt/ftnoir_tracker_pt_settings.h"
+
+using namespace options;
+using namespace migrations;
+
+static constexpr const char* old_name = "threshold-primary";
+static constexpr const char* new_name = "threshold-slider";
+static constexpr const char* bundle_name = "tracker-pt";
+
+struct move_int_to_slider : migration
+{
+ QString unique_date() const override
+ {
+ return "20171013_00";
+ }
+
+
+ QString name() const override
+ {
+ return "tracker/pt threshold slider (int -> slider_value)";
+ }
+
+ bool should_run() const override
+ {
+ bundle b = make_bundle("tracker-pt");
+
+ return b->contains(old_name) && !b->contains(new_name);
+ }
+
+ void run() override
+ {
+ bundle b = make_bundle("tracker-pt");
+
+ value<int> old_val(b, old_name, 128);
+ value<slider_value> new_val(b, new_name, slider_value(128, 0, 255));
+
+ new_val = slider_value(old_val.to<int>(), 0, 255);
+
+ b->save();
+ }
+};
+
+OPENTRACK_MIGRATION(move_int_to_slider);