mirror of https://github.com/odrling/Aegisub
Don't overwrite existing hotkeys in migrations
This commit is contained in:
parent
9809b66f61
commit
cff5afbb08
|
@ -110,6 +110,17 @@ std::string Hotkey::Scan(const std::string &context, const std::string &str, boo
|
|||
return "";
|
||||
}
|
||||
|
||||
bool Hotkey::HasHotkey(const std::string &context, const std::string &str) const {
|
||||
HotkeyMap::const_iterator index, end;
|
||||
for (std::tie(index, end) = str_map.equal_range(str); index != end; ++index) {
|
||||
std::string const& ctext = index->second.Context();
|
||||
|
||||
if (ctext == context)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> Hotkey::GetHotkeys(const std::string &context, const std::string &command) const {
|
||||
std::vector<std::string> ret;
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ public:
|
|||
/// @return Name of command or "" if none match
|
||||
std::string Scan(const std::string &context, const std::string &str, bool always) const;
|
||||
|
||||
bool HasHotkey(const std::string &context, const std::string &str) const;
|
||||
|
||||
/// Get the string representation of the hotkeys for the given command
|
||||
/// @param context Context requested
|
||||
/// @param command Command name
|
||||
|
|
|
@ -57,9 +57,12 @@ namespace {
|
|||
keys.emplace_back(added[i][2]);
|
||||
if (added[i][3])
|
||||
keys.emplace_back(added[i][3]);
|
||||
hk_map.insert(make_pair(
|
||||
std::string(added[i][0]),
|
||||
agi::hotkey::Combo(added[i][1], added[i][0], keys)));
|
||||
agi::hotkey::Combo combo(added[i][1], added[i][0], keys);
|
||||
|
||||
if (hotkey::inst->HasHotkey(combo.Context(), combo.Str()))
|
||||
continue;
|
||||
|
||||
hk_map.insert(make_pair(std::string(added[i][0]), combo));
|
||||
}
|
||||
|
||||
hotkey::inst->SetHotkeyMap(hk_map);
|
||||
|
|
Loading…
Reference in New Issue