| 77 | |
| 78 | agi::hotkey::Hotkey *inst = nullptr; |
| 79 | void init() { |
| 80 | inst = new agi::hotkey::Hotkey( |
| 81 | config::path->Decode("?user/hotkey.json"), |
| 82 | GET_DEFAULT_CONFIG(default_hotkey)); |
| 83 | |
| 84 | auto migrations = OPT_GET("App/Hotkey Migrations")->GetListString(); |
| 85 | |
| 86 | if (boost::find(migrations, "7035") == end(migrations)) { |
| 87 | migrate_hotkeys(added_hotkeys_7035); |
| 88 | migrations.emplace_back("7035"); |
| 89 | } |
| 90 | |
| 91 | if (boost::find(migrations, "7070") == end(migrations)) { |
| 92 | migrate_hotkeys(added_hotkeys_7070); |
| 93 | migrations.emplace_back("7070"); |
| 94 | } |
| 95 | |
| 96 | if (boost::find(migrations, "edit/line/duplicate/shift_back") == end(migrations)) { |
| 97 | migrate_hotkeys(added_hotkeys_shift_back); |
| 98 | migrations.emplace_back("edit/line/duplicate/shift_back"); |
| 99 | } |
| 100 | |
| 101 | if (boost::find(migrations, "duplicate -> split") == end(migrations)) { |
| 102 | auto hk_map = hotkey::inst->GetHotkeyMap(); |
| 103 | for (auto const& hotkey : boost::make_iterator_range(hk_map.equal_range("edit/line/duplicate/shift"))) { |
| 104 | auto combo = agi::hotkey::Combo(hotkey.second.Context(), "edit/line/split/before", hotkey.second.Str()); |
| 105 | hk_map.emplace(combo.CmdName(), combo); |
| 106 | } |
| 107 | for (auto const& hotkey : boost::make_iterator_range(hk_map.equal_range("edit/line/duplicate/shift_back"))) { |
| 108 | auto combo = agi::hotkey::Combo(hotkey.second.Context(), "edit/line/split/after", hotkey.second.Str()); |
| 109 | hk_map.emplace(combo.CmdName(), combo); |
| 110 | } |
| 111 | |
| 112 | hk_map.erase("edit/line/duplicate/shift"); |
| 113 | hk_map.erase("edit/line/duplicate/shift_back"); |
| 114 | |
| 115 | hotkey::inst->SetHotkeyMap(std::move(hk_map)); |
| 116 | migrations.emplace_back("duplicate -> split"); |
| 117 | } |
| 118 | |
| 119 | #ifdef __WXMAC__ |
| 120 | if (boost::find(migrations, "app/minimize") == end(migrations)) { |
| 121 | migrate_hotkeys(added_hotkeys_minimize); |
| 122 | migrations.emplace_back("app/minimize"); |
| 123 | } |
| 124 | #endif |
| 125 | |
| 126 | OPT_SET("App/Hotkey Migrations")->SetListString(std::move(migrations)); |
| 127 | } |
| 128 | |
| 129 | void clear() { |
| 130 | delete inst; |