-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
updater.h
85 lines (66 loc) · 2.49 KB
/
updater.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef UPDATER_H
#define UPDATER_H
#include <QtWidgets>
class Updater : public QObject {
Q_OBJECT
public:
/// Set a shared Updater instance
static void setInstance(Updater *value);
/// Get a shared updater instance, null by default
static Updater &instance();
Updater(QObject *parent = nullptr);
QAction *getAction();
QPushButton *getButton();
QLabel *getLabel();
enum class Status {
Unknown,
UpToDate,
UpdateAvailable,
DownloadingUpdate,
UpdateDownloaded,
UpdateDownloadFailed
};
Q_ENUM(Status)
Status getStatus() const { return status; }
// This should be protected
void setStatus(Status v);
QString getVersion() const { return version; }
// This should be protected
void setVersion(const QString &value) { version = value; }
QString getDisplayVersion() const { return displayVersion; }
// This should be protected
void setDisplayVersion(const QString &value) { displayVersion = value; }
/// true if the app can be updated immediately while running (default: false)
virtual bool getImmediateInstallWithoutRelaunch() const {
return immediateInstallWithoutRelaunch;
}
virtual void setImmediateInstallWithoutRelaunch(bool value) {
immediateInstallWithoutRelaunch = value;
}
/// true if the app can be stopped and relaunched immediately (default: false)
virtual bool getImmediateInstallAndRelaunch() const { return immediateInstallAndRelaunch; }
virtual void setImmediateInstallAndRelaunch(bool value) { immediateInstallAndRelaunch = value; }
/// when true an available update will be downloaded without user interaction (default: true)
virtual bool getAutomaticDownload() const { return automaticDownload; }
virtual void setAutomaticDownload(bool value) { automaticDownload = value; }
virtual void checkAndShowUI() = 0;
virtual void checkAndMaybeShowUI() = 0;
virtual void checkWithoutUI() = 0;
protected slots:
virtual void update() = 0;
virtual void onUserAction();
signals:
void statusChanged(Status status);
void actionTextChanged(const QString &actionText);
private:
QAction *action = nullptr;
QPushButton *button = nullptr;
QLabel *label = nullptr;
bool automaticDownload = true;
bool immediateInstallAndRelaunch = false;
bool immediateInstallWithoutRelaunch = false;
Status status = Status::Unknown;
QString version;
QString displayVersion;
};
#endif // UPDATER_H