diff --git a/cockatrice/src/dialogs/dlg_settings.cpp b/cockatrice/src/dialogs/dlg_settings.cpp index d4ffd2815..9b9794503 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,12 @@ GeneralSettingsPage::GeneralSettingsPage() mainLayout->addWidget(pathsGroupBox); mainLayout->addStretch(); + GeneralSettingsPage::retranslateUi(); + + // connect the ReleaseChannel combo box only after the entries are inserted in retranslateUi + connect(&updateReleaseChannelBox, SIGNAL(currentIndexChanged(int)), &settings, SLOT(setUpdateReleaseChannel(int))); + updateReleaseChannelBox.setCurrentIndex(settings.getUpdateReleaseChannel()->getIndex()); + setLayout(mainLayout); } @@ -299,12 +304,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() diff --git a/cockatrice/src/settings/cache_settings.h b/cockatrice/src/settings/cache_settings.h index 6b0a24598..a15194b3d 100644 --- a/cockatrice/src/settings/cache_settings.h +++ b/cockatrice/src/settings/cache_settings.h @@ -292,7 +292,7 @@ public: } ReleaseChannel *getUpdateReleaseChannel() const { - return releaseChannels.at(updateReleaseChannel); + return releaseChannels.at(qMax(0, updateReleaseChannel)); } QList getUpdateReleaseChannels() const {