tests / package-smoke-linux (push) Skipped
tests / package-smoke-windows (push) Skipped
tests / package-smoke-macos (push) Skipped
tests / macos (push) Successful in 1m15s
tests / linux (push) Failing after 2m3s
tests / windows (push) Failing after 2m7s
release / create-release (push) Failing after 2s
release / build-linux (push) Skipped
release / build-windows (push) Skipped
release / build-macos (push) Skipped
release / publish (push) Skipped
Signed-off-by: galeon <dertiellis@gmail.com>
58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <QNetworkAccessManager>
|
|
#include <QTemporaryDir>
|
|
#include <QVariantMap>
|
|
#include <QtQml/qqmlregistration.h>
|
|
#include <memory>
|
|
|
|
class QFile;
|
|
class QNetworkReply;
|
|
|
|
class LauncherUpdates : public QObject
|
|
{
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
Q_PROPERTY(QString channel READ channel CONSTANT)
|
|
Q_PROPERTY(QVariantMap catalogs READ catalogs NOTIFY catalogChanged)
|
|
Q_PROPERTY(QVariantMap states READ states NOTIFY catalogChanged)
|
|
Q_PROPERTY(QString latest READ latest NOTIFY catalogChanged)
|
|
Q_PROPERTY(bool installing READ installing NOTIFY installationChanged)
|
|
Q_PROPERTY(double downloadProgress READ downloadProgress NOTIFY downloadProgressChanged)
|
|
|
|
public:
|
|
explicit LauncherUpdates(QObject *parent = nullptr);
|
|
~LauncherUpdates() override;
|
|
|
|
QString channel() const;
|
|
QVariantMap catalogs() const { return m_catalogs; }
|
|
QVariantMap states() const { return m_states; }
|
|
QString latest() const { return m_latest; }
|
|
bool installing() const { return bool(m_download); }
|
|
double downloadProgress() const { return m_downloadProgress; }
|
|
|
|
Q_INVOKABLE void refresh(const QString &channel);
|
|
Q_INVOKABLE void install(const QString &channel, const QString &version);
|
|
Q_INVOKABLE void cancelDownload();
|
|
|
|
signals:
|
|
void catalogChanged();
|
|
void installationChanged();
|
|
void downloadProgressChanged();
|
|
void installationFailed();
|
|
|
|
private:
|
|
void fetchPage(const QString &channel, int page, QVariantList entries);
|
|
bool startInstallation(const QString &path);
|
|
|
|
QNetworkAccessManager m_network;
|
|
QVariantMap m_catalogs;
|
|
QVariantMap m_states;
|
|
QString m_latest;
|
|
std::unique_ptr<QTemporaryDir> m_temp;
|
|
std::unique_ptr<QFile> m_download;
|
|
QNetworkReply *m_downloadReply = nullptr;
|
|
double m_downloadProgress = -1;
|
|
bool m_cancelRequested = false;
|
|
};
|