diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2018-09-14 16:25:59 +0300 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2018-09-14 16:25:59 +0300 |
commit | 0290564d5c654d654856f04f1b04bad984f36aee (patch) | |
tree | 3b9a5eda39861d9467bc130a00e7effbc4ef7b6c /src/gui/generalsettings.cpp | |
parent | 638f5c8752164ccc0429b1df60b79c3d3293bcd4 (diff) | |
parent | 3a335879fa1f00f094d82855126fec3f6ab59405 (diff) |
Merge remote-tracking branch 'owncloud/master' into delta-sync
Conflicts:
.gitmodules
src/cmd/cmd.cpp
src/gui/generalsettings.ui
src/libsync/propagatedownload.cpp
src/libsync/propagateuploadng.cpp
Diffstat (limited to 'src/gui/generalsettings.cpp')
-rw-r--r-- | src/gui/generalsettings.cpp | 109 |
1 files changed, 86 insertions, 23 deletions
diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 8f08b1f73..d6a33fed1 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -25,6 +25,10 @@ #include "updater/updater.h" #include "updater/ocupdater.h" +#ifdef Q_OS_MAC +// FIXME We should unify those, but Sparkle does everything behind the scene transparently +#include "updater/sparkleupdater.h" +#endif #include "ignorelisteditor.h" #include "config.h" @@ -32,6 +36,7 @@ #include <QNetworkProxy> #include <QDir> #include <QScopedValueRollback> +#include <QMessageBox> namespace OCC { @@ -49,17 +54,6 @@ GeneralSettings::GeneralSettings(QWidget *parent) _ui->autostartCheckBox->setChecked(Utility::hasLaunchOnStartup(Theme::instance()->appName())); connect(_ui->autostartCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleLaunchOnStartup); - // setup about section - QString about = Theme::instance()->about(); - if (about.isEmpty()) { - _ui->aboutGroupBox->hide(); - } else { - _ui->aboutLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction); - _ui->aboutLabel->setText(about); - _ui->aboutLabel->setWordWrap(true); - _ui->aboutLabel->setOpenExternalLinks(true); - } - loadMiscSettings(); slotUpdateInfo(); @@ -98,6 +92,18 @@ GeneralSettings::GeneralSettings(QWidget *parent) // accountAdded means the wizard was finished and the wizard might change some options. connect(AccountManager::instance(), &AccountManager::accountAdded, this, &GeneralSettings::loadMiscSettings); + + // Only our standard brandings currently support beta channel + Theme *theme = Theme::instance(); + if (theme->appName() != QLatin1String("ownCloud") && theme->appName() != QLatin1String("testpilotcloud") ) { +#ifdef Q_OS_MAC + // Because we don't have any statusString from the SparkleUpdater anyway we can hide the whole thing + _ui->updatesGroupBox->hide(); +#else + _ui->updateChannelLabel->hide(); + _ui->updateChannel->hide(); +#endif + } } GeneralSettings::~GeneralSettings() @@ -130,22 +136,79 @@ void GeneralSettings::loadMiscSettings() void GeneralSettings::slotUpdateInfo() { - // Note: the sparkle-updater is not an OCUpdater - OCUpdater *updater = qobject_cast<OCUpdater *>(Updater::instance()); - if (ConfigFile().skipUpdateCheck()) { - updater = 0; // don't show update info if updates are disabled + if (ConfigFile().skipUpdateCheck() || !Updater::instance()) { + // updater disabled on compile + _ui->updatesGroupBox->setVisible(false); + return; } - if (updater) { - connect(updater, &OCUpdater::downloadStateChanged, this, &GeneralSettings::slotUpdateInfo, Qt::UniqueConnection); - connect(_ui->restartButton, &QAbstractButton::clicked, updater, &OCUpdater::slotStartInstaller, Qt::UniqueConnection); + // Note: the sparkle-updater is not an OCUpdater + OCUpdater *ocupdater = qobject_cast<OCUpdater *>(Updater::instance()); + if (ocupdater) { + connect(ocupdater, &OCUpdater::downloadStateChanged, this, &GeneralSettings::slotUpdateInfo, Qt::UniqueConnection); + connect(_ui->restartButton, &QAbstractButton::clicked, ocupdater, &OCUpdater::slotStartInstaller, Qt::UniqueConnection); connect(_ui->restartButton, &QAbstractButton::clicked, qApp, &QApplication::quit, Qt::UniqueConnection); - _ui->updateStateLabel->setText(updater->statusString()); - _ui->restartButton->setVisible(updater->downloadState() == OCUpdater::DownloadComplete); - } else { - // can't have those infos from sparkle currently - _ui->updatesGroupBox->setVisible(false); + + _ui->updateStateLabel->setText(ocupdater->statusString()); + _ui->restartButton->setVisible(ocupdater->downloadState() == OCUpdater::DownloadComplete); + } +#if defined(Q_OS_MAC) && defined(HAVE_SPARKLE) + else if (SparkleUpdater *sparkleUpdater = qobject_cast<SparkleUpdater *>(Updater::instance())) { + _ui->updateStateLabel->setText(sparkleUpdater->statusString()); + _ui->restartButton->setVisible(false); + } +#endif + + // Channel selection + _ui->updateChannel->setCurrentIndex(ConfigFile().updateChannel() == "beta" ? 1 : 0); + connect(_ui->updateChannel, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection); +} + +void GeneralSettings::slotUpdateChannelChanged(int index) +{ + QString channel = index == 0 ? QStringLiteral("stable") : QStringLiteral("beta"); + 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 (OCUpdater *updater = qobject_cast<OCUpdater *>(Updater::instance())) { + updater->setUpdateUrl(Updater::updateUrl()); + updater->checkForUpdate(); + } +#if defined(Q_OS_MAC) && defined(HAVE_SPARKLE) + else if (SparkleUpdater *updater = qobject_cast<SparkleUpdater *>(Updater::instance())) { + updater->setUpdateUrl(Updater::updateUrl()); + updater->checkForUpdate(); + } +#endif + } else { + _ui->updateChannel->setCurrentText(ConfigFile().updateChannel()); + } + }); + msgBox->open(); } void GeneralSettings::saveMiscSettings() |