mirror-chatterino2/src/singletons/Updates.hpp

49 lines
968 B
C++
Raw Normal View History

2018-04-19 22:16:55 +02:00
#pragma once
2018-05-06 14:16:41 +02:00
#include <QString>
2018-04-19 22:16:55 +02:00
#include <pajlada/signals/signal.hpp>
namespace chatterino {
2018-06-28 19:51:07 +02:00
class Updates
2018-04-19 22:16:55 +02:00
{
2018-06-28 19:51:07 +02:00
Updates();
2018-04-19 22:16:55 +02:00
public:
2018-07-05 11:42:40 +02:00
enum Status {
2018-06-21 22:02:35 +02:00
None,
Searching,
UpdateAvailable,
NoUpdateAvailable,
SearchFailed,
Downloading,
DownloadFailed,
WriteFileFailed,
};
2018-06-01 14:20:46 +02:00
// fourtf: don't add this class to the application class
2018-06-28 19:51:07 +02:00
static Updates &getInstance();
2018-04-19 22:16:55 +02:00
void checkForUpdates();
const QString &getCurrentVersion() const;
const QString &getOnlineVersion() const;
2018-06-01 14:20:46 +02:00
void installUpdates();
2018-07-05 11:42:40 +02:00
Status getStatus() const;
2018-04-19 22:16:55 +02:00
2018-07-05 11:42:40 +02:00
bool shouldShowUpdateButton() const;
bool isError() const;
pajlada::Signals::Signal<Status> statusUpdated;
2018-04-19 22:16:55 +02:00
private:
2018-06-01 14:20:46 +02:00
QString currentVersion_;
QString onlineVersion_;
2018-07-05 11:42:40 +02:00
Status status_ = None;
2018-06-01 14:20:46 +02:00
2018-06-21 22:02:35 +02:00
QString updateUrl_;
2018-07-05 11:42:40 +02:00
void setStatus_(Status status);
2018-04-19 22:16:55 +02:00
};
} // namespace chatterino