From 9fc1bc3e1d5b475d23270b89301baaec149a10e8 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 10 Mar 2019 16:37:03 +1100 Subject: [PATCH] check for updates --- olive.pro | 8 ++++++-- oliveglobal.cpp | 5 +++++ ui/icons.cpp | 3 +++ ui/icons.h | 14 ++++++++++++++ ui/updatenotification.cpp | 38 ++++++++++++++++++++++++++++++++++++++ ui/updatenotification.h | 19 +++++++++++++++++++ 6 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 ui/icons.cpp create mode 100644 ui/icons.h create mode 100644 ui/updatenotification.cpp create mode 100644 ui/updatenotification.h diff --git a/olive.pro b/olive.pro index f31ec75ab..5f844a844 100644 --- a/olive.pro +++ b/olive.pro @@ -160,7 +160,9 @@ SOURCES += \ rendering/clipqueue.cpp \ rendering/audio.cpp \ dialogs/clippropertiesdialog.cpp \ - rendering/framebufferobject.cpp + rendering/framebufferobject.cpp \ + ui/updatenotification.cpp \ + ui/icons.cpp HEADERS += \ mainwindow.h \ @@ -272,7 +274,9 @@ HEADERS += \ rendering/cacher.h \ rendering/audio.h \ dialogs/clippropertiesdialog.h \ - rendering/framebufferobject.h + rendering/framebufferobject.h \ + ui/updatenotification.h \ + ui/icons.h FORMS += diff --git a/oliveglobal.cpp b/oliveglobal.cpp index e9242dfcf..edfa000dc 100644 --- a/oliveglobal.cpp +++ b/oliveglobal.cpp @@ -41,6 +41,8 @@ #include "project/sequence.h" +#include "ui/updatenotification.h" + #include #include #include @@ -263,6 +265,9 @@ void OliveGlobal::finished_initialize() { d->open(); #endif } + + // Check for updates + olive::update_notifier.check(); } void OliveGlobal::save_autorecovery_file() { diff --git a/ui/icons.cpp b/ui/icons.cpp new file mode 100644 index 000000000..20ed17955 --- /dev/null +++ b/ui/icons.cpp @@ -0,0 +1,3 @@ +#include "icons.h" + + diff --git a/ui/icons.h b/ui/icons.h new file mode 100644 index 000000000..7dbc1b62b --- /dev/null +++ b/ui/icons.h @@ -0,0 +1,14 @@ +#ifndef ICONS_H +#define ICONS_H + +#include + +namespace olive { + namespace icon { + extern QIcon KeyframeLeft; + extern QIcon KeyframeSet; + extern QIcon KeyframeRight; + } +} + +#endif // ICONS_H diff --git a/ui/updatenotification.cpp b/ui/updatenotification.cpp new file mode 100644 index 000000000..38d2a8f2d --- /dev/null +++ b/ui/updatenotification.cpp @@ -0,0 +1,38 @@ +#include "updatenotification.h" + +#include +#include + +#include "mainwindow.h" + +UpdateNotification olive::update_notifier; + +UpdateNotification::UpdateNotification() +{ + +} + +void UpdateNotification::check() +{ +#if defined(_WIN32) || defined(__APPLE__) + QNetworkAccessManager* manager = new QNetworkAccessManager(); + + connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(finished_slot(QNetworkReply *))); + connect(manager, SIGNAL(finished(QNetworkReply *)), manager, SLOT(deleteLater())); + + QString update_url = QString("http://olivevideoeditor.org/update.php?version=0&hash=%1"); + + QNetworkRequest request(QUrl(update_url.arg(GITHASH))); + manager->get(request); +#endif +} + +void UpdateNotification::finished_slot(QNetworkReply *reply) +{ + QString response = QString::fromUtf8(reply->readAll()); + + if (response == "1") { + olive::MainWindow->statusBar()->showMessage(tr("An update is available from the Olive website. " + "Visit www.olivevideoeditor.org to download it.")); + } +} diff --git a/ui/updatenotification.h b/ui/updatenotification.h new file mode 100644 index 000000000..8a8f87e78 --- /dev/null +++ b/ui/updatenotification.h @@ -0,0 +1,19 @@ +#ifndef UPDATENOTIFICATION_H +#define UPDATENOTIFICATION_H + +#include + +class UpdateNotification : public QObject { + Q_OBJECT +public: + UpdateNotification(); + void check(); +private slots: + void finished_slot(QNetworkReply*); +}; + +namespace olive { + extern UpdateNotification update_notifier; +} + +#endif // UPDATENOTIFICATION_H