logic: Moved update check setting to preferences and enable automatic update check by default
This commit is contained in:
@@ -53,9 +53,9 @@
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
#updateCheckbox {
|
#updateButton:disabled {
|
||||||
color: black;
|
color: black;
|
||||||
font-size: 12px;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#licenseHeaderLabel {
|
#licenseHeaderLabel {
|
||||||
|
|||||||
@@ -86,6 +86,7 @@
|
|||||||
<automatic><!-- BOOL: whether to check automatically for new software updates --></automatic>
|
<automatic><!-- BOOL: whether to check automatically for new software updates --></automatic>
|
||||||
<time_stamp><!-- TIME: time of the last update check --></time_stamp>
|
<time_stamp><!-- TIME: time of the last update check --></time_stamp>
|
||||||
<skip_version><!-- VERSION: version to skip for update --></skip_version>
|
<skip_version><!-- VERSION: version to skip for update --></skip_version>
|
||||||
|
<url><!-- STRING: url to new version download --></url>
|
||||||
</update_check>
|
</update_check>
|
||||||
</user>
|
</user>
|
||||||
|
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ void ApplicationSettings::setUserToken(std::string token)
|
|||||||
|
|
||||||
bool ApplicationSettings::getAutomaticUpdateCheck() const
|
bool ApplicationSettings::getAutomaticUpdateCheck() const
|
||||||
{
|
{
|
||||||
return getValue<bool>("user/update_check/automatic", false);
|
return getValue<bool>("user/update_check/automatic", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationSettings::setAutomaticUpdateCheck(bool automaticUpdates)
|
void ApplicationSettings::setAutomaticUpdateCheck(bool automaticUpdates)
|
||||||
@@ -450,6 +450,16 @@ void ApplicationSettings::setSkipUpdateForVersion(const Version& version)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ApplicationSettings::getUpdateDownloadUrl() const
|
||||||
|
{
|
||||||
|
return getValue<std::string>("user/update_check/url", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationSettings::setUpdateDownloadUrl(const std::string& url)
|
||||||
|
{
|
||||||
|
setValue<std::string>("user/update_check/url", url);
|
||||||
|
}
|
||||||
|
|
||||||
int ApplicationSettings::getPluginPort() const
|
int ApplicationSettings::getPluginPort() const
|
||||||
{
|
{
|
||||||
return getValue<int>("network/plugin_port", 6666);
|
return getValue<int>("network/plugin_port", 6666);
|
||||||
|
|||||||
@@ -132,6 +132,9 @@ public:
|
|||||||
Version getSkipUpdateForVersion() const;
|
Version getSkipUpdateForVersion() const;
|
||||||
void setSkipUpdateForVersion(const Version& version);
|
void setSkipUpdateForVersion(const Version& version);
|
||||||
|
|
||||||
|
std::string getUpdateDownloadUrl() const;
|
||||||
|
void setUpdateDownloadUrl(const std::string& url);
|
||||||
|
|
||||||
// network
|
// network
|
||||||
int getPluginPort() const;
|
int getPluginPort() const;
|
||||||
void setPluginPort(const int pluginPort);
|
void setPluginPort(const int pluginPort);
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ add_files(
|
|||||||
qt/element/QtTooltip.h
|
qt/element/QtTooltip.h
|
||||||
qt/element/QtUndoRedo.cpp
|
qt/element/QtUndoRedo.cpp
|
||||||
qt/element/QtUndoRedo.h
|
qt/element/QtUndoRedo.h
|
||||||
|
qt/element/QtUpdateCheckerWidget.cpp
|
||||||
|
qt/element/QtUpdateCheckerWidget.h
|
||||||
|
|
||||||
qt/graphics/QtCountCircleItem.cpp
|
qt/graphics/QtCountCircleItem.cpp
|
||||||
qt/graphics/QtCountCircleItem.h
|
qt/graphics/QtCountCircleItem.h
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
#include "qt/element/QtUpdateCheckerWidget.h"
|
||||||
|
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "qt/network/QtUpdateChecker.h"
|
||||||
|
#include "settings/ApplicationSettings.h"
|
||||||
|
#include "utility/TimeStamp.h"
|
||||||
|
|
||||||
|
QtUpdateCheckerWidget::QtUpdateCheckerWidget(QWidget* parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||||
|
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
|
||||||
|
m_button = new QPushButton("check for new version");
|
||||||
|
m_button->setObjectName("updateButton");
|
||||||
|
m_button->setCursor(Qt::PointingHandCursor);
|
||||||
|
layout->addWidget(m_button);
|
||||||
|
|
||||||
|
if (appSettings->getAutomaticUpdateCheck())
|
||||||
|
{
|
||||||
|
if (QtUpdateChecker::needsAutomaticCheck())
|
||||||
|
{
|
||||||
|
checkUpdate(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString url = QString::fromStdString(appSettings->getUpdateDownloadUrl());
|
||||||
|
if (!url.isEmpty())
|
||||||
|
{
|
||||||
|
setDownloadUrl(url);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_button->setText("up-to-date");
|
||||||
|
m_button->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connect(m_button, &QPushButton::clicked, [this](){ checkUpdate(true); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtUpdateCheckerWidget::checkUpdate(bool force)
|
||||||
|
{
|
||||||
|
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||||
|
appSettings->setUpdateDownloadUrl("");
|
||||||
|
appSettings->save();
|
||||||
|
|
||||||
|
m_button->setText("checking for update...");
|
||||||
|
m_button->setEnabled(false);
|
||||||
|
|
||||||
|
QtUpdateChecker::check(force,
|
||||||
|
[this, appSettings](QtUpdateChecker::Result result)
|
||||||
|
{
|
||||||
|
if (!result.success)
|
||||||
|
{
|
||||||
|
m_button->setText("update check failed");
|
||||||
|
}
|
||||||
|
else if (result.url.isEmpty())
|
||||||
|
{
|
||||||
|
m_button->setText("up-to-date");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setDownloadUrl(result.url);
|
||||||
|
|
||||||
|
appSettings->setUpdateDownloadUrl(result.url.toStdString());
|
||||||
|
appSettings->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtUpdateCheckerWidget::setDownloadUrl(QString url)
|
||||||
|
{
|
||||||
|
m_button->setText("new version available");
|
||||||
|
m_button->disconnect();
|
||||||
|
connect(m_button, &QPushButton::clicked, this,
|
||||||
|
[url]()
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
m_button->setEnabled(true);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef QT_UPDATE_CHECKER_WIDGET_H
|
||||||
|
#define QT_UPDATE_CHECKER_WIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
|
class QtUpdateCheckerWidget
|
||||||
|
: public QWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QtUpdateCheckerWidget(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void checkUpdate(bool force);
|
||||||
|
void setDownloadUrl(QString url);
|
||||||
|
|
||||||
|
QPushButton* m_button;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_UPDATE_CHECKER_WIDGET_H
|
||||||
@@ -14,15 +14,23 @@
|
|||||||
#include "utility/utilityApp.h"
|
#include "utility/utilityApp.h"
|
||||||
#include "utility/utilityUuid.h"
|
#include "utility/utilityUuid.h"
|
||||||
|
|
||||||
void QtUpdateChecker::check(bool force)
|
bool QtUpdateChecker::needsAutomaticCheck()
|
||||||
{
|
{
|
||||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||||
|
return TimeStamp::now().deltaHours(appSettings->getLastUpdateCheck()) >= 24;
|
||||||
|
}
|
||||||
|
|
||||||
if (!force && TimeStamp::now().deltaHours(appSettings->getLastUpdateCheck()) < 24)
|
void QtUpdateChecker::check(bool force, std::function<void(Result)> callback)
|
||||||
|
{
|
||||||
|
Result result;
|
||||||
|
|
||||||
|
if (!force && !needsAutomaticCheck())
|
||||||
{
|
{
|
||||||
|
callback(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||||
appSettings->setLastUpdateCheck(TimeStamp::now());
|
appSettings->setLastUpdateCheck(TimeStamp::now());
|
||||||
appSettings->save();
|
appSettings->save();
|
||||||
|
|
||||||
@@ -43,6 +51,7 @@ void QtUpdateChecker::check(bool force)
|
|||||||
osString = "linux";
|
osString = "linux";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
callback(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +99,10 @@ void QtUpdateChecker::check(bool force)
|
|||||||
// send request
|
// send request
|
||||||
QtRequest* request = new QtRequest();
|
QtRequest* request = new QtRequest();
|
||||||
QObject::connect(request, &QtRequest::receivedData,
|
QObject::connect(request, &QtRequest::receivedData,
|
||||||
[force, request](QByteArray bytes)
|
[force, callback, request](QByteArray bytes)
|
||||||
{
|
{
|
||||||
|
Result result;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(bytes);
|
QJsonDocument doc = QJsonDocument::fromJson(bytes);
|
||||||
@@ -111,14 +122,18 @@ void QtUpdateChecker::check(bool force)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
result.success = true;
|
||||||
if (!force && appSettings->getSkipUpdateForVersion() == updateVersion)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateVersion > Version::getApplicationVersion())
|
if (updateVersion > Version::getApplicationVersion())
|
||||||
{
|
{
|
||||||
|
result.url = url;
|
||||||
|
|
||||||
|
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||||
|
if (!force && appSettings->getSkipUpdateForVersion() == updateVersion)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setText("Update Check");
|
msgBox.setText("Update Check");
|
||||||
msgBox.setInformativeText(
|
msgBox.setInformativeText(
|
||||||
@@ -154,6 +169,8 @@ void QtUpdateChecker::check(bool force)
|
|||||||
while (false);
|
while (false);
|
||||||
|
|
||||||
request->deleteLater();
|
request->deleteLater();
|
||||||
|
|
||||||
|
callback(result);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -165,7 +182,7 @@ void QtUpdateChecker::checkUpdate()
|
|||||||
m_onQtThread(
|
m_onQtThread(
|
||||||
[this]()
|
[this]()
|
||||||
{
|
{
|
||||||
check();
|
check(false, [](Result){});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,14 @@ class QtUpdateChecker
|
|||||||
: public UpdateChecker
|
: public UpdateChecker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void check(bool force = false);
|
struct Result
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
QString url;
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool needsAutomaticCheck();
|
||||||
|
static void check(bool force, std::function<void(Result)> callback);
|
||||||
|
|
||||||
virtual void checkUpdate() override;
|
virtual void checkUpdate() override;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "License.h"
|
#include "License.h"
|
||||||
#include "PublicKey.h"
|
#include "PublicKey.h"
|
||||||
#include "qt/network/QtUpdateChecker.h"
|
#include "qt/element/QtUpdateCheckerWidget.h"
|
||||||
#include "qt/utility/utilityQt.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
#include "settings/ApplicationSettings.h"
|
#include "settings/ApplicationSettings.h"
|
||||||
#include "settings/ProjectSettings.h"
|
#include "settings/ProjectSettings.h"
|
||||||
@@ -163,33 +163,8 @@ void QtStartScreen::setupStartScreen()
|
|||||||
versionLabel->setObjectName("versionLabel");
|
versionLabel->setObjectName("versionLabel");
|
||||||
col->addWidget(versionLabel);
|
col->addWidget(versionLabel);
|
||||||
|
|
||||||
QPushButton* updateButton = new QPushButton("check for new version", this);
|
QtUpdateCheckerWidget* checker = new QtUpdateCheckerWidget(this);
|
||||||
updateButton->setObjectName("updateButton");
|
col->addWidget(checker);
|
||||||
updateButton->setCursor(Qt::PointingHandCursor);
|
|
||||||
connect(updateButton, &QPushButton::clicked,
|
|
||||||
[]()
|
|
||||||
{
|
|
||||||
QtUpdateChecker::check(true);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
col->addWidget(updateButton);
|
|
||||||
|
|
||||||
QCheckBox* updateCheckbox = new QCheckBox("automatic update check");
|
|
||||||
updateCheckbox->setObjectName("updateCheckbox");
|
|
||||||
updateCheckbox->setChecked(ApplicationSettings::getInstance()->getAutomaticUpdateCheck());
|
|
||||||
connect(updateCheckbox, &QCheckBox::stateChanged,
|
|
||||||
[updateCheckbox]()
|
|
||||||
{
|
|
||||||
ApplicationSettings::getInstance()->setAutomaticUpdateCheck(updateCheckbox->isChecked());
|
|
||||||
ApplicationSettings::getInstance()->save();
|
|
||||||
|
|
||||||
if (updateCheckbox->isChecked())
|
|
||||||
{
|
|
||||||
QtUpdateChecker::check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
col->addWidget(updateCheckbox);
|
|
||||||
|
|
||||||
if (!licenseValid)
|
if (!licenseValid)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -91,13 +91,33 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
|
|||||||
QString modifierName =utility::getOsType() == OS_MAC ? "Cmd" : "Ctrl";
|
QString modifierName =utility::getOsType() == OS_MAC ? "Cmd" : "Ctrl";
|
||||||
m_graphZooming = addCheckBox(
|
m_graphZooming = addCheckBox(
|
||||||
"Graph Zoom",
|
"Graph Zoom",
|
||||||
"Zoom on mouse wheel",
|
"Zoom graph on mouse wheel",
|
||||||
"<p>Enable graph zoom using mouse wheel only, instead of using " + modifierName + " + Mouse Wheel.</p>",
|
"<p>Enable graph zoom using mouse wheel only, instead of using " + modifierName + " + Mouse Wheel.</p>",
|
||||||
layout, row
|
layout, row
|
||||||
);
|
);
|
||||||
|
|
||||||
addGap(layout, row);
|
addGap(layout, row);
|
||||||
|
|
||||||
|
// Network
|
||||||
|
addTitle("NETWORK", layout, row);
|
||||||
|
|
||||||
|
// Update check
|
||||||
|
m_automaticUpdateCheck = addCheckBox("Automatic<br />Update Check", "Check automatically for updates",
|
||||||
|
"<p>Check automatically for a new releases once a day.</p>", layout, row);
|
||||||
|
addGap(layout, row);
|
||||||
|
|
||||||
|
// Plugins
|
||||||
|
addTitle("PLUGIN", layout, row);
|
||||||
|
|
||||||
|
// Sourcetrail port
|
||||||
|
m_sourcetrailPort = addLineEdit("Sourcetrail Port",
|
||||||
|
"<p>Port number that Sourcetrail uses to listen for incoming messages from plugins.</p>", layout, row);
|
||||||
|
|
||||||
|
// Sourcetrail port
|
||||||
|
m_pluginPort = addLineEdit("Plugin Port", "<p>Port number that Sourcetrail uses to sends outgoing messages to plugins.</p>", layout, row);
|
||||||
|
|
||||||
|
addGap(layout, row);
|
||||||
|
|
||||||
// indexing
|
// indexing
|
||||||
addTitle("INDEXING", layout, row);
|
addTitle("INDEXING", layout, row);
|
||||||
|
|
||||||
@@ -140,18 +160,6 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
|
|||||||
addGap(layout, row);
|
addGap(layout, row);
|
||||||
|
|
||||||
|
|
||||||
// Plugins
|
|
||||||
addTitle("PLUGIN", layout, row);
|
|
||||||
|
|
||||||
// Sourcetrail port
|
|
||||||
m_sourcetrailPort = addLineEdit("Sourcetrail Port",
|
|
||||||
"<p>Port number that Sourcetrail uses to listen for incoming messages from plugins.</p>", layout, row);
|
|
||||||
|
|
||||||
// Sourcetrail port
|
|
||||||
m_pluginPort = addLineEdit("Plugin Port", "<p>Port number that Sourcetrail uses to sends outgoing messages to plugins.</p>", layout, row);
|
|
||||||
|
|
||||||
addGap(layout, row);
|
|
||||||
|
|
||||||
// Java
|
// Java
|
||||||
addTitle("JAVA", layout, row);
|
addTitle("JAVA", layout, row);
|
||||||
|
|
||||||
@@ -301,6 +309,8 @@ void QtProjectWizzardContentPreferences::load()
|
|||||||
m_scrollSpeed->setText(QString::number(appSettings->getScrollSpeed(), 'f', 1));
|
m_scrollSpeed->setText(QString::number(appSettings->getScrollSpeed(), 'f', 1));
|
||||||
m_graphZooming->setChecked(appSettings->getControlsGraphZoomOnMouseWheel());
|
m_graphZooming->setChecked(appSettings->getControlsGraphZoomOnMouseWheel());
|
||||||
|
|
||||||
|
m_automaticUpdateCheck->setChecked(appSettings->getAutomaticUpdateCheck());
|
||||||
|
|
||||||
m_sourcetrailPort->setText(QString::number(appSettings->getSourcetrailPort()));
|
m_sourcetrailPort->setText(QString::number(appSettings->getSourcetrailPort()));
|
||||||
m_pluginPort->setText(QString::number(appSettings->getPluginPort()));
|
m_pluginPort->setText(QString::number(appSettings->getPluginPort()));
|
||||||
|
|
||||||
@@ -345,6 +355,8 @@ void QtProjectWizzardContentPreferences::save()
|
|||||||
|
|
||||||
appSettings->setControlsGraphZoomOnMouseWheel(m_graphZooming->isChecked());
|
appSettings->setControlsGraphZoomOnMouseWheel(m_graphZooming->isChecked());
|
||||||
|
|
||||||
|
appSettings->setAutomaticUpdateCheck(m_automaticUpdateCheck->isChecked());
|
||||||
|
|
||||||
int sourcetrailPort = m_sourcetrailPort->text().toInt();
|
int sourcetrailPort = m_sourcetrailPort->text().toInt();
|
||||||
if (sourcetrailPort) appSettings->setSourcetrailPort(sourcetrailPort);
|
if (sourcetrailPort) appSettings->setSourcetrailPort(sourcetrailPort);
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ private:
|
|||||||
QLineEdit* m_scrollSpeed;
|
QLineEdit* m_scrollSpeed;
|
||||||
QCheckBox* m_graphZooming;
|
QCheckBox* m_graphZooming;
|
||||||
|
|
||||||
|
QCheckBox* m_automaticUpdateCheck;
|
||||||
|
|
||||||
QLineEdit* m_sourcetrailPort;
|
QLineEdit* m_sourcetrailPort;
|
||||||
QLineEdit* m_pluginPort;
|
QLineEdit* m_pluginPort;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user