diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-04-28 17:25:35 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-04-28 21:27:35 +0200 |
commit | c80dd2e156e20f028cf4631fd7874a89c3568bab (patch) | |
tree | b15b61ad444aeaab61ea04e549ee24e98ab6415a /migration/20180428_00-module-names.cpp | |
parent | 526304a41970c1ad890cf81d92bb4b123e8608e7 (diff) |
settings: store untranslated chosen module names
Now that we translate module names, they have to be
stored as language-neutral in the config.
- add tie_setting overload with from/to conversions
- add logic to opentrack/main-window
- add migration
- remove actually useless tie_setting_traits
Diffstat (limited to 'migration/20180428_00-module-names.cpp')
-rw-r--r-- | migration/20180428_00-module-names.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/migration/20180428_00-module-names.cpp b/migration/20180428_00-module-names.cpp new file mode 100644 index 00000000..fbb7a161 --- /dev/null +++ b/migration/20180428_00-module-names.cpp @@ -0,0 +1,84 @@ +#include "migration.hpp" +#include "options/options.hpp" + +using namespace migrations; +using namespace options; + +#include "api/plugin-support.hpp" +#include "compat/library-path.hpp" + +struct module_names : migration +{ + using dylib_ptr = Modules::dylib_ptr; + using dylib_list = Modules::dylib_list; + + QString unique_date() const override + { + return "20180428_00"; + } + + QString name() const override + { + return "module names"; + } + + bool should_run() const override + { + return true; + } + + void run() override + { + struct module_type { + QString name, def; + dylib_list const& list; + }; + + Modules m { OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH }; + + module_type types[3] { + { "tracker-dll", "pt", m.trackers() }, + { "protocol-dll", "freetrack", m.protocols() }, + { "filter-dll", "accela", m.filters() }, + }; + + bundle b = make_bundle("modules"); + + for (module_type& type : types) + { + QByteArray n = type.name.toUtf8(); + + if (!b->contains(type.name)) + { + qDebug() << n.constData() << "=>" << "EMPTY"; + b->store_kv(type.name, type.def); + continue; + } + + QString value = b->get<QString>(type.name); + + bool found = false; + + for (dylib_ptr lib : type.list) + { + if (value == lib->name) + { + qDebug() << n.constData() << "=>" << lib->module_name; + b->store_kv(type.name, lib->module_name); + found = true; + break; + } + } + + if (!found) + { + qDebug() << n.constData() << "=>" << "not found" << value; + b->store_kv(type.name, type.def); + } + } + + b->save(); + } +}; + +OPENTRACK_MIGRATION(module_names); |