From a822ebc16a1b8c654ae289cea60692fb6f3d4c15 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sat, 28 Dec 2024 13:59:57 -0800 Subject: [PATCH] fix bug with release channel not saving --- cockatrice/src/dialogs/dlg_settings.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/dialogs/dlg_settings.cpp b/cockatrice/src/dialogs/dlg_settings.cpp index d4ffd2815..21ab17139 100644 --- a/cockatrice/src/dialogs/dlg_settings.cpp +++ b/cockatrice/src/dialogs/dlg_settings.cpp @@ -68,7 +68,6 @@ GeneralSettingsPage::GeneralSettingsPage() showTipsOnStartup.setChecked(settings.getShowTipsOnStartup()); connect(&languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int))); - connect(&updateReleaseChannelBox, SIGNAL(currentIndexChanged(int)), &settings, SLOT(setUpdateReleaseChannel(int))); connect(&startupUpdateCheckCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setCheckUpdatesOnStartup); connect(&updateNotificationCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setNotifyAboutUpdate); @@ -172,6 +171,13 @@ GeneralSettingsPage::GeneralSettingsPage() mainLayout->addWidget(pathsGroupBox); mainLayout->addStretch(); + GeneralSettingsPage::retranslateUi(); + + // connect the ReleaseChannel combo box only after the entries are inserted in retranslateUi + connect(&updateReleaseChannelBox, &QComboBox::currentIndexChanged, &settings, + &SettingsCache::setUpdateReleaseChannel); + updateReleaseChannelBox.setCurrentIndex(settings.getUpdateReleaseChannel()->getIndex()); + setLayout(mainLayout); } @@ -299,12 +305,14 @@ void GeneralSettingsPage::retranslateUi() resetAllPathsButton->setText(tr("Reset all paths")); const auto &settings = SettingsCache::instance(); - QList channels = settings.getUpdateReleaseChannels(); + + // We can't change the strings after they're put into the QComboBox, so this is our workaround + int oldIndex = updateReleaseChannelBox.currentIndex(); updateReleaseChannelBox.clear(); - for (ReleaseChannel *chan : channels) { + for (ReleaseChannel *chan : settings.getUpdateReleaseChannels()) { updateReleaseChannelBox.insertItem(chan->getIndex(), tr(chan->getName().toUtf8())); } - updateReleaseChannelBox.setCurrentIndex(settings.getUpdateReleaseChannel()->getIndex()); + updateReleaseChannelBox.setCurrentIndex(oldIndex); } AppearanceSettingsPage::AppearanceSettingsPage()