summaryrefslogtreecommitdiffhomepage
path: root/opentrack/software-update-dialog.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-05-23 20:56:40 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-05-27 19:35:45 +0200
commitc7878efb1039f70d3041ac2404d5e299a81fcfec (patch)
tree59d7195219f5eb3b0e195c0f54dcd7c616147efd /opentrack/software-update-dialog.hpp
parent75044583226009200159f72cb5100f5a7d65e877 (diff)
trackhat: add updater
Diffstat (limited to 'opentrack/software-update-dialog.hpp')
-rw-r--r--opentrack/software-update-dialog.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/opentrack/software-update-dialog.hpp b/opentrack/software-update-dialog.hpp
new file mode 100644
index 00000000..1e150e62
--- /dev/null
+++ b/opentrack/software-update-dialog.hpp
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <QtNetwork>
+#include <QDialog>
+#include <QTimer>
+#include "ui_software-update.h"
+
+extern "C" const char* const opentrack_version;
+
+class update_query final : public QObject
+{
+ Q_OBJECT
+public:
+ explicit update_query(QWidget* parent) : QObject{parent} {}
+
+ QNetworkReply* r = nullptr;
+ QNetworkAccessManager qnam{this};
+ QByteArray buf;
+ QTimer t{this};
+
+ void on_finished();
+ void on_ready() { buf.append(r->readAll()); }
+ void maybe_show_dialog();
+};
+
+class update_dialog : QDialog
+{
+ Q_OBJECT
+ friend class update_query;
+private:
+ Ui::UpdateDialog ui;
+ update_query& q;
+ update_dialog(QWidget* parent, update_query& q, const QString& new_version);
+};