Pumpkin mod.

To provide a better quality service we restrict the lifetime a user can use a
test build.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-08-23 08:17:26 +03:00
parent c63a1af61d
commit a9a09d85c3
4 changed files with 42 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#include "tmainwindow.h"
#include "mapplication.h"
#include "../fervor/fvupdater.h"
#include "../vmisc/vsysexits.h"
#include <QMessageBox> // For QT_REQUIRE_VERSION
#include <QTimer>
@ -55,6 +56,17 @@ int main(int argc, char *argv[])
MApplication app(argc, argv);
app.InitOptions();
if (FvUpdater::IsStaledTestBuild())
{
qWarning() << QApplication::translate("Tape",
"This test build is older than %1 days. To provide you with better "
"quality service we restrict the lifetime you can use a test build. "
"To continue using Tape please update to newer test build. The "
"application will be shut down.")
.arg(FvUpdater::testBuildLifetime);
return V_EX_UNAVAILABLE;
}
QTimer::singleShot(0, &app, &MApplication::ProcessCMD);
return app.exec();

View File

@ -66,6 +66,17 @@ int main(int argc, char *argv[])
app.InitOptions();
if (FvUpdater::IsStaledTestBuild())
{
qWarning() << QApplication::translate("Valentina",
"This test build is older than %1 days. To provide you with better "
"quality service we restrict the lifetime you can use a test build. "
"To continue using Valentina please update to newer test build. The "
"application will be shut down.")
.arg(FvUpdater::testBuildLifetime);
return V_EX_UNAVAILABLE;
}
if (VApplication::IsGUIMode())
{
// Set feed URL before doing anything else

View File

@ -53,6 +53,8 @@
#include "fvavailableupdate.h"
#include "fvupdatewindow.h"
const int FvUpdater::testBuildLifetime = 90;
namespace
{
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defaultFeedURL,
@ -132,6 +134,20 @@ bool FvUpdater::IsTestBuild()
return (version != 0x0 && version != APP_VERSION);
}
//---------------------------------------------------------------------------------------------------------------------
bool FvUpdater::IsStaledTestBuild()
{
if (IsTestBuild())
{
QDate builtDate = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), QStringLiteral("MMM d yyyy"));
return builtDate.daysTo(QDate::currentDate()) > testBuildLifetime;
}
else
{
return false;
}
}
//---------------------------------------------------------------------------------------------------------------------
FvUpdater::FvUpdater()
: QObject(nullptr),

View File

@ -46,6 +46,7 @@ public:
static QString CurrentFeedURL();
static int CurrentVersion();
static bool IsTestBuild();
static bool IsStaledTestBuild();
// Set / get feed URL
void SetFeedURL(const QUrl &feedURL);
@ -55,6 +56,8 @@ public:
bool IsDropOnFinnish() const;
void SetDropOnFinnish(bool value);
static const int testBuildLifetime;
public slots:
// Check for updates
bool CheckForUpdates(bool silentAsMuchAsItCouldGet = true);