From e07f6f516bc6a852c762eec153430df211b72c68 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 15 Apr 2024 20:59:50 +0200 Subject: [PATCH 01/12] Add daily update channel. - Set update channel options list in slotUpdateInfo. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 21 ++++++++++++++++----- src/gui/generalsettings.ui | 32 +++++++++++--------------------- src/libsync/configfile.cpp | 13 ++++++++----- src/libsync/configfile.h | 1 + 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index b57745fc2c9b2..1c77cf42e1819 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -340,8 +340,12 @@ void GeneralSettings::slotUpdateInfo() } #endif - // Channel selection - _ui->updateChannel->setCurrentIndex(ConfigFile().updateChannel() == "beta" ? 1 : 0); + // stable, beta, daily + ConfigFile config; + const auto validUpdateChannels = config.validUpdateChannels(); + const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(config.updateChannel()); + _ui->updateChannel->addItems(validUpdateChannels); + _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex); connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection); } @@ -355,17 +359,24 @@ void GeneralSettings::slotUpdateChannelChanged() decodedTranslatedChannel = tr("stable"); } else if (channel == QStringLiteral("beta")) { decodedTranslatedChannel = tr("beta"); + } else if (channel == QStringLiteral("daily")) { + decodedTranslatedChannel = tr("daily"); } return decodedTranslatedChannel; }; const auto updateChannelFromLocalized = [](const int index) { - if (index == 1) { + switch(index) { + case 1: return QStringLiteral("beta"); + break; + case 2: + return QStringLiteral("daily"); + break; + default: + return QStringLiteral("stable"); } - - return QStringLiteral("stable"); }; const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex()); diff --git a/src/gui/generalsettings.ui b/src/gui/generalsettings.ui index 54f79b55d4750..aac6ea6ab82ba 100644 --- a/src/gui/generalsettings.ui +++ b/src/gui/generalsettings.ui @@ -6,7 +6,7 @@ 0 0 - 601 + 667 663 @@ -40,10 +40,10 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -77,10 +77,10 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -104,10 +104,10 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -197,7 +197,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -269,16 +269,6 @@ 0 - - - stable - - - - - beta - - @@ -343,7 +333,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -374,7 +364,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -395,7 +385,7 @@ - Qt::Vertical + Qt::Orientation::Vertical diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index abc9eb8a84a60..f70dfe2b36e66 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -109,8 +109,6 @@ static constexpr char forceLoginV2C[] = "forceLoginV2"; static constexpr char certPath[] = "http_certificatePath"; static constexpr char certPasswd[] = "http_certificatePasswd"; - -static const QSet validUpdateChannels { QStringLiteral("stable"), QStringLiteral("beta") }; } namespace OCC { @@ -700,7 +698,7 @@ QString ConfigFile::updateChannel() const QSettings settings(configFile(), QSettings::IniFormat); const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString(); - if (!validUpdateChannels.contains(channel)) { + if (!validUpdateChannels().contains(channel)) { qCWarning(lcConfigFile()) << "Received invalid update channel from confog:" << channel << "defaulting to:" @@ -711,12 +709,17 @@ QString ConfigFile::updateChannel() const return channel; } +QStringList ConfigFile::validUpdateChannels() const +{ + return { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") }; +} + void ConfigFile::setUpdateChannel(const QString &channel) { - if (!validUpdateChannels.contains(channel)) { + if (!validUpdateChannels().contains(channel)) { qCWarning(lcConfigFile()) << "Received invalid update channel:" << channel - << "can only accept 'stable' or 'beta'. Ignoring."; + << "can only accept 'stable', 'beta' or 'daily'. Ignoring."; return; } diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index 97ec16e2f5ad7..851f89d10bb55 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -196,6 +196,7 @@ class OWNCLOUDSYNC_EXPORT ConfigFile [[nodiscard]] int updateSegment() const; [[nodiscard]] QString updateChannel() const; + [[nodiscard]] QStringList validUpdateChannels() const; void setUpdateChannel(const QString &channel); [[nodiscard]] QString overrideServerUrl() const; From d5ecfa64878a27f24b2438e1da8b4e8c3237f078 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 16:08:59 +0200 Subject: [PATCH 02/12] Modernize ConfigFile::updateChannel and Updater::getQueryParams. Signed-off-by: Camila Ayres --- src/gui/updater/updater.cpp | 21 +++++++++------------ src/libsync/configfile.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/gui/updater/updater.cpp b/src/gui/updater/updater.cpp index 4365ae5837ab4..6f5f3970a1aed 100644 --- a/src/gui/updater/updater.cpp +++ b/src/gui/updater/updater.cpp @@ -75,9 +75,7 @@ QUrl Updater::updateUrl() QUrlQuery Updater::getQueryParams() { - QUrlQuery query; - Theme *theme = Theme::instance(); - QString platform = QStringLiteral("stranger"); + auto platform = QStringLiteral("stranger"); if (Utility::isLinux()) { platform = QStringLiteral("linux"); } else if (Utility::isBSD()) { @@ -88,8 +86,8 @@ QUrlQuery Updater::getQueryParams() platform = QStringLiteral("macos"); } - QString sysInfo = getSystemInfo(); - if (!sysInfo.isEmpty()) { + QUrlQuery query; + if (const auto sysInfo = getSystemInfo(); !sysInfo.isEmpty()) { query.addQueryItem(QStringLiteral("client"), sysInfo); } query.addQueryItem(QStringLiteral("version"), clientVersion()); @@ -97,21 +95,20 @@ QUrlQuery Updater::getQueryParams() query.addQueryItem(QStringLiteral("osRelease"), QSysInfo::productType()); query.addQueryItem(QStringLiteral("osVersion"), QSysInfo::productVersion()); query.addQueryItem(QStringLiteral("kernelVersion"), QSysInfo::kernelVersion()); - query.addQueryItem(QStringLiteral("oem"), theme->appName()); + query.addQueryItem(QStringLiteral("oem"), Theme::instance()->appName()); query.addQueryItem(QStringLiteral("buildArch"), QSysInfo::buildCpuArchitecture()); query.addQueryItem(QStringLiteral("currentArch"), QSysInfo::currentCpuArchitecture()); - QString suffix = QStringLiteral(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); + const auto suffix = QStringLiteral(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); query.addQueryItem(QStringLiteral("versionsuffix"), suffix); - auto channel = ConfigFile().updateChannel(); - if (channel != QLatin1String("stable")) { + ConfigFile config; + if (const auto channel = config.updateChannel(); + channel != QLatin1String("stable")) { query.addQueryItem(QStringLiteral("channel"), channel); } - // updateSegment (see configfile.h) - ConfigFile cfg; - auto updateSegment = cfg.updateSegment(); + const auto updateSegment = config.updateSegment(); query.addQueryItem(QLatin1String("updatesegment"), QString::number(updateSegment)); return query; diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index f70dfe2b36e66..ca2f3eadc85fc 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -686,9 +686,9 @@ int ConfigFile::updateSegment() const QString ConfigFile::updateChannel() const { - QString defaultUpdateChannel = QStringLiteral("stable"); - QString suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); - if (suffix.startsWith("daily") + auto defaultUpdateChannel = QStringLiteral("stable"); + if (const auto suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); + suffix.startsWith("daily") || suffix.startsWith("nightly") || suffix.startsWith("alpha") || suffix.startsWith("rc") @@ -699,7 +699,7 @@ QString ConfigFile::updateChannel() const QSettings settings(configFile(), QSettings::IniFormat); const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString(); if (!validUpdateChannels().contains(channel)) { - qCWarning(lcConfigFile()) << "Received invalid update channel from confog:" + qCWarning(lcConfigFile()) << "Received invalid update channel from config:" << channel << "defaulting to:" << defaultUpdateChannel; From e396fbe4684a92274212c29da9d4500842061229 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 17:11:12 +0200 Subject: [PATCH 03/12] Adds info about daily builds to message shown if user changes update channel. - Also makes the explanation more concise. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 1c77cf42e1819..fe6f5bf65784d 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -386,21 +386,16 @@ void GeneralSettings::slotUpdateChannelChanged() 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."), + tr("Changing update channel?"), + tr("The channel determines which upgrades will be offered to install:\n" + "- stable: contains versions considered reliable.\n" + "- beta: contains versions with new features in test.\n" + "- daily: contains versions created daily only for testing.\n\n" + "Downgrading is not possible: changing from beta to stable means waiting for a newer " + "version than the one installed."), QMessageBox::NoButton, this); - auto acceptButton = msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole); + const 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, updateChannelToLocalized] { msgBox->deleteLater(); From 1dfa608d6bd4bb30f7cabc462d49dec1f6286c2e Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 17:18:40 +0200 Subject: [PATCH 04/12] Clean up code in GeneralSettings. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 45 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index fe6f5bf65784d..c1f6f354f1555 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -190,8 +190,6 @@ GeneralSettings::GeneralSettings(QWidget *parent) }); loadMiscSettings(); - // updater info now set in: customizeStyle - //slotUpdateInfo(); // misc connect(_ui->monoIconsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings); @@ -286,33 +284,36 @@ void GeneralSettings::loadMiscSettings() #if defined(BUILD_UPDATER) void GeneralSettings::slotUpdateInfo() { + ConfigFile config; const auto updater = Updater::instance(); - if (ConfigFile().skipUpdateCheck() || !updater) { + if (config.skipUpdateCheck() || !updater) { // updater disabled on compile _ui->updatesContainer->setVisible(false); return; } + const auto validUpdateChannels = config.validUpdateChannels(); + _ui->updateChannel->addItems(validUpdateChannels); + if (updater) { connect(_ui->updateButton, &QAbstractButton::clicked, this, - &GeneralSettings::slotUpdateCheckNow, Qt::UniqueConnection); connect(_ui->autoCheckForUpdatesCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleAutoUpdateCheck, Qt::UniqueConnection); - _ui->autoCheckForUpdatesCheckBox->setChecked(ConfigFile().autoUpdateCheck()); + _ui->autoCheckForUpdatesCheckBox->setChecked(config.autoUpdateCheck()); } // Note: the sparkle-updater is not an OCUpdater - auto *ocupdater = qobject_cast(updater); + const auto *ocupdater = qobject_cast(updater); 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); - QString status = ocupdater->statusString(OCUpdater::UpdateStatusStringFormat::Html); + auto status = ocupdater->statusString(OCUpdater::UpdateStatusStringFormat::Html); Theme::replaceLinkColorStringBackgroundAware(status); _ui->updateStateLabel->setOpenExternalLinks(false); @@ -320,9 +321,7 @@ void GeneralSettings::slotUpdateInfo() Utility::openBrowser(QUrl(link)); }); _ui->updateStateLabel->setText(status); - _ui->restartButton->setVisible(ocupdater->downloadState() == OCUpdater::DownloadComplete); - _ui->updateButton->setEnabled(ocupdater->downloadState() != OCUpdater::CheckingServer && ocupdater->downloadState() != OCUpdater::Downloading && ocupdater->downloadState() != OCUpdater::DownloadComplete); @@ -340,12 +339,8 @@ void GeneralSettings::slotUpdateInfo() } #endif - // stable, beta, daily - ConfigFile config; - const auto validUpdateChannels = config.validUpdateChannels(); const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(config.updateChannel()); - _ui->updateChannel->addItems(validUpdateChannels); - _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex); + _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0); connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection); } @@ -353,17 +348,19 @@ void GeneralSettings::slotUpdateInfo() void GeneralSettings::slotUpdateChannelChanged() { const auto updateChannelToLocalized = [](const QString &channel) { - auto decodedTranslatedChannel = QString{}; - if (channel == QStringLiteral("stable")) { - decodedTranslatedChannel = tr("stable"); - } else if (channel == QStringLiteral("beta")) { - decodedTranslatedChannel = tr("beta"); - } else if (channel == QStringLiteral("daily")) { - decodedTranslatedChannel = tr("daily"); + return tr("stable"); + } + + if (channel == QStringLiteral("beta")) { + return tr("beta"); + } + + if (channel == QStringLiteral("daily")) { + return tr("daily"); } - return decodedTranslatedChannel; + return QString{}; }; const auto updateChannelFromLocalized = [](const int index) { @@ -374,9 +371,9 @@ void GeneralSettings::slotUpdateChannelChanged() case 2: return QStringLiteral("daily"); break; - default: - return QStringLiteral("stable"); } + + return QStringLiteral("stable"); }; const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex()); From d905401a35c406e5c02efde5e130a220c78a16d3 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 20:52:11 +0200 Subject: [PATCH 05/12] List daily update channel in the general settings view. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index c1f6f354f1555..1851b7cc2a9be 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -279,6 +279,14 @@ void GeneralSettings::loadMiscSettings() _ui->stopExistingFolderNowBigSyncCheckBox->setChecked(_ui->existingFolderLimitCheckBox->isChecked() && cfgFile.stopSyncingExistingFoldersOverLimit()); _ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage()); _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); + +#if defined(BUILD_UPDATER) + auto validUpdateChannels = cfgFile.validUpdateChannels(); + _ui->updateChannel->addItems(validUpdateChannels); + const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.updateChannel()); + _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0); + connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged); +#endif } #if defined(BUILD_UPDATER) @@ -292,9 +300,6 @@ void GeneralSettings::slotUpdateInfo() return; } - const auto validUpdateChannels = config.validUpdateChannels(); - _ui->updateChannel->addItems(validUpdateChannels); - if (updater) { connect(_ui->updateButton, &QAbstractButton::clicked, @@ -338,11 +343,6 @@ void GeneralSettings::slotUpdateInfo() _ui->updateButton->setEnabled(enableUpdateButton); } #endif - - const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(config.updateChannel()); - _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0); - connect(_ui->updateChannel, &QComboBox::currentTextChanged, - this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection); } void GeneralSettings::slotUpdateChannelChanged() From 6f60094b465da88aaf492312e9e51922a164286f Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 26 Jun 2024 19:11:26 +0200 Subject: [PATCH 06/12] Change the default MIRALL_VERSION_SUFFIX from "git" to "daily". Signed-off-by: Camila Ayres --- VERSION.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.cmake b/VERSION.cmake index 50bd2dfc264c2..27bbf8f801af6 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -18,7 +18,7 @@ set(NEXTCLOUD_SERVER_VERSION_MOUNT_ROOT_PROPERTY_SUPPORTED_MINOR 0) set(NEXTCLOUD_SERVER_VERSION_MOUNT_ROOT_PROPERTY_SUPPORTED_PATCH 3) if ( NOT DEFINED MIRALL_VERSION_SUFFIX ) - set( MIRALL_VERSION_SUFFIX "git") #e.g. beta1, beta2, rc1 + set( MIRALL_VERSION_SUFFIX "daily") #e.g. beta1, beta2, rc1 endif( NOT DEFINED MIRALL_VERSION_SUFFIX ) if( NOT DEFINED MIRALL_VERSION_BUILD ) From 1e68dab5501506a72b3d39269151396053cc8275 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 26 Jun 2024 19:12:59 +0200 Subject: [PATCH 07/12] Use the value from MIRALL_VERSION_SUFFIX as the default update channel. Signed-off-by: Camila Ayres --- src/libsync/configfile.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index ca2f3eadc85fc..4eb39de725db1 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -686,16 +686,7 @@ int ConfigFile::updateSegment() const QString ConfigFile::updateChannel() const { - auto defaultUpdateChannel = QStringLiteral("stable"); - if (const auto suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); - suffix.startsWith("daily") - || suffix.startsWith("nightly") - || suffix.startsWith("alpha") - || suffix.startsWith("rc") - || suffix.startsWith("beta")) { - defaultUpdateChannel = QStringLiteral("beta"); - } - + auto defaultUpdateChannel = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); QSettings settings(configFile(), QSettings::IniFormat); const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString(); if (!validUpdateChannels().contains(channel)) { From 8d22b61737a29493c36a27f749f17b511d613156 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 26 Jun 2024 20:18:41 +0200 Subject: [PATCH 08/12] Add versionSuffix function to Theme. Signed-off-by: Camila Ayres --- src/gui/updater/updater.cpp | 2 +- src/libsync/configfile.cpp | 2 +- src/libsync/theme.cpp | 5 +++++ src/libsync/theme.h | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/updater/updater.cpp b/src/gui/updater/updater.cpp index 6f5f3970a1aed..2e49e8706af08 100644 --- a/src/gui/updater/updater.cpp +++ b/src/gui/updater/updater.cpp @@ -99,7 +99,7 @@ QUrlQuery Updater::getQueryParams() query.addQueryItem(QStringLiteral("buildArch"), QSysInfo::buildCpuArchitecture()); query.addQueryItem(QStringLiteral("currentArch"), QSysInfo::currentCpuArchitecture()); - const auto suffix = QStringLiteral(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); + const auto suffix = Theme::instance()->versionSuffix(); query.addQueryItem(QStringLiteral("versionsuffix"), suffix); ConfigFile config; diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 4eb39de725db1..b43317ae938e9 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -686,7 +686,7 @@ int ConfigFile::updateSegment() const QString ConfigFile::updateChannel() const { - auto defaultUpdateChannel = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); + auto defaultUpdateChannel = Theme::instance()->versionSuffix(); QSettings settings(configFile(), QSettings::IniFormat); const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString(); if (!validUpdateChannels().contains(channel)) { diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index bb4bae4c4be86..b20ef2a6798af 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -195,6 +195,11 @@ QString Theme::version() const return MIRALL_VERSION_STRING; } +QString Theme::versionSuffix() const +{ + return QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX)); +} + QString Theme::configFileName() const { return QStringLiteral(APPLICATION_CONFIG_NAME ".cfg"); diff --git a/src/libsync/theme.h b/src/libsync/theme.h index c59266f65cf81..e5d312ddee400 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -196,6 +196,7 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject [[nodiscard]] QString statusHeaderText(SyncResult::Status) const; [[nodiscard]] QString version() const; + [[nodiscard]] QString versionSuffix() const; /** * Characteristics: bool if more than one sync folder is allowed From 13b0d9e564c3260b2d32d1ffef78f43c392ad39a Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 26 Jun 2024 21:14:07 +0200 Subject: [PATCH 09/12] Enforce the update channel based on the current client installed. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 6 +++--- src/gui/updater/updater.cpp | 14 +++----------- src/libsync/configfile.cpp | 35 ++++++++++++++++++++++------------- src/libsync/configfile.h | 3 ++- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 1851b7cc2a9be..562913ae4261a 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -283,7 +283,7 @@ void GeneralSettings::loadMiscSettings() #if defined(BUILD_UPDATER) auto validUpdateChannels = cfgFile.validUpdateChannels(); _ui->updateChannel->addItems(validUpdateChannels); - const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.updateChannel()); + const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.currentUpdateChannel()); _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0); connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged); #endif @@ -377,7 +377,7 @@ void GeneralSettings::slotUpdateChannelChanged() }; const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex()); - if (channel == ConfigFile().updateChannel()) { + if (channel == ConfigFile().currentUpdateChannel()) { return; } @@ -409,7 +409,7 @@ void GeneralSettings::slotUpdateChannelChanged() } #endif } else { - _ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().updateChannel())); + _ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().currentUpdateChannel())); } }); msgBox->open(); diff --git a/src/gui/updater/updater.cpp b/src/gui/updater/updater.cpp index 2e49e8706af08..87957c724e3d7 100644 --- a/src/gui/updater/updater.cpp +++ b/src/gui/updater/updater.cpp @@ -98,23 +98,15 @@ QUrlQuery Updater::getQueryParams() query.addQueryItem(QStringLiteral("oem"), Theme::instance()->appName()); query.addQueryItem(QStringLiteral("buildArch"), QSysInfo::buildCpuArchitecture()); query.addQueryItem(QStringLiteral("currentArch"), QSysInfo::currentCpuArchitecture()); - - const auto suffix = Theme::instance()->versionSuffix(); - query.addQueryItem(QStringLiteral("versionsuffix"), suffix); + query.addQueryItem(QStringLiteral("versionsuffix"), Theme::instance()->versionSuffix()); ConfigFile config; - if (const auto channel = config.updateChannel(); - channel != QLatin1String("stable")) { - query.addQueryItem(QStringLiteral("channel"), channel); - } - - const auto updateSegment = config.updateSegment(); - query.addQueryItem(QLatin1String("updatesegment"), QString::number(updateSegment)); + query.addQueryItem(QStringLiteral("channel"), config.currentUpdateChannel()); + query.addQueryItem(QLatin1String("updatesegment"), QString::number(config.updateSegment())); return query; } - QString Updater::getSystemInfo() { #ifdef Q_OS_LINUX diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index b43317ae938e9..0a803595f2248 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -109,6 +109,9 @@ static constexpr char forceLoginV2C[] = "forceLoginV2"; static constexpr char certPath[] = "http_certificatePath"; static constexpr char certPasswd[] = "http_certificatePasswd"; + +static const QStringList validUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") }; +static const char stableUpdateChannel[] = "stable"; } namespace OCC { @@ -684,25 +687,31 @@ int ConfigFile::updateSegment() const return segment; } -QString ConfigFile::updateChannel() const +QStringList ConfigFile::validUpdateChannels() const { - auto defaultUpdateChannel = Theme::instance()->versionSuffix(); - QSettings settings(configFile(), QSettings::IniFormat); - const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString(); - if (!validUpdateChannels().contains(channel)) { - qCWarning(lcConfigFile()) << "Received invalid update channel from config:" - << channel - << "defaulting to:" - << defaultUpdateChannel; - return defaultUpdateChannel; + return validUpdateChannelsList; +} + +QString ConfigFile::defaultUpdateChannel() const +{ + if (const auto currentVersionSuffix = Theme::instance()->versionSuffix();validUpdateChannels().contains(currentVersionSuffix)) { + qCWarning(lcConfigFile()) << "Enforcing update channel" << currentVersionSuffix << "because of the version suffix of the current client."; + return currentVersionSuffix; } - return channel; + return stableUpdateChannel; } -QStringList ConfigFile::validUpdateChannels() const +QString ConfigFile::currentUpdateChannel() const { - return { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") }; + QSettings settings(configFile(), QSettings::IniFormat); + if (const auto configUpdateChannel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel()).toString(); + validUpdateChannels().contains(configUpdateChannel)) { + qCWarning(lcConfigFile()) << "Config file has a valid update channel:" << configUpdateChannel; + return configUpdateChannel; + } + + return defaultUpdateChannel(); } void ConfigFile::setUpdateChannel(const QString &channel) diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index 851f89d10bb55..6b10a8f2fd1fe 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -195,7 +195,8 @@ class OWNCLOUDSYNC_EXPORT ConfigFile See: https://github.com/nextcloud/client_updater_server/pull/36 */ [[nodiscard]] int updateSegment() const; - [[nodiscard]] QString updateChannel() const; + [[nodiscard]] QString currentUpdateChannel() const; + [[nodiscard]] QString defaultUpdateChannel() const; [[nodiscard]] QStringList validUpdateChannels() const; void setUpdateChannel(const QString &channel); From a9ed8f915e41acab983440528232bd3743b7f1bf Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 27 Jun 2024 13:53:09 +0200 Subject: [PATCH 10/12] Improve text displayed when user switches update channel. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 562913ae4261a..69a2bfb46f47f 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -385,11 +385,10 @@ void GeneralSettings::slotUpdateChannelChanged() QMessageBox::Warning, tr("Changing update channel?"), tr("The channel determines which upgrades will be offered to install:\n" - "- stable: contains versions considered reliable.\n" - "- beta: contains versions with new features in test.\n" - "- daily: contains versions created daily only for testing.\n\n" - "Downgrading is not possible: changing from beta to stable means waiting for a newer " - "version than the one installed."), + "- stable: contains tested versions considered reliable\n" + "- beta: contains versions with new features that may not be tested thoroughly\n" + "- daily: contains versions created daily only for testing and development\n\n" + "Downgrading versions is not possible immediately: changing from beta to stable means waiting for the new stable version."), QMessageBox::NoButton, this); const auto acceptButton = msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole); From e788c2fb1c4c4091ff70542dcffba60020ec536b Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 27 Jun 2024 18:15:23 +0200 Subject: [PATCH 11/12] Use radio buttons instead of a combo box to list the update channels. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 68 ++++++++------ src/gui/generalsettings.h | 5 +- src/gui/generalsettings.ui | 173 ++++++++++++++++++++---------------- 3 files changed, 137 insertions(+), 109 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 69a2bfb46f47f..4830cb14c7928 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include @@ -281,11 +283,33 @@ void GeneralSettings::loadMiscSettings() _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); #if defined(BUILD_UPDATER) - auto validUpdateChannels = cfgFile.validUpdateChannels(); - _ui->updateChannel->addItems(validUpdateChannels); - const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.currentUpdateChannel()); - _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0); - connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged); + const auto updateChannelToLocalized = [](const QString &channel) { + if (channel == QStringLiteral("stable")) { + return tr("stable"); + } + + if (channel == QStringLiteral("beta")) { + return tr("beta"); + } + + if (channel == QStringLiteral("daily")) { + return tr("daily"); + } + + return QString{}; + }; + + _updateChannelGroup = new QButtonGroup(this); + auto position = _ui->updateChannelLayout->indexOf(_ui->updateChannelLabel); + for (const auto &channel : cfgFile.validUpdateChannels()) { + auto channelRadioButton = new QRadioButton(updateChannelToLocalized(channel), this); + _updateChannelGroup->addButton(channelRadioButton, cfgFile.validUpdateChannels().indexOf(channel)); + position++; + _ui->updateChannelLayout->insertWidget(position, channelRadioButton); + channelRadioButton->setChecked(cfgFile.currentUpdateChannel() == channel); + } + connect(_updateChannelGroup, &QButtonGroup::idClicked, this, &GeneralSettings::slotUpdateChannelChanged); + #endif } @@ -345,38 +369,23 @@ void GeneralSettings::slotUpdateInfo() #endif } -void GeneralSettings::slotUpdateChannelChanged() +void GeneralSettings::slotUpdateChannelChanged(const int id) { - const auto updateChannelToLocalized = [](const QString &channel) { - if (channel == QStringLiteral("stable")) { - return tr("stable"); - } - - if (channel == QStringLiteral("beta")) { - return tr("beta"); - } + auto updateChannelselected = _updateChannelGroup->button(id); + const auto updateChannelFromLocalized = [](const QString &channel) { - if (channel == QStringLiteral("daily")) { - return tr("daily"); + if (channel == tr("daily")) { + return QStringLiteral("daily"); } - return QString{}; - }; - - const auto updateChannelFromLocalized = [](const int index) { - switch(index) { - case 1: + if (channel == tr("beta")) { return QStringLiteral("beta"); - break; - case 2: - return QStringLiteral("daily"); - break; } return QStringLiteral("stable"); }; - const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex()); + const auto channel = updateChannelFromLocalized(updateChannelselected->text()); if (channel == ConfigFile().currentUpdateChannel()) { return; } @@ -393,7 +402,7 @@ void GeneralSettings::slotUpdateChannelChanged() this); const 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, updateChannelToLocalized] { + connect(msgBox, &QMessageBox::finished, msgBox, [this, channel, msgBox, acceptButton] { msgBox->deleteLater(); if (msgBox->clickedButton() == acceptButton) { ConfigFile().setUpdateChannel(channel); @@ -408,7 +417,8 @@ void GeneralSettings::slotUpdateChannelChanged() } #endif } else { - _ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().currentUpdateChannel())); + auto currentUpdateChannel = _updateChannelGroup->button(ConfigFile().validUpdateChannels().indexOf(ConfigFile().currentUpdateChannel())); + currentUpdateChannel->setChecked(true); } }); msgBox->open(); diff --git a/src/gui/generalsettings.h b/src/gui/generalsettings.h index 70a726142db8b..4c59eaaef0f62 100644 --- a/src/gui/generalsettings.h +++ b/src/gui/generalsettings.h @@ -20,6 +20,8 @@ #include #include +class QButtonGroup; + namespace OCC { class IgnoreListEditor; class SyncLogDialog; @@ -56,7 +58,7 @@ private slots: void slotShowLegalNotice(); #if defined(BUILD_UPDATER) void slotUpdateInfo(); - void slotUpdateChannelChanged(); + void slotUpdateChannelChanged(const int id); void slotUpdateCheckNow(); void slotToggleAutoUpdateCheck(); #endif @@ -67,6 +69,7 @@ private slots: Ui::GeneralSettings *_ui; QPointer _ignoreEditor; bool _currentlyLoading = false; + QButtonGroup *_updateChannelGroup; }; diff --git a/src/gui/generalsettings.ui b/src/gui/generalsettings.ui index aac6ea6ab82ba..c01f8e77a9009 100644 --- a/src/gui/generalsettings.ui +++ b/src/gui/generalsettings.ui @@ -6,7 +6,7 @@ 0 0 - 667 + 933 663 @@ -14,6 +14,59 @@ Form + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + General Settings + + + + + + For System Tray + + + Use &monochrome icons + + + + + + + &Launch on system startup + + + + + + + Show server &notifications + + + + + + + Show call notifications + + + + + + @@ -40,10 +93,10 @@ - Qt::Orientation::Horizontal + Qt::Vertical - QSizePolicy::Policy::Fixed + QSizePolicy::Fixed @@ -77,10 +130,10 @@ - Qt::Orientation::Horizontal + Qt::Vertical - QSizePolicy::Policy::Fixed + QSizePolicy::Fixed @@ -104,10 +157,10 @@ - Qt::Orientation::Horizontal + Qt::Vertical - QSizePolicy::Policy::Fixed + QSizePolicy::Fixed @@ -197,7 +250,7 @@ - Qt::Orientation::Horizontal + Qt::Vertical @@ -247,7 +300,7 @@ 0 - + @@ -262,13 +315,16 @@ - + 0 0 + + &Restart && Update + @@ -284,19 +340,6 @@ - - - - - 0 - 0 - - - - &Restart && Update - - - @@ -330,10 +373,23 @@ + + + + Qt::Horizontal + + + + 20 + 20 + + + + - Qt::Orientation::Horizontal + Qt::Vertical @@ -361,10 +417,23 @@ + + + + Qt::Horizontal + + + + 20 + 20 + + + + - Qt::Orientation::Horizontal + Qt::Vertical @@ -382,59 +451,6 @@ - - - - Qt::Orientation::Vertical - - - - 20 - 0 - - - - - - - - General Settings - - - - - - For System Tray - - - Use &monochrome icons - - - - - - - &Launch on system startup - - - - - - - Show server &notifications - - - - - - - Show call notifications - - - - - - @@ -445,7 +461,6 @@ newFolderLimitCheckBox newFolderLimitSpinBox crashreporterCheckBox - restartButton From 091b49a33299598dbeda1a30fe40a0b88122ff85 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 27 Jun 2024 18:24:10 +0200 Subject: [PATCH 12/12] Remove commented out line. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 4830cb14c7928..fee6efa1512e7 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -340,7 +340,6 @@ void GeneralSettings::slotUpdateInfo() 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); auto status = ocupdater->statusString(OCUpdater::UpdateStatusStringFormat::Html); Theme::replaceLinkColorStringBackgroundAware(status);