summaryrefslogtreecommitdiffhomepage
path: root/opentrack/software-update-dialog.hpp
blob: 1e150e623c1cd66bfa976db34f91cf39a0b685d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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);
};