fix: handle aboutToQuit() (#6159)

This commit is contained in:
nerix
2025-04-19 13:05:36 +02:00
committed by GitHub
parent 3282cac94d
commit 52067d0af7
4 changed files with 20 additions and 4 deletions
+1
View File
@@ -24,6 +24,7 @@
- Dev: Conan will no longer generate a `CMakeUserPresets.json` file. (#6117)
- Dev: Pass `--force-openssl` when installing from CMake in Qt 6.8+. (#6129)
- Dev: Fixed `<build-tool> clean` not working correctly with generated sources. (#6154)
- Dev: Save settings in `aboutToQuit`. (#6159)
## 2.5.3
+11 -3
View File
@@ -280,12 +280,20 @@ void runGui(QApplication &a, const Paths &paths, Settings &settings,
chatterino::NetworkManager::init();
updates.checkForUpdates();
QObject::connect(qApp, &QApplication::aboutToQuit, [] {
auto *app = dynamic_cast<Application *>(tryGetApp());
if (app)
{
app->save();
}
getSettings()->requestSave();
getSettings()->disableSave();
});
Application app(settings, paths, args, updates);
app.initialize(settings, paths);
app.run();
app.save();
settings.requestSave();
chatterino::NetworkManager::deinit();
+5
View File
@@ -278,6 +278,11 @@ void Settings::restoreSnapshot()
}
}
void Settings::disableSave()
{
this->disableSaving = true;
}
float Settings::getClampedUiScale() const
{
return std::clamp(this->uiScale.getValue(), 0.2F, 10.F);
+3 -1
View File
@@ -104,7 +104,7 @@ class Settings
static Settings *instance_;
Settings *prevInstance_ = nullptr;
const bool disableSaving;
bool disableSaving;
public:
Settings(const Args &args, const QString &settingsDirectory);
@@ -120,6 +120,8 @@ public:
void saveSnapshot();
void restoreSnapshot();
void disableSave();
FloatSetting uiScale = {"/appearance/uiScale2", 1};
BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false};