FEAT(client): Immediately save settings

Previously settings were only saved upon Mumble's exit. This commit
makes sure that the settings are also saved to file every time, the user
accepts the settings window. That way settings are guaranteed to survive
potential crashes or other hard-exits of Mumble (e.g. Ctrl+C, Task
manager, etc.).
This commit is contained in:
Robert Adam 2021-11-02 10:59:07 +01:00
parent d0628628d3
commit 20f47f1bbf
2 changed files with 14 additions and 0 deletions

View File

@ -268,5 +268,8 @@ void ConfigDialog::accept() {
#endif
Global::get().s.qbaConfigGeometry = saveGeometry();
// Save settings to disk
Global::get().s.save();
QDialog::accept();
}

View File

@ -11,6 +11,7 @@
#include "Database.h"
#include "EnvUtils.h"
#include "MainWindow.h"
#include "ServerHandler.h"
#include "Global.h"
#include "GlobalShortcutButtons.h"
@ -721,6 +722,16 @@ void GlobalShortcutConfig::save() const {
if (s.bEnableUIAccess != oldUIAccess || s.bEnableGKey != oldGKey || s.bEnableXboxInput != oldXboxInput) {
s.requireRestartToApply = true;
}
if (Global::get().sh && Global::get().sh->hasSynchronized()) {
// If we are connected to a server (that has finished synchronizing) there is the change, the user has
// configured server-specific shortcuts, which we save in the DB instead of in the regular settings. Thus we
// have to explicitly save them here.
// Note that the server needs to have finished synchronizing, since only then did we load any previously
// configured shortcuts from the DB in the first place. Otherwise, "saving" the shortcuts (which are not
// loaded yet) would effectively delete them.
Global::get().db->setShortcuts(Global::get().sh->qbaDigest, s.qlShortcuts);
}
}
QTreeWidgetItem *GlobalShortcutConfig::itemForShortcut(const Shortcut &sc) const {