Skip to content

Commit

Permalink
Attempted blind fix for hotkeys not saving. (#3473)
Browse files Browse the repository at this point in the history
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
  • Loading branch information
Mm2PL and pajlada authored Jan 8, 2022
1 parent 42002d8 commit dfa3818
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/controllers/hotkeys/HotkeyController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit dfa3818

Please sign in to comment.