-
Notifications
You must be signed in to change notification settings - Fork 13
/
updatechecker.h
47 lines (37 loc) · 1.01 KB
/
updatechecker.h
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
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef UPDATECHECKER_H
#define UPDATECHECKER_H
#include <QObject>
#include <QNetworkAccessManager>
#ifdef APPIMAGE_UPDATE_CHECK
#include <thread>
#include <appimage/update.h>
#endif
class UpdateChecker : public QObject {
Q_OBJECT
Q_PROPERTY(bool active READ active NOTIFY activeChanged)
private:
QNetworkAccessManager netAccessManager;
#ifdef APPIMAGE_UPDATE_CHECK
std::shared_ptr<appimage::update::Updater> updater;
std::thread updatethread;
#endif
std::atomic_bool m_active;
void onRequestFinished(QNetworkReply* reply);
public:
UpdateChecker(QObject* parent = nullptr);
#ifdef APPIMAGE_UPDATE_CHECK
~UpdateChecker();
#endif
bool active() const { return m_active; }
signals:
void updateAvailable(QString downloadUrl);
void updateCheck(bool update);
void progress(qreal progress);
void activeChanged();
void requestRestart();
void updateError(QString error);
public slots:
void checkForUpdates();
void startUpdate();
};
#endif // UPDATECHECKER_H