fix bug with release channel setting not being remembered (#5365)

This commit is contained in:
RickyRister 2024-12-28 15:08:07 -08:00 committed by GitHub
parent df9c5ae53c
commit f737d9a794
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View file

@ -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<ReleaseChannel *> 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()

View file

@ -292,7 +292,7 @@ public:
}
ReleaseChannel *getUpdateReleaseChannel() const
{
return releaseChannels.at(updateReleaseChannel);
return releaseChannels.at(qMax(0, updateReleaseChannel));
}
QList<ReleaseChannel *> getUpdateReleaseChannels() const
{