General Settings window. Allow opening the update URL via mouse.

Signed-off-by: alex-z <blackslayer4@gmail.com>
This commit is contained in:
alex-z 2021-09-21 12:04:08 +02:00
parent 4992977167
commit 59199fc907
3 changed files with 24 additions and 5 deletions

View File

@ -21,6 +21,7 @@
#include "configfile.h"
#include "owncloudsetupwizard.h"
#include "accountmanager.h"
#include "guiutility.h"
#if defined(BUILD_UPDATER)
#include "updater/updater.h"
@ -275,8 +276,13 @@ void GeneralSettings::slotUpdateInfo()
connect(_ui->updateButton, &QAbstractButton::clicked, this, &GeneralSettings::slotUpdateCheckNow, Qt::UniqueConnection);
connect(_ui->autoCheckForUpdatesCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleAutoUpdateCheck);
QString status = ocupdater->statusString();
QString 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);

View File

@ -144,7 +144,7 @@ void OCUpdater::backgroundCheckForUpdate()
}
}
QString OCUpdater::statusString() const
QString OCUpdater::statusString(UpdateStatusStringFormat format) const
{
QString updateVersion = _updateInfo.versionString();
@ -153,12 +153,20 @@ QString OCUpdater::statusString() const
return tr("Downloading %1. Please wait …").arg(updateVersion);
case DownloadComplete:
return tr("%1 available. Restart application to start the update.").arg(updateVersion);
case DownloadFailed:
case DownloadFailed: {
if (format == UpdateStatusStringFormat::Html) {
return tr("Could not download update. Please open <a href='%1'>%1</a> to download the update manually.").arg(_updateInfo.web());
}
return tr("Could not download update. Please open %1 to download the update manually.").arg(_updateInfo.web());
}
case DownloadTimedOut:
return tr("Could not check for new updates.");
case UpdateOnlyAvailableThroughSystem:
case UpdateOnlyAvailableThroughSystem: {
if (format == UpdateStatusStringFormat::Html) {
return tr("New %1 is available. Please open <a href='%2'>%2</a> to download the update.").arg(updateVersion, _updateInfo.web());
}
return tr("New %1 is available. Please open %2 to download the update.").arg(updateVersion, _updateInfo.web());
}
case CheckingServer:
return tr("Checking update server …");
case Unknown:

View File

@ -97,6 +97,11 @@ public:
DownloadFailed,
DownloadTimedOut,
UpdateOnlyAvailableThroughSystem };
enum UpdateStatusStringFormat {
PlainText,
Html,
};
explicit OCUpdater(const QUrl &url);
void setUpdateUrl(const QUrl &url);
@ -105,7 +110,7 @@ public:
void checkForUpdate() override;
QString statusString() const;
QString statusString(UpdateStatusStringFormat format = PlainText) const;
int downloadState() const;
void setDownloadState(DownloadState state);