Resolved issue #667. Check for updates - Test version.
--HG-- branch : develop
This commit is contained in:
parent
e56423905d
commit
c56992407e
|
@ -61,7 +61,7 @@ DialogAboutTape::DialogAboutTape(QWidget *parent)
|
||||||
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
|
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
|
||||||
{
|
{
|
||||||
// Set feed URL before doing anything else
|
// Set feed URL before doing anything else
|
||||||
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
|
FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL());
|
||||||
FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
|
FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) :
|
||||||
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
|
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
|
||||||
{
|
{
|
||||||
// Set feed URL before doing anything else
|
// Set feed URL before doing anything else
|
||||||
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
|
FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL());
|
||||||
FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
|
FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -64,12 +64,12 @@ int main(int argc, char *argv[])
|
||||||
app.InitOptions();
|
app.InitOptions();
|
||||||
|
|
||||||
// Due to unknown reasons version checker cause a crash. See issue #633.
|
// Due to unknown reasons version checker cause a crash. See issue #633.
|
||||||
// Before we will find what cause such crashes it will stay disabled in Release mode.
|
// Before we will find what cause such crashes it will stay disabled in Release mode on Mac OS.
|
||||||
#ifndef V_NO_ASSERT
|
#if !defined(Q_OS_MAC) || !defined(V_NO_ASSERT)
|
||||||
if (VApplication::IsGUIMode())
|
if (VApplication::IsGUIMode())
|
||||||
{
|
{
|
||||||
// Set feed URL before doing anything else
|
// Set feed URL before doing anything else
|
||||||
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
|
FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL());
|
||||||
|
|
||||||
// Check for updates automatically
|
// Check for updates automatically
|
||||||
FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
|
FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <QXmlStreamAttributes>
|
#include <QXmlStreamAttributes>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QSslConfiguration>
|
#include <QSslConfiguration>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include "../ifc/exception/vexception.h"
|
#include "../ifc/exception/vexception.h"
|
||||||
#include "../ifc/xml/vabstractconverter.h"
|
#include "../ifc/xml/vabstractconverter.h"
|
||||||
|
@ -51,7 +52,11 @@
|
||||||
#include "fvavailableupdate.h"
|
#include "fvavailableupdate.h"
|
||||||
#include "fvupdatewindow.h"
|
#include "fvupdatewindow.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const QString defaultFeedURL = QStringLiteral("https://valentinaproject.bitbucket.io/Appcast.xml");
|
const QString defaultFeedURL = QStringLiteral("https://valentinaproject.bitbucket.io/Appcast.xml");
|
||||||
|
const QString testFeedURL = QStringLiteral("https://valentinaproject.bitbucket.io/Appcast_testing.xml");
|
||||||
|
}
|
||||||
|
|
||||||
QPointer<FvUpdater> FvUpdater::m_Instance;
|
QPointer<FvUpdater> FvUpdater::m_Instance;
|
||||||
|
|
||||||
|
@ -78,6 +83,52 @@ void FvUpdater::drop()
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString FvUpdater::CurrentFeedURL()
|
||||||
|
{
|
||||||
|
return FvUpdater::IsTestBuild() ? testFeedURL : defaultFeedURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int FvUpdater::CurrentVersion()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
const QString path = QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/VERSION");
|
||||||
|
#else
|
||||||
|
const QString path = QApplication::applicationDirPath() + QDir::separator() + QLatin1String("VERSION");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QFile file(path);
|
||||||
|
if (file.exists())
|
||||||
|
{
|
||||||
|
if (not file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
return APP_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream in(&file);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return VAbstractConverter::GetVersion(in.read(15));
|
||||||
|
}
|
||||||
|
catch(const VException &)
|
||||||
|
{
|
||||||
|
return APP_VERSION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return APP_VERSION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool FvUpdater::IsTestBuild()
|
||||||
|
{
|
||||||
|
const int version = FvUpdater::CurrentVersion();
|
||||||
|
return (version != 0x0 && version != APP_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
FvUpdater::FvUpdater()
|
FvUpdater::FvUpdater()
|
||||||
: QObject(nullptr),
|
: QObject(nullptr),
|
||||||
|
@ -110,7 +161,7 @@ void FvUpdater::showUpdaterWindowUpdatedWithCurrentUpdateProposal()
|
||||||
// Create a new window
|
// Create a new window
|
||||||
m_updaterWindow = new FvUpdateWindow(qApp->getMainWindow());
|
m_updaterWindow = new FvUpdateWindow(qApp->getMainWindow());
|
||||||
m_updaterWindow->UpdateWindowWithCurrentProposedUpdate();
|
m_updaterWindow->UpdateWindowWithCurrentProposedUpdate();
|
||||||
m_updaterWindow->show();
|
m_updaterWindow->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -521,7 +572,7 @@ bool FvUpdater::VersionIsIgnored(const QString &version)
|
||||||
return true; // Ignore invalid version
|
return true; // Ignore invalid version
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decVersion == APP_VERSION)
|
if (decVersion == FvUpdater::CurrentVersion())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -536,7 +587,7 @@ bool FvUpdater::VersionIsIgnored(const QString &version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decVersion > APP_VERSION)
|
if (decVersion > FvUpdater::CurrentVersion())
|
||||||
{
|
{
|
||||||
// Newer version - do not skip
|
// Newer version - do not skip
|
||||||
return false;
|
return false;
|
||||||
|
@ -560,7 +611,7 @@ void FvUpdater::IgnoreVersion(const QString &version)
|
||||||
return ; // Ignore invalid version
|
return ; // Ignore invalid version
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decVersion == APP_VERSION)
|
if (decVersion == FvUpdater::CurrentVersion())
|
||||||
{
|
{
|
||||||
// Don't ignore the current version
|
// Don't ignore the current version
|
||||||
return;
|
return;
|
||||||
|
@ -618,8 +669,7 @@ void FvUpdater::showErrorDialog(const QString &message, bool showEvenInSilentMod
|
||||||
|
|
||||||
QMessageBox dlFailedMsgBox;
|
QMessageBox dlFailedMsgBox;
|
||||||
dlFailedMsgBox.setIcon(QMessageBox::Critical);
|
dlFailedMsgBox.setIcon(QMessageBox::Critical);
|
||||||
dlFailedMsgBox.setText(tr("Error"));
|
dlFailedMsgBox.setText(message);
|
||||||
dlFailedMsgBox.setInformativeText(message);
|
|
||||||
dlFailedMsgBox.exec();
|
dlFailedMsgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,7 +687,6 @@ void FvUpdater::showInformationDialog(const QString &message, bool showEvenInSil
|
||||||
|
|
||||||
QMessageBox dlInformationMsgBox;
|
QMessageBox dlInformationMsgBox;
|
||||||
dlInformationMsgBox.setIcon(QMessageBox::Information);
|
dlInformationMsgBox.setIcon(QMessageBox::Information);
|
||||||
dlInformationMsgBox.setText(tr("Information"));
|
dlInformationMsgBox.setText(message);
|
||||||
dlInformationMsgBox.setInformativeText(message);
|
|
||||||
dlInformationMsgBox.exec();
|
dlInformationMsgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
#include "fvavailableupdate.h"
|
#include "fvavailableupdate.h"
|
||||||
#include "fvupdatewindow.h"
|
#include "fvupdatewindow.h"
|
||||||
|
|
||||||
extern const QString defaultFeedURL;
|
|
||||||
|
|
||||||
class FvUpdater : public QObject
|
class FvUpdater : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -45,6 +43,9 @@ public:
|
||||||
// Singleton
|
// Singleton
|
||||||
static FvUpdater* sharedUpdater();
|
static FvUpdater* sharedUpdater();
|
||||||
static void drop();
|
static void drop();
|
||||||
|
static QString CurrentFeedURL();
|
||||||
|
static int CurrentVersion();
|
||||||
|
static bool IsTestBuild();
|
||||||
|
|
||||||
// Set / get feed URL
|
// Set / get feed URL
|
||||||
void SetFeedURL(const QUrl &feedURL);
|
void SetFeedURL(const QUrl &feedURL);
|
||||||
|
|
|
@ -67,9 +67,18 @@ bool FvUpdateWindow::UpdateWindowWithCurrentProposedUpdate()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString downloadString = m_ui->wouldYouLikeToDownloadLabel->text()
|
QString downloadString;
|
||||||
|
if (FvUpdater::IsTestBuild())
|
||||||
|
{
|
||||||
|
downloadString = QString("New %1 test build is now available. Would you like to download it now?")
|
||||||
|
.arg(QGuiApplication::applicationDisplayName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
downloadString = m_ui->wouldYouLikeToDownloadLabel->text()
|
||||||
.arg(QGuiApplication::applicationDisplayName(), proposedUpdate->GetEnclosureVersion(),
|
.arg(QGuiApplication::applicationDisplayName(), proposedUpdate->GetEnclosureVersion(),
|
||||||
QCoreApplication::applicationVersion());
|
QCoreApplication::applicationVersion());
|
||||||
|
}
|
||||||
m_ui->wouldYouLikeToDownloadLabel->setText(downloadString);
|
m_ui->wouldYouLikeToDownloadLabel->setText(downloadString);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>A new version of %1 is available!</string>
|
<string>%1 update is available!</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -154,7 +154,8 @@ int VAbstractConverter::GetVersion(const QString &version)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractConverter::ValidateVersion(const QString &version)
|
void VAbstractConverter::ValidateVersion(const QString &version)
|
||||||
{
|
{
|
||||||
const QRegularExpression rx(QStringLiteral("^(0|([1-9][0-9]*)).(0|([1-9][0-9]*)).(0|([1-9][0-9]*))$"));
|
const QRegularExpression rx(QStringLiteral("^([0-9]|[1-9][0-9]|[1-2][0-5][0-5]).([0-9]|[1-9][0-9]|[1-2][0-5][0-5])"
|
||||||
|
".([0-9]|[1-9][0-9]|[1-2][0-5][0-5])$"));
|
||||||
|
|
||||||
if (rx.match(version).hasMatch() == false)
|
if (rx.match(version).hasMatch() == false)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user