summaryrefslogtreecommitdiffhomepage
path: root/migration
diff options
context:
space:
mode:
Diffstat (limited to 'migration')
-rw-r--r--migration/20180118_00-reltrans.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/migration/20180118_00-reltrans.cpp b/migration/20180118_00-reltrans.cpp
new file mode 100644
index 00000000..ba35e7f0
--- /dev/null
+++ b/migration/20180118_00-reltrans.cpp
@@ -0,0 +1,44 @@
+#include "migration.hpp"
+#include "options/options.hpp"
+
+using namespace options;
+using namespace migrations;
+
+enum reltrans_state
+{
+ reltrans_disabled = 0,
+ reltrans_enabled = 1,
+ reltrans_non_center = 2,
+};
+
+static const char* old_name = "compensate-translation";
+static const char* new_name = "relative-translation-mode";
+
+struct reltrans_enum : migration
+{
+ QString unique_date() const override
+ {
+ return "20180118_00";
+ }
+
+ QString name() const override
+ {
+ return "reltrans modes";
+ }
+
+ bool should_run() const override
+ {
+ auto b = make_bundle("opentrack-ui");
+ return b->contains(old_name) && !b->contains(new_name);
+ }
+
+ void run() override
+ {
+ auto b = make_bundle("opentrack-ui");
+ bool value = b->get<bool>(old_name);
+ b->store_kv(new_name, int(value ? reltrans_enabled : reltrans_disabled));
+ b->save();
+ }
+};
+
+OPENTRACK_MIGRATION(reltrans_enum);