General Settings window. Allow opening the update URL via mouse.
authoralex-z <blackslayer4@gmail.com>
Tue, 21 Sep 2021 10:04:08 +0000 (12:04 +0200)
committeralex-z <blackslayer4@gmail.com>
Tue, 21 Sep 2021 14:21:38 +0000 (16:21 +0200)
Signed-off-by: alex-z <blackslayer4@gmail.com>
src/gui/generalsettings.cpp
src/gui/updater/ocupdater.cpp
src/gui/updater/ocupdater.h

index 0f4c21f5286caf366a43975a91f1cbd545f4b44d..058bdf1d66998913832461c581da81cb2d6a9839 100644 (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);
index 684ee2020f6f58bf1b00309f08954663fa104138..6bcf726d05696383a0224578a1e9299d7c2a1b55 100644 (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:
index dbdb6be51774e72a33f51fdd51d44ed324348fa0..c6c1ad8dfa2271477024d283a710786975becf9f 100644 (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);