From 60d3696ccd38204a01e365ab8ea4f27a5043517b Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 18 May 2018 14:45:29 +0200 Subject: [PATCH] Settings: Add warning when switching update channel --- src/gui/generalsettings.cpp | 49 +++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 789bc27b3..16658f8a3 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -294,18 +295,46 @@ void GeneralSettings::slotUpdateInfo() void GeneralSettings::slotUpdateChannelChanged(const QString &channel) { - ConfigFile().setUpdateChannel(channel); - auto *updater = qobject_cast(Updater::instance()); - if (updater) { - updater->setUpdateUrl(Updater::updateUrl()); - updater->checkForUpdate(); - } + if (channel == ConfigFile().updateChannel()) + return; + + auto msgBox = new QMessageBox( + QMessageBox::Warning, + tr("Change update channel?"), + tr("The update channel determines which client updates will be offered " + "for installation. The \"stable\" channel contains only upgrades that " + "are considered reliable, while the versions in the \"beta\" channel " + "may contain newer features and bugfixes, but have not yet been tested " + "thoroughly." + "\n\n" + "Note that this selects only what pool upgrades are taken from, and that " + "there are no downgrades: So going back from the beta channel to " + "the stable channel usually cannot be done immediately and means waiting " + "for a stable version that is newer than the currently installed beta " + "version."), + QMessageBox::NoButton, + this); + msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole); + msgBox->addButton(tr("Cancel"), QMessageBox::RejectRole); + connect(msgBox, &QMessageBox::finished, msgBox, [this, channel, msgBox](int result) { + msgBox->deleteLater(); + if (result == QMessageBox::AcceptRole) { + ConfigFile().setUpdateChannel(channel); + if (auto updater = qobject_cast(Updater::instance())) { + updater->setUpdateUrl(Updater::updateUrl()); + updater->checkForUpdate(); + } #ifdef Q_OS_MAC - else if (auto *updater = qobject_cast(Updater::instance())) { - updater->setUpdateUrl(Updater::updateUrl()); - updater->checkForUpdate(); - } + else if (auto updater = qobject_cast(Updater::instance())) { + updater->setUpdateUrl(Updater::updateUrl()); + updater->checkForUpdate(); + } #endif + } else { + _ui->updateChannel->setCurrentText(ConfigFile().updateChannel()); + } + }); + msgBox->open(); } void GeneralSettings::slotUpdateCheckNow() -- 2.30.2