Tweak updating, no more NSIS.
This commit is contained in:
parent
0a8ff1a0cc
commit
75849453de
5 changed files with 32 additions and 46 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<releases>
|
<releases>
|
||||||
<release version="3.2.4">
|
<release version="3.2.4">
|
||||||
<url platform="x86" os="Windows">https://bitbucket.org/skunkos/rssguard/downloads/rssguard-3.2.4-win32.exe</url>
|
<url platform="x86" os="Windows">https://bitbucket.org/skunkos/rssguard/downloads/rssguard-3.2.4-win32.zip</url>
|
||||||
</release>
|
</release>
|
||||||
</releases>
|
</releases>
|
||||||
|
|
|
@ -30,15 +30,11 @@
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
FormUpdate::FormUpdate(QWidget *parent)
|
FormUpdate::FormUpdate(QWidget *parent)
|
||||||
: QDialog(parent), m_downloader(NULL), m_readyToInstall(false), m_ui(new Ui::FormUpdate) {
|
: QDialog(parent), m_downloader(NULL), m_readyToInstall(false), m_ui(new Ui::FormUpdate) {
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_btnUpdate = m_ui->m_buttonBox->addButton(tr("Update"), QDialogButtonBox::ActionRole);
|
m_btnUpdate = m_ui->m_buttonBox->addButton(tr("Download update"), QDialogButtonBox::ActionRole);
|
||||||
m_btnUpdate->setToolTip(tr("Download new installation files."));
|
m_btnUpdate->setToolTip(tr("Download new installation files."));
|
||||||
m_ui->m_lblCurrentRelease->setText(STRFY(APP_VERSION));
|
m_ui->m_lblCurrentRelease->setText(STRFY(APP_VERSION));
|
||||||
|
|
||||||
|
@ -89,7 +85,7 @@ void FormUpdate::checkForUpdates() {
|
||||||
if (SystemFactory::isVersionNewer(update.first.m_availableVersion, STRFY(APP_VERSION))) {
|
if (SystemFactory::isVersionNewer(update.first.m_availableVersion, STRFY(APP_VERSION))) {
|
||||||
m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok,
|
m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok,
|
||||||
tr("New release available."),
|
tr("New release available."),
|
||||||
tr("This is new version which can be\ndownloaded and installed."));
|
tr("This is new version which can be\ndownloaded."));
|
||||||
m_btnUpdate->setEnabled(true);
|
m_btnUpdate->setEnabled(true);
|
||||||
m_btnUpdate->setToolTip(is_self_update_for_this_system ?
|
m_btnUpdate->setToolTip(is_self_update_for_this_system ?
|
||||||
tr("Download installation file for your OS.") :
|
tr("Download installation file for your OS.") :
|
||||||
|
@ -157,8 +153,8 @@ void FormUpdate::updateCompleted(QNetworkReply::NetworkError status, QByteArray
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case QNetworkReply::NoError:
|
case QNetworkReply::NoError:
|
||||||
saveUpdateFile(contents);
|
saveUpdateFile(contents);
|
||||||
m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok, tr("Downloaded successfully"), tr("Package was downloaded successfully."));
|
m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok, tr("Downloaded successfully"), tr("Package was downloaded successfully.\nYou must install it manually."));
|
||||||
m_btnUpdate->setText(tr("Install update"));
|
m_btnUpdate->setText(tr("Go to update file"));
|
||||||
m_btnUpdate->setEnabled(true);
|
m_btnUpdate->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -180,32 +176,15 @@ void FormUpdate::startUpdate() {
|
||||||
url_file = STRFY(APP_URL);
|
url_file = STRFY(APP_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_readyToInstall) {
|
if (m_readyToInstall) {
|
||||||
// Some package is downloaded and it can be installed
|
if (!SystemFactory::openFolderFile(m_updateFilePath)) {
|
||||||
// via self-update feature.
|
MessageBox::show(this,
|
||||||
close();
|
QMessageBox::Warning,
|
||||||
|
tr("Cannot open directory"),
|
||||||
qDebug("Preparing to launch external installer '%s'.", qPrintable(QDir::toNativeSeparators(m_updateFilePath)));
|
tr("Cannot open output directory. Open it manually."),
|
||||||
|
QString(),
|
||||||
#if defined(Q_OS_WIN)
|
m_updateFilePath);
|
||||||
HINSTANCE exec_result = ShellExecute(NULL,
|
|
||||||
NULL,
|
|
||||||
reinterpret_cast<const WCHAR*>(QDir::toNativeSeparators(m_updateFilePath).utf16()),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
SW_NORMAL);
|
|
||||||
|
|
||||||
if (((int)exec_result) <= 32) {
|
|
||||||
qDebug("External updater was not launched due to error.");
|
|
||||||
|
|
||||||
qApp->showGuiMessage(tr("Cannot update application"),
|
|
||||||
tr("Cannot launch external updater. Update application manually."),
|
|
||||||
QSystemTrayIcon::Warning, this);
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (update_for_this_system) {
|
else if (update_for_this_system) {
|
||||||
// Nothing is downloaded yet, but update for this system
|
// Nothing is downloaded yet, but update for this system
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QProcess>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
|
@ -240,6 +241,15 @@ bool SystemFactory::isVersionEqualOrNewer(const QString &new_version, const QStr
|
||||||
return new_version == base_version || isVersionNewer(new_version, base_version);
|
return new_version == base_version || isVersionNewer(new_version, base_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SystemFactory::openFolderFile(const QString &file_path) {
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
return QProcess::startDetached(QString("explorer.exe /select, \"") + QDir::toNativeSeparators(file_path) + "\"");
|
||||||
|
#else
|
||||||
|
const QString folder = QDir::toNativeSeparators(QFileInfo(file_path).absoluteDir().absolutePath());
|
||||||
|
return QDesktopServices::openUrl(QUrl::fromLocalFile(folder));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
UpdateInfo SystemFactory::parseUpdatesFile(const QByteArray &updates_file, const QByteArray &changelog) const {
|
UpdateInfo SystemFactory::parseUpdatesFile(const QByteArray &updates_file, const QByteArray &changelog) const {
|
||||||
UpdateInfo update;
|
UpdateInfo update;
|
||||||
QDomDocument document; document.setContent(updates_file, false);
|
QDomDocument document; document.setContent(updates_file, false);
|
||||||
|
|
|
@ -90,6 +90,8 @@ class SystemFactory : public QObject {
|
||||||
static bool isVersionNewer(const QString &new_version, const QString &base_version);
|
static bool isVersionNewer(const QString &new_version, const QString &base_version);
|
||||||
static bool isVersionEqualOrNewer(const QString &new_version, const QString &base_version);
|
static bool isVersionEqualOrNewer(const QString &new_version, const QString &base_version);
|
||||||
|
|
||||||
|
static bool openFolderFile(const QString &file_path);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void checkForUpdatesOnStartup();
|
void checkForUpdatesOnStartup();
|
||||||
|
|
||||||
|
|
|
@ -213,19 +213,14 @@ void DownloadItem::openFile() {
|
||||||
|
|
||||||
void DownloadItem::openFolder() {
|
void DownloadItem::openFolder() {
|
||||||
if (m_output.exists()) {
|
if (m_output.exists()) {
|
||||||
const QString folder = QDir::toNativeSeparators(QFileInfo(m_output.fileName()).absoluteDir().absolutePath());
|
if (!SystemFactory::openFolderFile(m_output.fileName())) {
|
||||||
|
MessageBox::show(this,
|
||||||
#if defined(Q_OS_WIN32)
|
QMessageBox::Warning,
|
||||||
const QString file = QDir::toNativeSeparators(m_output.fileName());
|
tr("Cannot open directory"),
|
||||||
|
tr("Cannot open output directory. Open it manually."),
|
||||||
if (!QProcess::startDetached(QString("explorer.exe /select, \"") + file + "\"")) {
|
QString(),
|
||||||
MessageBox::show(this, QMessageBox::Warning, tr("Cannot open directory"), tr("Cannot open output directory. Open it manually."), QString(), folder);
|
m_output.fileName());
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(folder))) {
|
|
||||||
MessageBox::show(this, QMessageBox::Warning, tr("Cannot open directory"), tr("Cannot open output directory. Open it manually."), QString(), folder);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue