Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update channel UI enhancements #6873

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
99 changes: 55 additions & 44 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/generalsettings.cpp

File src/gui/generalsettings.cpp does not conform to Custom style guidelines. (lines 374, 394, 395, 396, 397, 398, 399)
* Copyright (C) by Daniel Molkentin <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -43,6 +43,8 @@
#include <QDir>
#include <QScopedValueRollback>
#include <QMessageBox>
#include <QButtongroup>
#include <QRadioButton>

#include <KZip>

Expand Down Expand Up @@ -190,8 +192,6 @@
});

loadMiscSettings();
// updater info now set in: customizeStyle
//slotUpdateInfo();

// misc
connect(_ui->monoIconsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
Expand Down Expand Up @@ -281,13 +281,44 @@
_ui->stopExistingFolderNowBigSyncCheckBox->setChecked(_ui->existingFolderLimitCheckBox->isChecked() && cfgFile.stopSyncingExistingFoldersOverLimit());
_ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());

#if defined(BUILD_UPDATER)
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
}

#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;
Expand All @@ -297,32 +328,28 @@
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<OCUpdater *>(updater);
const auto *ocupdater = qobject_cast<OCUpdater *>(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);
connect(_ui->updateStateLabel, &QLabel::linkActivated, this, [](const QString &link) {
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);
Expand All @@ -339,59 +366,42 @@
_ui->updateButton->setEnabled(enableUpdateButton);
}
#endif

// Channel selection
_ui->updateChannel->setCurrentIndex(ConfigFile().updateChannel() == "beta" ? 1 : 0);
connect(_ui->updateChannel, &QComboBox::currentTextChanged,
this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection);
}

void GeneralSettings::slotUpdateChannelChanged()
void GeneralSettings::slotUpdateChannelChanged(const int id)
{
const auto updateChannelToLocalized = [](const QString &channel) {
auto decodedTranslatedChannel = QString{};
auto updateChannelselected = _updateChannelGroup->button(id);
const auto updateChannelFromLocalized = [](const QString &channel) {

if (channel == QStringLiteral("stable")) {
decodedTranslatedChannel = tr("stable");
} else if (channel == QStringLiteral("beta")) {
decodedTranslatedChannel = tr("beta");
if (channel == tr("daily")) {
return QStringLiteral("daily");
}

return decodedTranslatedChannel;
};

const auto updateChannelFromLocalized = [](const int index) {
if (index == 1) {
if (channel == tr("beta")) {
return QStringLiteral("beta");
}

return QStringLiteral("stable");
};

const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex());
if (channel == ConfigFile().updateChannel()) {
const auto channel = updateChannelFromLocalized(updateChannelselected->text());
if (channel == ConfigFile().currentUpdateChannel()) {
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."),
tr("Changing update channel?"),
tr("The channel determines which upgrades will be offered to install:\n"
"- 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);
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] {
connect(msgBox, &QMessageBox::finished, msgBox, [this, channel, msgBox, acceptButton] {
msgBox->deleteLater();
if (msgBox->clickedButton() == acceptButton) {
ConfigFile().setUpdateChannel(channel);
Expand All @@ -406,7 +416,8 @@
}
#endif
} else {
_ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().updateChannel()));
auto currentUpdateChannel = _updateChannelGroup->button(ConfigFile().validUpdateChannels().indexOf(ConfigFile().currentUpdateChannel()));
currentUpdateChannel->setChecked(true);
}
});
msgBox->open();
Expand Down
5 changes: 4 additions & 1 deletion src/gui/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
#ifndef MIRALL_GENERALSETTINGS_H
#define MIRALL_GENERALSETTINGS_H

#include "config.h"

Check failure on line 18 in src/gui/generalsettings.h

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.h:18:10 [clang-diagnostic-error]

'config.h' file not found

#include <QWidget>
#include <QPointer>

class QButtonGroup;

Check warning on line 23 in src/gui/generalsettings.h

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.h:23:7 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'QButtonGroup' is non-const and globally accessible, consider making it const

namespace OCC {

Check warning on line 25 in src/gui/generalsettings.h

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.h:25:11 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'OCC' is non-const and globally accessible, consider making it const
class IgnoreListEditor;
class SyncLogDialog;

Expand Down Expand Up @@ -56,7 +58,7 @@
void slotShowLegalNotice();
#if defined(BUILD_UPDATER)
void slotUpdateInfo();
void slotUpdateChannelChanged();
void slotUpdateChannelChanged(const int id);
void slotUpdateCheckNow();
void slotToggleAutoUpdateCheck();
#endif
Expand All @@ -67,6 +69,7 @@
Ui::GeneralSettings *_ui;
QPointer<IgnoreListEditor> _ignoreEditor;
bool _currentlyLoading = false;
QButtonGroup *_updateChannelGroup;
};


Expand Down
Loading
Loading