this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection);
}
-void GeneralSettings::slotUpdateChannelChanged(const QString &channel)
+void GeneralSettings::slotUpdateChannelChanged(const QString &translatedChannel)
{
- if (channel == ConfigFile().updateChannel())
+ const auto updateChannelToLocalized = [](const QString &channel) {
+ auto decodedTranslatedChannel = QString{};
+
+ if (channel == QStringLiteral("stable")) {
+ decodedTranslatedChannel = tr("stable");
+ } else if (channel == QStringLiteral("beta")) {
+ decodedTranslatedChannel = tr("beta");
+ }
+
+ return decodedTranslatedChannel;
+ };
+
+ const auto updateChannelFromLocalized = [](const int index) {
+ auto channel = QString{};
+
+ switch (index)
+ {
+ case 0:
+ channel = QStringLiteral("stable");
+ break;
+ case 1:
+ channel = QStringLiteral("beta");
+ break;
+ default:
+ channel = QString{};
+ }
+
+ return channel;
+ };
+
+ const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex());
+
+ if (translatedChannel == ConfigFile().updateChannel()) {
return;
+ }
auto msgBox = new QMessageBox(
QMessageBox::Warning,
this);
auto acceptButton = msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole);
msgBox->addButton(tr("Cancel"), QMessageBox::RejectRole);
- connect(msgBox, &QMessageBox::finished, msgBox, [this, channel, msgBox, acceptButton] {
+ connect(msgBox, &QMessageBox::finished, msgBox, [this, channel, msgBox, acceptButton, updateChannelToLocalized] {
msgBox->deleteLater();
if (msgBox->clickedButton() == acceptButton) {
ConfigFile().setUpdateChannel(channel);
}
#endif
} else {
- _ui->updateChannel->setCurrentText(ConfigFile().updateChannel());
+ _ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().updateChannel()));
}
});
msgBox->open();