logic: Added update checker connecting to online API

* connects to https://www.sourcetrail.com/api/v1/versions/latest
* sends information about OS, platform, license type, current version and a unique user token
* Automatic update check is enabled via Startscreen and performed once every 24 hours on window focus
* Update check can be forced by clicking on "check for new version" on start screen
* renamed TimePoint to TimeStamp

fortune cookie message = In Träumen und im Leben ist nichts unmöglich.
This commit is contained in:
Eberhard Graether
2017-08-08 14:18:14 +02:00
parent db1c3b3f40
commit ff65a3f285
67 changed files with 680 additions and 251 deletions
+12 -9
View File
@@ -17,6 +17,7 @@
#include "component/view/View.h"
#include "data/bookmark/Bookmark.h"
#include "LicenseChecker.h"
#include "qt/network/QtUpdateChecker.h"
#include "qt/utility/QtContextMenu.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
@@ -51,6 +52,7 @@
#include "utility/UserPaths.h"
#include "utility/utilityString.h"
QtViewToggle::QtViewToggle(View* view, QWidget *parent)
: QWidget(parent)
, m_view(view)
@@ -104,7 +106,7 @@ QtMainWindow::QtMainWindow()
, m_showDockWidgetTitleBars(true)
, m_windowStack(this)
{
setObjectName("QtMainWindow");
setObjectName("QtMainWindow");
setCentralWidget(nullptr);
setDockNestingEnabled(true);
@@ -112,13 +114,13 @@ QtMainWindow::QtMainWindow()
setWindowFlags(Qt::Widget);
#ifdef __linux__
if (std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr)
{
QMessageBox::warning(this, "Run Sourcetrail via Script", "Please run Sourcetrail via Sourcetrail.sh");
}
if (std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr)
{
QMessageBox::warning(this, "Run Sourcetrail via Script", "Please run Sourcetrail via Sourcetrail.sh");
}
#endif
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
app->installEventFilter(new MouseReleaseFilter(this));
app->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("main.css"))).c_str());
@@ -358,6 +360,7 @@ void QtMainWindow::keyPressEvent(QKeyEvent* event)
break;
case Qt::Key_Space:
QtUpdateChecker::check();
PRINT_TRACES();
break;
}
@@ -376,13 +379,13 @@ void QtMainWindow::closeEvent(QCloseEvent* event)
{
log->setEnabled(false);
}
MessageWindowClosed().dispatch();
MessageWindowClosed().dispatch();
}
void QtMainWindow::resizeEvent(QResizeEvent *event)
{
m_windowStack.centerSubWindows();
QMainWindow::resizeEvent(event);
m_windowStack.centerSubWindows();
QMainWindow::resizeEvent(event);
}
void QtMainWindow::about()
+43 -18
View File
@@ -1,21 +1,23 @@
#include "qt/window/QtStartScreen.h"
#include <QCheckBox>
#include <QLabel>
#include <QString>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QMessageBox>
#include "settings/ApplicationSettings.h"
#include "settings/ProjectSettings.h"
#include "utility/AppPath.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/ResourcePaths.h"
#include "qt/utility/utilityQt.h"
#include "utility/Version.h"
#include "License.h"
#include "PublicKey.h"
#include "utility/AppPath.h"
#include "qt/network/QtUpdateChecker.h"
#include "qt/utility/utilityQt.h"
#include "settings/ApplicationSettings.h"
#include "settings/ProjectSettings.h"
QtRecentProjectButton::QtRecentProjectButton(QWidget* parent)
: QPushButton(parent)
@@ -158,12 +160,44 @@ void QtStartScreen::setupStartScreen()
QVBoxLayout* col = new QVBoxLayout();
layout->addLayout(col, 2);
QLabel* versionLabel = new QLabel(("Version " + Version::getApplicationVersion().toDisplayString()).c_str(), this);
versionLabel->setObjectName("versionLabel");
col->addWidget(versionLabel);
QPushButton* updateButton = new QPushButton("check for new version", this);
updateButton->setObjectName("updateButton");
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)
{
col->addSpacing(4);
col->addSpacing(20);
QLabel* welcomeLabel = new QLabel(
"Welcome to the trial version of <b>Sourcetrail</b>!<br /><br />"
"<b>Welcome to the trial version of Sourcetrail!</b><br />"
"Explore our preindexed projects to experience Sourcetrail's unique user interface. "
"More projects are available for download <a href=\"http://sourcetrail.com/downloads#extra\" style=\"color: #007AC2;\">here</a>.<br /><br />"
"If you want to use Sourcetrail on your own source code please "
@@ -175,6 +209,7 @@ void QtStartScreen::setupStartScreen()
welcomeLabel->setAlignment(Qt::AlignTop);
col->addWidget(welcomeLabel, 0, Qt::AlignHCenter | Qt::AlignTop);
col->addStrut(260);
col->addStretch();
QPushButton* openProjectButton = new QPushButton("Open Project", this);
@@ -201,17 +236,7 @@ void QtStartScreen::setupStartScreen()
}
else
{
QLabel* versionLabel = new QLabel(("Version " + Version::getApplicationVersion().toDisplayString()).c_str(), this);
versionLabel->setObjectName("versionLabel");
col->addWidget(versionLabel);
QLabel* updateLabel = new QLabel(
"<a href=\"https://sourcetrail.com/downloads\" style=\"color: #007AC2;\">check for new version</a>", this);
updateLabel->setOpenExternalLinks(true);
updateLabel->setObjectName("updateLabel");
col->addWidget(updateLabel);
col->addSpacing(20);
col->addSpacing(30);
std::string licenseString = license.getLicenseInfo();