Attempted blind fix for hotkeys not saving. (#3473)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL 2022-01-08 13:06:32 +00:00 committed by GitHub
parent 42002d80b7
commit dfa3818a70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -201,8 +201,15 @@ void HotkeyController::loadHotkeys()
auto set = std::set<QString>(defaultHotkeysAdded.begin(),
defaultHotkeysAdded.end());
// set is currently "defaults added in settings"
auto numDefaultsFromSettings = set.size();
auto keys = pajlada::Settings::SettingManager::getObjectKeys("/hotkeys");
this->addDefaults(set);
// set is currently "all defaults (defaults defined from application + defaults defined in settings)"
auto numCombinedDefaults = set.size();
pajlada::Settings::Setting<std::vector<QString>>::set(
"/hotkeys/addedDefaults", std::vector<QString>(set.begin(), set.end()));
@ -239,6 +246,12 @@ void HotkeyController::loadHotkeys()
*category, QKeySequence(keySequence), action, arguments,
QString::fromStdString(key)));
}
if (numDefaultsFromSettings != numCombinedDefaults)
{
// some default that the user was not aware of has been added to the application, force a save to ensure shared state between hotkey controller and settings
this->saveHotkeys();
}
}
void HotkeyController::saveHotkeys()