diff --git a/include/QSimpleUpdater.h b/include/QSimpleUpdater.h index d235dd6..eaa827e 100644 --- a/include/QSimpleUpdater.h +++ b/include/QSimpleUpdater.h @@ -79,6 +79,7 @@ class QSU_DECL QSimpleUpdater : public QObject { bool getDownloaderEnabled (const QString& url) const; bool usesCustomInstallProcedures (const QString& url) const; + QString getOpenUrl (const QString& url) const; QString getChangelog (const QString& url) const; QString getModuleName (const QString& url) const; QString getDownloadUrl (const QString& url) const; diff --git a/src/QSimpleUpdater.cpp b/src/QSimpleUpdater.cpp index c234ba0..a54ba91 100644 --- a/src/QSimpleUpdater.cpp +++ b/src/QSimpleUpdater.cpp @@ -106,6 +106,19 @@ bool QSimpleUpdater::usesCustomInstallProcedures (const QString& url) const { return getUpdater (url)->useCustomInstallProcedures(); } +/** + * Returns the URL to open in a web browser of the \c Updater instance + * registered with the given \a url. + * + * \note If the module name is empty, then the \c Updater will use the + * application name as its module name. + * \note If an \c Updater instance registered with the given \a url is not + * found, that \c Updater instance will be initialized automatically + */ +QString QSimpleUpdater::getOpenUrl (const QString &url) const { + return getUpdater (url)->openUrl(); +} + /** * Returns the changelog of the \c Updater instance registered with the given * \a url. diff --git a/src/Updater.cpp b/src/Updater.cpp index bd9b9c7..3a0d07b 100644 --- a/src/Updater.cpp +++ b/src/Updater.cpp @@ -82,6 +82,16 @@ QString Updater::url() const { return m_url; } +/** + * Returns the URL that the update definitions file wants us to open in + * a web browser. + * + * \warning You should call \c checkForUpdates() before using this functio + */ +QString Updater::openUrl() const { + return m_openUrl; +} + /** * Returns the changelog defined by the update definitions file. * \warning You should call \c checkForUpdates() before using this function @@ -308,8 +318,8 @@ void Updater::setUpdateAvailable (const bool& available) { box.setDefaultButton (QMessageBox::Yes); if (box.exec() == QMessageBox::Yes) { - if (!m_openUrl.isEmpty()) - QDesktopServices::openUrl (QUrl (m_openUrl)); + if (!openUrl().isEmpty()) + QDesktopServices::openUrl (QUrl (openUrl())); else if (downloaderEnabled()) m_downloader->startDownload (QUrl (downloadUrl())); diff --git a/src/Updater.h b/src/Updater.h index aac89ab..7e7d5a8 100644 --- a/src/Updater.h +++ b/src/Updater.h @@ -54,6 +54,7 @@ class QSU_DECL Updater : public QObject { ~Updater(); QString url() const; + QString openUrl() const; QString changelog() const; QString moduleName() const; QString downloadUrl() const;