fix: save settings less often (#6620)

Reviewed-by: James Upjohn <jupjohn@jammeh.co.nz>
This commit is contained in:
pajlada
2025-12-11 17:42:23 +01:00
committed by GitHub
parent ccb8ad8ffc
commit 99f2b5b435
5 changed files with 36 additions and 10 deletions
+9 -5
View File
@@ -157,8 +157,12 @@ Settings::Settings(const Args &args, const QString &settingsDirectory)
settingsInstance->setBackupEnabled(true);
settingsInstance->setBackupSlots(9);
settingsInstance->saveMethod =
pajlada::Settings::SettingManager::SaveMethod::SaveManually;
settingsInstance->saveMethod = static_cast<
pajlada::Settings::SettingManager::SaveMethod>(
static_cast<uint64_t>(
pajlada::Settings::SettingManager::SaveMethod::SaveManually) |
static_cast<uint64_t>(
pajlada::Settings::SettingManager::SaveMethod::OnlySaveIfChanged));
initializeSignalVector(this->signalHolder, this->highlightedMessagesSetting,
this->highlightedMessages);
@@ -198,14 +202,14 @@ Settings::~Settings()
Settings::instance_ = this->prevInstance_;
}
void Settings::requestSave() const
pajlada::Settings::SettingManager::SaveResult Settings::requestSave() const
{
if (this->disableSaving)
{
return;
return pajlada::Settings::SettingManager::SaveResult::Skipped;
}
pajlada::Settings::SettingManager::gSave();
return pajlada::Settings::SettingManager::gSave();
}
void Settings::saveSnapshot()
+4 -1
View File
@@ -24,6 +24,7 @@
#include <pajlada/settings/setting.hpp>
#include <pajlada/settings/settinglistener.hpp>
#include <pajlada/settings/settingmanager.hpp>
#include <pajlada/signals/signalholder.hpp>
#include <optional>
@@ -130,7 +131,9 @@ public:
/// Request the settings to be saved to file
///
/// Depending on the launch options, a save might end up not happening
void requestSave() const;
///
/// Returns the result from the save, or Skipped if disableSave has been called
pajlada::Settings::SettingManager::SaveResult requestSave() const;
void saveSnapshot();
void restoreSnapshot();