From dfa3818a701d5445dea10c102712404fbc104f27 Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Sat, 8 Jan 2022 13:06:32 +0000 Subject: [PATCH] Attempted blind fix for hotkeys not saving. (#3473) Co-authored-by: Rasmus Karlsson --- src/controllers/hotkeys/HotkeyController.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/controllers/hotkeys/HotkeyController.cpp b/src/controllers/hotkeys/HotkeyController.cpp index 2dafc0c70..6e6d32f9c 100644 --- a/src/controllers/hotkeys/HotkeyController.cpp +++ b/src/controllers/hotkeys/HotkeyController.cpp @@ -201,8 +201,15 @@ void HotkeyController::loadHotkeys() auto set = std::set(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>::set( "/hotkeys/addedDefaults", std::vector(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()