mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-03-27 09:13:09 +00:00
86 lines
2.9 KiB
C
86 lines
2.9 KiB
C
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
|
// SPDX-FileCopyrightText: 2026 A-La-Karte Contributors
|
||
|
|
|
||
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <QObject>
|
||
|
|
#include <QVariantList>
|
||
|
|
#include <QVariantMap>
|
||
|
|
|
||
|
|
class RunnerManagerClient : public QObject
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
|
||
|
|
Q_PROPERTY(QString installId READ installId NOTIFY installIdChanged)
|
||
|
|
Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY progressChanged)
|
||
|
|
Q_PROPERTY(qint64 totalBytes READ totalBytes NOTIFY progressChanged)
|
||
|
|
Q_PROPERTY(QString status READ status NOTIFY statusChanged)
|
||
|
|
Q_PROPERTY(QString lastError READ lastError NOTIFY lastErrorChanged)
|
||
|
|
Q_PROPERTY(QVariantList runners READ runners NOTIFY runnersChanged)
|
||
|
|
|
||
|
|
public:
|
||
|
|
explicit RunnerManagerClient(QObject *parent = nullptr);
|
||
|
|
~RunnerManagerClient() override;
|
||
|
|
|
||
|
|
bool busy() const;
|
||
|
|
QString installId() const;
|
||
|
|
qint64 receivedBytes() const;
|
||
|
|
qint64 totalBytes() const;
|
||
|
|
QString status() const;
|
||
|
|
QString lastError() const;
|
||
|
|
QVariantList runners() const;
|
||
|
|
|
||
|
|
Q_INVOKABLE void installRunnerFromUrl(const QString &url,
|
||
|
|
const QString &sha256 = QString(),
|
||
|
|
const QString &name = QString(),
|
||
|
|
const QString &type = QStringLiteral("proton"),
|
||
|
|
bool overwrite = true);
|
||
|
|
|
||
|
|
Q_INVOKABLE void cancelCurrentInstall();
|
||
|
|
|
||
|
|
Q_INVOKABLE void refreshRunners();
|
||
|
|
Q_INVOKABLE void uninstallRunner(const QString &runnerId);
|
||
|
|
|
||
|
|
Q_INVOKABLE void ensurePrefix(const QString &gameId, const QString &runner, const QString &prefixPath = QString());
|
||
|
|
|
||
|
|
Q_INVOKABLE void deletePrefix(const QString &gameId, const QString &prefixPath = QString());
|
||
|
|
|
||
|
|
Q_SIGNALS:
|
||
|
|
void busyChanged();
|
||
|
|
void installIdChanged();
|
||
|
|
void progressChanged();
|
||
|
|
void statusChanged();
|
||
|
|
void lastErrorChanged();
|
||
|
|
void runnersChanged();
|
||
|
|
void prefixEnsured(const QString &gameId, const QString &prefixPath);
|
||
|
|
void prefixDeleted(const QString &gameId, const QString &prefixPath);
|
||
|
|
|
||
|
|
private Q_SLOTS:
|
||
|
|
void onInstallStarted(const QString &installId, const QVariantMap &spec);
|
||
|
|
void onInstallProgress(const QString &installId, qlonglong received, qlonglong total);
|
||
|
|
void onInstallFinished(const QString &installId, const QVariantMap &result);
|
||
|
|
|
||
|
|
private:
|
||
|
|
void ensureRunnerDaemon();
|
||
|
|
void shutdownSpawnedRunnerDaemon();
|
||
|
|
void setBusy(bool busy);
|
||
|
|
void setInstallId(const QString &installId);
|
||
|
|
void setProgress(qint64 received, qint64 total);
|
||
|
|
void setStatus(const QString &status);
|
||
|
|
void setLastError(const QString &error);
|
||
|
|
|
||
|
|
bool m_busy = false;
|
||
|
|
QString m_installId;
|
||
|
|
qint64 m_receivedBytes = 0;
|
||
|
|
qint64 m_totalBytes = 0;
|
||
|
|
QString m_status;
|
||
|
|
QString m_lastError;
|
||
|
|
|
||
|
|
QVariantList m_runners;
|
||
|
|
|
||
|
|
bool m_refreshRetryPending = false;
|
||
|
|
|
||
|
|
class QProcess *m_runnerdProcess = nullptr;
|
||
|
|
bool m_runnerdSpawnAttempted = false;
|
||
|
|
};
|