ui: Added "Skip this Version" option to update dialog

This commit is contained in:
Eberhard Graether
2017-09-05 23:26:34 +02:00
parent 48f5180605
commit fc87d2e1aa
6 changed files with 96 additions and 57 deletions
@@ -6,6 +6,7 @@
<!-- STRING: string e.g hello -->
<!-- UUID: string e.g. 00000000-0000-0000-0000-000000000000 -->
<!-- TIME: string in format "%Y-%m-%d %H:%M:%S" -->
<!-- VERSION: string in format "yyyy.x.z" -->
<config>
<version><!-- INTEGER: Version number --></version>
@@ -84,6 +85,7 @@
<update_check>
<automatic><!-- BOOL: whether to check automatically for new software updates --></automatic>
<time_stamp><!-- TIME: time of the last update check --></time_stamp>
<skip_version><!-- VERSION: version to skip for update --></skip_version>
</update_check>
</user>
+14
View File
@@ -7,6 +7,7 @@
#include "utility/TimeStamp.h"
#include "utility/utility.h"
#include "utility/UserPaths.h"
#include "utility/Version.h"
const size_t ApplicationSettings::VERSION = 2;
@@ -436,6 +437,19 @@ void ApplicationSettings::setLastUpdateCheck(const TimeStamp& time)
setValue<std::string>("user/update_check/last", time.toString());
}
Version ApplicationSettings::getSkipUpdateForVersion() const
{
return Version::fromString(getValue<std::string>("user/update_check/skip_version", "2017.1.0"));
}
void ApplicationSettings::setSkipUpdateForVersion(const Version& version)
{
if (version.isValid())
{
setValue<std::string>("user/update_check/skip_version", version.toDisplayString());
}
}
int ApplicationSettings::getPluginPort() const
{
return getValue<int>("network/plugin_port", 6666);
+4
View File
@@ -6,6 +6,7 @@
#include "settings/Settings.h"
class TimeStamp;
class Version;
class ApplicationSettings
: public Settings
@@ -128,6 +129,9 @@ public:
TimeStamp getLastUpdateCheck() const;
void setLastUpdateCheck(const TimeStamp& time);
Version getSkipUpdateForVersion() const;
void setSkipUpdateForVersion(const Version& version);
// network
int getPluginPort() const;
void setPluginPort(const int pluginPort);
+15 -1
View File
@@ -111,6 +111,12 @@ void QtUpdateChecker::check(bool force)
break;
}
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
if (!force && appSettings->getSkipUpdateForVersion() == updateVersion)
{
break;
}
if (updateVersion > Version::getApplicationVersion())
{
QMessageBox msgBox;
@@ -118,10 +124,18 @@ void QtUpdateChecker::check(bool force)
msgBox.setInformativeText(
"Sourcetrial " + version + " is available for download: <a href=\"" + url + "\">" + url + "</a>");
msgBox.addButton("Close", QMessageBox::ButtonRole::NoRole);
msgBox.addButton("Skip this Version", QMessageBox::ButtonRole::NoRole);
QPushButton* but = msgBox.addButton("Download", QMessageBox::ButtonRole::YesRole);
msgBox.setDefaultButton(but);
if (msgBox.exec() == 1)
int val = msgBox.exec();
if (val == 1)
{
appSettings->setSkipUpdateForVersion(updateVersion);
appSettings->save();
}
else if (val == 2)
{
QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
}
+59 -54
View File
@@ -67,6 +67,60 @@ Version Version::fromString(const std::string& versionString)
return Version();
}
void Version::setApplicationVersion(const Version& version)
{
s_version = version;
}
const Version& Version::getApplicationVersion()
{
return s_version;
}
Version::Version(int year, int minor, int commit, const std::string& hash)
: m_year(year)
, m_minorNumber(minor)
, m_commitNumber(commit)
, m_commitHash(hash)
{
}
bool Version::isEmpty() const
{
return m_year == 0 && m_minorNumber == 0 && m_commitNumber == 0;
}
bool Version::isValid() const
{
if (m_minorNumber < 5 && m_minorNumber > 0
&& m_year > 2016)
{
return true;
}
return false;
}
std::string Version::toShortString() const
{
std::stringstream ss;
ss << m_year << '.' << m_minorNumber;
return ss.str();
}
std::string Version::toString() const
{
std::stringstream ss;
ss << m_year << '.' << m_minorNumber << '-' << m_commitNumber << '-' << m_commitHash;
return ss.str();
}
std::string Version::toDisplayString() const
{
std::stringstream ss;
ss << m_year << '.' << m_minorNumber << '.' << m_commitNumber;
return ss.str();
}
bool Version::operator<(const Version& other) const
{
if (m_year != other.m_year)
@@ -99,6 +153,11 @@ bool Version::operator>(const Version& other) const
}
}
bool Version::operator==(const Version& other) const
{
return m_year == other.m_year && m_minorNumber == other.m_minorNumber && m_commitNumber == other.m_commitNumber;
}
Version& Version::operator+=(const int& number)
{
int minor = this->m_minorNumber - 1 + number;
@@ -106,57 +165,3 @@ Version& Version::operator+=(const int& number)
this->m_minorNumber = (minor%4) + 1;
return *this;
}
bool Version::isValid()
{
if (m_minorNumber < 5 && m_minorNumber > 0
&& m_year > 2016)
{
return true;
}
return false;
}
void Version::setApplicationVersion(const Version& version)
{
s_version = version;
}
const Version& Version::getApplicationVersion()
{
return s_version;
}
Version::Version(int year, int minor, int commit, const std::string& hash)
: m_year(year)
, m_minorNumber(minor)
, m_commitNumber(commit)
, m_commitHash(hash)
{
}
bool Version::isEmpty() const
{
return m_year == 0 && m_minorNumber == 0 && m_commitNumber == 0;
}
std::string Version::toShortString() const
{
std::stringstream ss;
ss << m_year << '.' << m_minorNumber;
return ss.str();
}
std::string Version::toString() const
{
std::stringstream ss;
ss << m_year << '.' << m_minorNumber << '-' << m_commitNumber << '-' << m_commitHash;
return ss.str();
}
std::string Version::toDisplayString() const
{
std::stringstream ss;
ss << m_year << '.' << m_minorNumber << '.' << m_commitNumber;
return ss.str();
}
+2 -2
View File
@@ -7,7 +7,6 @@ class Version
{
public:
static Version fromString(const std::string& versionString);
static Version fromShortString(const std::string& versionString);
static void setApplicationVersion(const Version& version);
static const Version& getApplicationVersion();
@@ -15,6 +14,7 @@ public:
Version(int year = 0, int minor = 0, int commit = 0, const std::string& hash = "");
bool isEmpty() const;
bool isValid() const;
std::string toString() const;
std::string toShortString() const;
@@ -22,8 +22,8 @@ public:
bool operator<(const Version& other) const;
bool operator>(const Version& other) const;
bool operator==(const Version& other) const;
Version& operator+=(const int& number);
bool isValid();
private:
static Version s_version;