summaryrefslogtreecommitdiffhomepage
path: root/migration/20180118_00-reltrans.cpp
blob: 09e3847e831482ecc287975b0872c9d13863a09d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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_variant(old_name).value<bool>();
        b->store_kv(new_name, int(value ? reltrans_enabled : reltrans_disabled));
        b->save();
    }
};

OPENTRACK_MIGRATION(reltrans_enum)