mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-02-10 05:13:08 +00:00
Initial release of A-La-Karte, a unified game launcher for KDE Plasma. Includes the QML UI, platform importers, AppStream metadata, icons, and developer documentation.
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
// SPDX-FileCopyrightText: 2024 A-La-Karte Contributors
|
|
|
|
#pragma once
|
|
|
|
#include <QMap>
|
|
#include <QObject>
|
|
#include <QProcess>
|
|
#include <QQmlEngine>
|
|
|
|
#include "game.h"
|
|
|
|
class GameLauncher : public QObject
|
|
{
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
|
|
Q_PROPERTY(bool hasRunningGames READ hasRunningGames NOTIFY runningGamesChanged)
|
|
|
|
public:
|
|
explicit GameLauncher(QObject *parent = nullptr);
|
|
~GameLauncher();
|
|
|
|
bool hasRunningGames() const;
|
|
|
|
Q_INVOKABLE void launchGame(Game *game);
|
|
Q_INVOKABLE void stopGame(Game *game);
|
|
Q_INVOKABLE bool isGameRunning(Game *game) const;
|
|
|
|
Q_SIGNALS:
|
|
void gameStarted(Game *game);
|
|
void gameStopped(Game *game, int exitCode);
|
|
void gameError(Game *game, const QString &error);
|
|
void runningGamesChanged();
|
|
|
|
private Q_SLOTS:
|
|
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
|
void onProcessError(QProcess::ProcessError error);
|
|
|
|
private:
|
|
QMap<QString, QProcess *> m_runningGames;
|
|
QMap<QProcess *, Game *> m_processToGame;
|
|
|
|
void cleanupProcess(QProcess *process);
|
|
};
|