From 2dcf728f6e4f4e05af5a87436a9866202a27d34e Mon Sep 17 00:00:00 2001 From: Nils Schimmelmann Date: Thu, 4 Jun 2026 12:56:55 -0500 Subject: [PATCH] fix parser commands to persist configuration This ensures that changes made by the CLI are persisted immediately since they could be undone if the user canceled the Preferences dialog. --- src/client/HotkeyManager.cpp | 4 ++++ src/mainwindow/mainwindow.cpp | 1 + src/parser/AbstractParser-Config.cpp | 2 ++ src/parser/AbstractParser-Group.cpp | 1 + src/parser/abstractparser.cpp | 1 + 5 files changed, 9 insertions(+) diff --git a/src/client/HotkeyManager.cpp b/src/client/HotkeyManager.cpp index 36916c4f3..72634e26e 100644 --- a/src/client/HotkeyManager.cpp +++ b/src/client/HotkeyManager.cpp @@ -95,6 +95,7 @@ bool HotkeyManager::setHotkey(const Hotkey &hk, const std::string_view command) QVariantMap data = getConfig().hotkeys.data(); data[mmqt::toQStringUtf8(hk.to_string())] = mmqt::toQStringUtf8(command); setConfig().hotkeys.setData(std::move(data)); + getConfig().write(); return true; } @@ -110,6 +111,7 @@ bool HotkeyManager::removeHotkey(const Hotkey &hk) } data.remove(key); setConfig().hotkeys.setData(std::move(data)); + getConfig().write(); return true; } @@ -143,9 +145,11 @@ void HotkeyManager::resetToDefaults() XFOREACH_DEFAULT_HOTKEYS(X_DEFAULT) #undef X_DEFAULT setConfig().hotkeys.setData(std::move(data)); + getConfig().write(); } void HotkeyManager::clear() { setConfig().hotkeys.setData(QVariantMap()); + getConfig().write(); } diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 76b96d5dc..f58393c27 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -1046,6 +1046,7 @@ void MainWindow::createActions() static void setConfigMapMode(const MapModeEnum mode) { setConfig().general.mapMode = mode; + getConfig().write(); } void MainWindow::slot_onPlayMode() diff --git a/src/parser/AbstractParser-Config.cpp b/src/parser/AbstractParser-Config.cpp index f021db16c..9a60745a1 100644 --- a/src/parser/AbstractParser-Config.cpp +++ b/src/parser/AbstractParser-Config.cpp @@ -198,6 +198,7 @@ void AbstractParser::doConfig(const StringView cmd) clone.set(oldValue); fp.setFloat(value); + getConfig().write(); os << "Changed " << help << " from " << clone.getFloat() << " to " << fp.getFloat() << AnsiOstream::endl; this->graphicsSettingsChanged(); @@ -294,6 +295,7 @@ void AbstractParser::doConfig(const StringView cmd) } conf.set(value); + getConfig().write(); os << "Set " << conf.getName() << " = " << BoolAlpha(value) << AnsiOstream::endl; graphicsSettingsChanged(); diff --git a/src/parser/AbstractParser-Group.cpp b/src/parser/AbstractParser-Group.cpp index ee8c714f4..08a69368b 100644 --- a/src/parser/AbstractParser-Group.cpp +++ b/src/parser/AbstractParser-Group.cpp @@ -129,6 +129,7 @@ void AbstractParser::parseGroup(StringView input) member->setColor(newColor.getQColor()); if (member->isYou()) { setConfig().groupManager.color = member->getColor(); + getConfig().write(); } os << "Member " << name << " (" << id << ") has been changed from " << oldColor << " to " << newColor << ".\n"; diff --git a/src/parser/abstractparser.cpp b/src/parser/abstractparser.cpp index a5fb05453..217f083f3 100644 --- a/src/parser/abstractparser.cpp +++ b/src/parser/abstractparser.cpp @@ -480,6 +480,7 @@ bool AbstractParser::setCommandPrefix(const char prefix) return false; } setConfig().parser.prefixChar = prefix; + getConfig().write(); showCommandPrefix(); return true; }