mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-02-09 21:13:08 +00:00
84 lines
2.4 KiB
C
84 lines
2.4 KiB
C
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
|
// SPDX-FileCopyrightText: 2026 A-La-Karte Contributors
|
||
|
|
|
||
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <QHash>
|
||
|
|
#include <QJsonObject>
|
||
|
|
#include <QObject>
|
||
|
|
#include <QQmlEngine>
|
||
|
|
|
||
|
|
#include "config.h"
|
||
|
|
#include "gamelauncher.h"
|
||
|
|
#include "gamemodel.h"
|
||
|
|
#include "steamgriddb.h"
|
||
|
|
|
||
|
|
class App : public QObject
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
QML_ELEMENT
|
||
|
|
QML_SINGLETON
|
||
|
|
|
||
|
|
Q_PROPERTY(GameModel *gameModel READ gameModel CONSTANT)
|
||
|
|
Q_PROPERTY(GameLauncher *launcher READ launcher CONSTANT)
|
||
|
|
Q_PROPERTY(SteamGridDB *steamGridDB READ steamGridDB CONSTANT)
|
||
|
|
Q_PROPERTY(Config *config READ config CONSTANT)
|
||
|
|
Q_PROPERTY(bool importing READ importing NOTIFY importingChanged)
|
||
|
|
Q_PROPERTY(QString importStatus READ importStatus NOTIFY importStatusChanged)
|
||
|
|
|
||
|
|
public:
|
||
|
|
static App *instance();
|
||
|
|
static App *create(QQmlEngine *engine, QJSEngine *scriptEngine);
|
||
|
|
|
||
|
|
GameModel *gameModel() const;
|
||
|
|
GameLauncher *launcher() const;
|
||
|
|
SteamGridDB *steamGridDB() const;
|
||
|
|
Config *config() const;
|
||
|
|
|
||
|
|
bool importing() const;
|
||
|
|
QString importStatus() const;
|
||
|
|
|
||
|
|
Q_INVOKABLE void importAllGames();
|
||
|
|
Q_INVOKABLE void importFromSteam();
|
||
|
|
Q_INVOKABLE void importFromLutris();
|
||
|
|
Q_INVOKABLE void importFromHeroic();
|
||
|
|
Q_INVOKABLE void importFromDesktop();
|
||
|
|
Q_INVOKABLE void importFromBottles();
|
||
|
|
Q_INVOKABLE void importFromFlatpak();
|
||
|
|
Q_INVOKABLE void importFromItch();
|
||
|
|
Q_INVOKABLE void importFromLegendary();
|
||
|
|
Q_INVOKABLE void importFromRetroArch();
|
||
|
|
Q_INVOKABLE void clearLibrary();
|
||
|
|
Q_INVOKABLE void removeMissingGames();
|
||
|
|
Q_INVOKABLE void saveLibrary();
|
||
|
|
Q_INVOKABLE void loadLibrary();
|
||
|
|
|
||
|
|
Q_INVOKABLE Game *createGame(const QString &name, const QString &launchCommand);
|
||
|
|
Q_INVOKABLE void removeGame(Game *game);
|
||
|
|
Q_INVOKABLE void restoreGame(const QString &gameId);
|
||
|
|
Q_INVOKABLE bool setCoverFromFile(Game *game, const QString &filePath);
|
||
|
|
|
||
|
|
Q_SIGNALS:
|
||
|
|
void importingChanged();
|
||
|
|
void importStatusChanged();
|
||
|
|
void importCompleted(int count);
|
||
|
|
void importError(const QString &error);
|
||
|
|
|
||
|
|
private:
|
||
|
|
explicit App(QObject *parent = nullptr);
|
||
|
|
|
||
|
|
static App *s_instance;
|
||
|
|
|
||
|
|
GameModel *m_gameModel;
|
||
|
|
GameLauncher *m_launcher;
|
||
|
|
SteamGridDB *m_steamGridDB;
|
||
|
|
Config *m_config;
|
||
|
|
|
||
|
|
bool m_importing = false;
|
||
|
|
QString m_importStatus;
|
||
|
|
QHash<QString, QJsonObject> m_removedGames;
|
||
|
|
|
||
|
|
void setImporting(bool importing);
|
||
|
|
void setImportStatus(const QString &status);
|
||
|
|
};
|