QtAutoUpdater  3.0.0
A Qt library to automatically check for updates and install them
updatebutton.h
1 #ifndef QTAUTOUPDATER_UPDATEBUTTON_H
2 #define QTAUTOUPDATER_UPDATEBUTTON_H
3 
4 #include "QtAutoUpdaterWidgets/qtautoupdaterwidgets_global.h"
5 
6 #include <QtAutoUpdaterCore/updater.h>
7 
8 #include <QtWidgets/qwidget.h>
9 
10 namespace QtAutoUpdater
11 {
12 
13 class UpdateButtonPrivate;
15 class Q_AUTOUPDATERWIDGETS_EXPORT UpdateButton : public QWidget
16 {
17  Q_OBJECT
18 
20  Q_PROPERTY(QtAutoUpdater::Updater* updater READ updater WRITE setUpdater NOTIFY updaterChanged)
22  Q_PROPERTY(Mode mode READ mode WRITE setMode NOTIFY modeChanged)
24  Q_PROPERTY(QString animationFile READ animationFile WRITE setAnimationFile RESET resetAnimationFile NOTIFY animationFileChanged)
26  Q_PROPERTY(QtAutoUpdater::Updater::InstallMode installMode READ installMode WRITE setInstallMode NOTIFY installModeChanged)
28  Q_PROPERTY(QtAutoUpdater::Updater::InstallScope installScope READ installScope WRITE setInstallScope NOTIFY installScopeChanged)
29 
30 public:
32  enum class ModeFlag {
33  ShowResult = 0x01,
34  ShowStatus = 0x02,
35  AllowInstall = 0x04,
36  AllowCancel = 0x08,
37 
38  None = 0x00,
39  AllowAndShowAll = (ShowResult | ShowStatus | AllowInstall | AllowCancel)
40  };
41  Q_DECLARE_FLAGS(Mode, ModeFlag)
42  Q_FLAG(Mode)
43 
44 
45  explicit UpdateButton(QWidget *parent = nullptr);
47  explicit UpdateButton(Updater *updater, QWidget *parent = nullptr);
48 
50  Updater* updater() const;
52  Mode mode() const;
54  QString animationFile() const;
56  Updater::InstallMode installMode() const;
58  Updater::InstallScope installScope() const;
59 
60 public Q_SLOTS:
62  void setUpdater(Updater* updater);
64  void setMode(Mode mode);
66  void setAnimationFile(const QString &animationFile, int speed = 100);
68  void setAnimationDevice(QIODevice *animationDevice, int speed = 100);
70  void resetAnimationFile();
72  void setInstallMode(QtAutoUpdater::Updater::InstallMode installMode);
74  void setInstallScope(QtAutoUpdater::Updater::InstallScope installScope);
75 
76 Q_SIGNALS:
78  void updaterChanged(QtAutoUpdater::Updater* updater, QPrivateSignal);
80  void modeChanged(Mode mode, QPrivateSignal);
82  void animationFileChanged(const QString &animationFile, QPrivateSignal);
84  void installModeChanged(QtAutoUpdater::Updater::InstallMode installMode, QPrivateSignal);
86  void installScopeChanged(QtAutoUpdater::Updater::InstallScope installScope, QPrivateSignal);
87 
88 private:
89  Q_DECLARE_PRIVATE(UpdateButton)
90 
91  Q_PRIVATE_SLOT(d_func(), void _q_changeUpdaterState(Updater::State))
92  Q_PRIVATE_SLOT(d_func(), void _q_updateStatus(double, const QString &))
93  Q_PRIVATE_SLOT(d_func(), void _q_updaterDestroyed())
94  Q_PRIVATE_SLOT(d_func(), void _q_clicked())
95 };
96 
97 }
98 
99 Q_DECLARE_OPERATORS_FOR_FLAGS(QtAutoUpdater::UpdateButton::Mode)
100 
101 #endif // QTAUTOUPDATER_UPDATEBUTTON_H
QtAutoUpdater::UpdateButton::ModeFlag
ModeFlag
Defines various flags to specify how the button should behave.
Definition: updatebutton.h:32
QtAutoUpdater::Updater
The main updater. Can check for updates and trigger update installations.
Definition: updater.h:26
QIODevice
QWidget
QtAutoUpdater::Updater::State
State
The state of the updater.
Definition: updater.h:43
QtAutoUpdater::UpdateButton
A simple button for update checks.
Definition: updatebutton.h:15
QString
QtAutoUpdater::Updater::InstallScope
InstallScope
Defines the different installation scopes.
Definition: updater.h:67
QtAutoUpdater
The QtAutoUpdater namespace holds all classes that are related with the updater.
Definition: adminauthoriser.h:9