From ab4d8afbdd3f12355f7aafa708b658609712fe49 Mon Sep 17 00:00:00 2001 From: PBeGood4 Date: Tue, 9 Jan 2024 20:22:50 +0000 Subject: [PATCH] Call settings->sync() when closing QSettings with IniFormat requires this function to be called, unlike Registry format --- dsda-launcher/main.cpp | 7 +- dsda-launcher/mainwindow.cpp | 164 ++++++++++++++++++----------------- 2 files changed, 86 insertions(+), 85 deletions(-) diff --git a/dsda-launcher/main.cpp b/dsda-launcher/main.cpp index 6febfc5..98e1200 100755 --- a/dsda-launcher/main.cpp +++ b/dsda-launcher/main.cpp @@ -15,11 +15,8 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - // Settings to be stored -#ifdef __APPLE__ - settings = new QSettings("pedrobeirao", "dsda-launcher"); -#else +#ifdef _WIN32 settings = new QSettings(QCoreApplication::applicationDirPath() + "/dsda-launcher.ini", QSettings::IniFormat); // Check for previous registry settings and copy it to the new one if needed @@ -31,6 +28,8 @@ int main(int argc, char *argv[]) settings->setValue(key, prev_reg_settings.value(key)); } } +#else + settings = new QSettings("pedrobeirao", "dsda-launcher"); #endif MainWindow w; diff --git a/dsda-launcher/mainwindow.cpp b/dsda-launcher/mainwindow.cpp index 2958c9d..24e6dc9 100755 --- a/dsda-launcher/mainwindow.cpp +++ b/dsda-launcher/mainwindow.cpp @@ -656,7 +656,7 @@ void MainWindow::on_actionCheck_for_updates_triggered() msgBox.exec(); if (msgBox.clickedButton()==pButtonYes) { - QDesktopServices::openUrl(QUrl("https://github.com/Pedro-Beirao/dsda-launcher/releases/tag/"+launcherV)); + QDesktopServices::openUrl(QUrl("https://github.com/Pedro-Beirao/dsda-launcher/releases" + launcherV)); } } else @@ -939,102 +939,104 @@ void MainWindow::on_launchGame_pushButton_clicked(bool onExit, bool returnToolti int diffIndex = ui->difficulty_comboBox->currentIndex(); if(onExit) + { + settings->setValue("iwad", ui->iwad_comboBox->currentIndex()); + + // Again, we need to remove the setting if the additional parameters box is empty so that it does not appear when we open the launcher again + if (ui->additionalArguments_textEdit->toPlainText().toStdString() != "") + { + settings->setValue("argumentText", ui->additionalArguments_textEdit->toPlainText().toStdString().c_str()); + } + else { - settings->setValue("iwad",ui->iwad_comboBox->currentIndex()); + settings->remove("argumentText"); + } + settings->setValue("fullscreen", ui->fullscreen_checkBox->isChecked()); + settings->setValue("geom", ui->resolution_comboBox->currentIndex()); - // Again, we need to remove the setting if the additional parameters box is empty so that it does not appear when we open the launcher again - if(ui->additionalArguments_textEdit->toPlainText().toStdString()!="") - { - settings->setValue("argumentText",ui->additionalArguments_textEdit->toPlainText().toStdString().c_str()); - } - else - { - settings->remove("argumentText"); - } - settings->setValue("fullscreen", ui->fullscreen_checkBox->isChecked()); - settings->setValue("geom",ui->resolution_comboBox->currentIndex()); + settings->setValue("solonet", isSoloNet); + settings->setValue("respawn", isRespawn); + settings->setValue("nomo", isNoMo); + settings->setValue("fast", isFast); - settings->setValue("solonet",isSoloNet); - settings->setValue("respawn",isRespawn); - settings->setValue("nomo",isNoMo); - settings->setValue("fast",isFast); + settings->setValue("complevel", complevelIndex); + settings->setValue("skill", diffIndex); - settings->setValue("complevel",complevelIndex); - settings->setValue("skill",diffIndex); + settings->setValue("warp1", ui->episode_lineEdit->text().toStdString().c_str()); + settings->setValue("warp2", ui->level_lineEdit->text().toStdString().c_str()); - settings->setValue("warp1",ui->episode_lineEdit->text().toStdString().c_str()); - settings->setValue("warp2",ui->level_lineEdit->text().toStdString().c_str()); + // We need to remove the setting if the warp number is deleted so that it does not appear when we open the launcher again + // gzdoom does not do this for the arguments box (at the time of writing, at least) and it drives me nuts + if (ui->episode_lineEdit->text().toStdString() == "") + { + settings->remove("warp1"); + } + if (ui->level_lineEdit->text().toStdString() == "") + { + settings->remove("warp2"); + } - // We need to remove the setting if the warp number is deleted so that it does not appear when we open the launcher again - // gzdoom does not do this for the arguments box (at the time of writing, at least) and it drives me nuts - if(ui->episode_lineEdit->text().toStdString()=="") - { - settings->remove("warp1"); - } - if(ui->level_lineEdit->text().toStdString()=="") - { - settings->remove("warp2"); - } + if (ui->record_lineEdit->text().toStdString() != "") + { + settings->setValue("recorddemo", ui->record_lineEdit->text()); + } + else + { + settings->remove("recorddemo"); + } - if(ui->record_lineEdit->text().toStdString()!="") - { - settings->setValue("recorddemo",ui->record_lineEdit->text()); - } - else - { - settings->remove("recorddemo"); - } + if (ui->playback_lineEdit->text().toStdString() != "") + { + settings->setValue("playdemo", ui->playback_lineEdit->text()); + } + else + { + settings->remove("playdemo"); + } - if(ui->playback_lineEdit->text().toStdString()!="") - { - settings->setValue("playdemo",ui->playback_lineEdit->text()); - } - else - { - settings->remove("playdemo"); - } + if (ui->viddump_lineEdit->text().toStdString() != "") + { + settings->setValue("viddump", ui->viddump_lineEdit->text()); + } + else + { + settings->remove("viddump"); + } - if(ui->viddump_lineEdit->text().toStdString()!="") - { - settings->setValue("viddump",ui->viddump_lineEdit->text()); - } - else - { - settings->remove("viddump"); - } + if (ui->hud_lineEdit->text().toStdString() != "") + { + settings->setValue("hud", ui->hud_lineEdit->text()); + } + else + { + settings->remove("hud"); + } - if(ui->hud_lineEdit->text().toStdString()!="") - { - settings->setValue("hud",ui->hud_lineEdit->text()); - } - else - { - settings->remove("hud"); - } + if (ui->config_lineEdit->text().toStdString() != "") + { + settings->setValue("config", ui->config_lineEdit->text()); + } + else + { + settings->remove("config"); + } - if(ui->config_lineEdit->text().toStdString()!="") - { - settings->setValue("config",ui->config_lineEdit->text()); - } - else - { - settings->remove("config"); - } + settings->setValue("demoplaybox", ui->playback_comboBox->currentIndex()); - settings->setValue("demoplaybox", ui->playback_comboBox->currentIndex()); + settings->setValue("pwadCount", ui->wads_listWidget->count()); + for (int i = 0; i < ui->wads_listWidget->count(); i++) + { + settings->setValue(("pwad" + std::to_string(i)).c_str(), ui->wads_listWidget->item(i)->text()); + } - settings->setValue("pwadCount", ui->wads_listWidget->count()); - for(int i=0; iwads_listWidget->count();i++) - { - settings->setValue(("pwad"+std::to_string(i)).c_str(),ui->wads_listWidget->item(i)->text()); - } + settings->setValue("exeName", exeName); - settings->setValue("exeName", exeName); + settings->setValue("version", version); - settings->setValue("version", version); + settings->sync(); - return; - } + return; + } QStringList argList;