2026-01-18 12:13:07 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
// SPDX-FileCopyrightText: 2024 A-La-Karte Contributors
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QQmlEngine>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QUrl>
|
2026-01-25 13:19:57 +00:00
|
|
|
#include <QVariantMap>
|
2026-01-18 12:13:07 +00:00
|
|
|
|
|
|
|
|
class Game : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
QML_ELEMENT
|
|
|
|
|
QML_UNCREATABLE("Game objects are created by GameModel")
|
|
|
|
|
|
|
|
|
|
Q_PROPERTY(QString id READ id CONSTANT)
|
|
|
|
|
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
|
|
|
|
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
|
|
|
|
|
Q_PROPERTY(QString developer READ developer WRITE setDeveloper NOTIFY developerChanged)
|
|
|
|
|
Q_PROPERTY(QString publisher READ publisher WRITE setPublisher NOTIFY publisherChanged)
|
|
|
|
|
Q_PROPERTY(QUrl coverUrl READ coverUrl WRITE setCoverUrl NOTIFY coverUrlChanged)
|
|
|
|
|
Q_PROPERTY(QUrl iconUrl READ iconUrl WRITE setIconUrl NOTIFY iconUrlChanged)
|
|
|
|
|
Q_PROPERTY(QString launchCommand READ launchCommand WRITE setLaunchCommand NOTIFY launchCommandChanged)
|
|
|
|
|
Q_PROPERTY(QString workingDirectory READ workingDirectory WRITE setWorkingDirectory NOTIFY workingDirectoryChanged)
|
2026-01-25 13:19:57 +00:00
|
|
|
Q_PROPERTY(QVariantMap launchEnv READ launchEnv WRITE setLaunchEnv NOTIFY launchEnvChanged)
|
|
|
|
|
Q_PROPERTY(QString launchRunner READ launchRunner WRITE setLaunchRunner NOTIFY launchRunnerChanged)
|
|
|
|
|
Q_PROPERTY(QString launchRunnerPath READ launchRunnerPath WRITE setLaunchRunnerPath NOTIFY launchRunnerPathChanged)
|
|
|
|
|
Q_PROPERTY(QString launchPrefixPath READ launchPrefixPath WRITE setLaunchPrefixPath NOTIFY launchPrefixPathChanged)
|
2026-01-18 12:13:07 +00:00
|
|
|
Q_PROPERTY(QString platform READ platform WRITE setPlatform NOTIFY platformChanged)
|
|
|
|
|
Q_PROPERTY(QString platformId READ platformId WRITE setPlatformId NOTIFY platformIdChanged)
|
|
|
|
|
Q_PROPERTY(QDateTime dateAdded READ dateAdded WRITE setDateAdded NOTIFY dateAddedChanged)
|
|
|
|
|
Q_PROPERTY(QDateTime lastPlayed READ lastPlayed WRITE setLastPlayed NOTIFY lastPlayedChanged)
|
|
|
|
|
Q_PROPERTY(qint64 playTime READ playTime WRITE setPlayTime NOTIFY playTimeChanged)
|
|
|
|
|
Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged)
|
|
|
|
|
Q_PROPERTY(bool hidden READ hidden WRITE setHidden NOTIFY hiddenChanged)
|
|
|
|
|
Q_PROPERTY(bool installed READ installed WRITE setInstalled NOTIFY installedChanged)
|
|
|
|
|
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit Game(QObject *parent = nullptr);
|
|
|
|
|
Game(const QString &id, const QString &name, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
QString id() const;
|
|
|
|
|
|
|
|
|
|
QString name() const;
|
|
|
|
|
void setName(const QString &name);
|
|
|
|
|
|
|
|
|
|
QString description() const;
|
|
|
|
|
void setDescription(const QString &description);
|
|
|
|
|
|
|
|
|
|
QString developer() const;
|
|
|
|
|
void setDeveloper(const QString &developer);
|
|
|
|
|
|
|
|
|
|
QString publisher() const;
|
|
|
|
|
void setPublisher(const QString &publisher);
|
|
|
|
|
|
|
|
|
|
QUrl coverUrl() const;
|
|
|
|
|
void setCoverUrl(const QUrl &url);
|
|
|
|
|
|
|
|
|
|
QUrl iconUrl() const;
|
|
|
|
|
void setIconUrl(const QUrl &url);
|
|
|
|
|
|
|
|
|
|
QString launchCommand() const;
|
|
|
|
|
void setLaunchCommand(const QString &command);
|
|
|
|
|
|
|
|
|
|
QString workingDirectory() const;
|
|
|
|
|
void setWorkingDirectory(const QString &dir);
|
|
|
|
|
|
2026-01-25 13:19:57 +00:00
|
|
|
QVariantMap launchEnv() const;
|
|
|
|
|
void setLaunchEnv(const QVariantMap &env);
|
|
|
|
|
|
|
|
|
|
QString launchRunner() const;
|
|
|
|
|
void setLaunchRunner(const QString &runner);
|
|
|
|
|
|
|
|
|
|
QString launchRunnerPath() const;
|
|
|
|
|
void setLaunchRunnerPath(const QString &path);
|
|
|
|
|
|
|
|
|
|
QString launchPrefixPath() const;
|
|
|
|
|
void setLaunchPrefixPath(const QString &path);
|
|
|
|
|
|
2026-01-18 12:13:07 +00:00
|
|
|
QString platform() const;
|
|
|
|
|
void setPlatform(const QString &platform);
|
|
|
|
|
|
|
|
|
|
QString platformId() const;
|
|
|
|
|
void setPlatformId(const QString &id);
|
|
|
|
|
|
|
|
|
|
QDateTime dateAdded() const;
|
|
|
|
|
void setDateAdded(const QDateTime &dateTime);
|
|
|
|
|
|
|
|
|
|
QDateTime lastPlayed() const;
|
|
|
|
|
void setLastPlayed(const QDateTime &dateTime);
|
|
|
|
|
|
|
|
|
|
qint64 playTime() const;
|
|
|
|
|
void setPlayTime(qint64 seconds);
|
|
|
|
|
|
|
|
|
|
bool favorite() const;
|
|
|
|
|
void setFavorite(bool favorite);
|
|
|
|
|
|
|
|
|
|
bool hidden() const;
|
|
|
|
|
void setHidden(bool hidden);
|
|
|
|
|
|
|
|
|
|
bool installed() const;
|
|
|
|
|
void setInstalled(bool installed);
|
|
|
|
|
|
|
|
|
|
bool running() const;
|
|
|
|
|
void setRunning(bool running);
|
|
|
|
|
|
|
|
|
|
QJsonObject toJson() const;
|
|
|
|
|
static Game *fromJson(const QJsonObject &json, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
Q_INVOKABLE QString playTimeFormatted() const;
|
|
|
|
|
Q_INVOKABLE QString lastPlayedFormatted() const;
|
|
|
|
|
Q_INVOKABLE QString dateAddedFormatted() const;
|
|
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void nameChanged();
|
|
|
|
|
void descriptionChanged();
|
|
|
|
|
void developerChanged();
|
|
|
|
|
void publisherChanged();
|
|
|
|
|
void coverUrlChanged();
|
|
|
|
|
void iconUrlChanged();
|
|
|
|
|
void launchCommandChanged();
|
|
|
|
|
void workingDirectoryChanged();
|
2026-01-25 13:19:57 +00:00
|
|
|
void launchEnvChanged();
|
|
|
|
|
void launchRunnerChanged();
|
|
|
|
|
void launchRunnerPathChanged();
|
|
|
|
|
void launchPrefixPathChanged();
|
2026-01-18 12:13:07 +00:00
|
|
|
void platformChanged();
|
|
|
|
|
void platformIdChanged();
|
|
|
|
|
void dateAddedChanged();
|
|
|
|
|
void lastPlayedChanged();
|
|
|
|
|
void playTimeChanged();
|
|
|
|
|
void favoriteChanged();
|
|
|
|
|
void hiddenChanged();
|
|
|
|
|
void installedChanged();
|
|
|
|
|
void runningChanged();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_id;
|
|
|
|
|
QString m_name;
|
|
|
|
|
QString m_description;
|
|
|
|
|
QString m_developer;
|
|
|
|
|
QString m_publisher;
|
|
|
|
|
QUrl m_coverUrl;
|
|
|
|
|
QUrl m_iconUrl;
|
|
|
|
|
QString m_launchCommand;
|
|
|
|
|
QString m_workingDirectory;
|
2026-01-25 13:19:57 +00:00
|
|
|
QVariantMap m_launchEnv;
|
|
|
|
|
QString m_launchRunner;
|
|
|
|
|
QString m_launchRunnerPath;
|
|
|
|
|
QString m_launchPrefixPath;
|
2026-01-18 12:13:07 +00:00
|
|
|
QString m_platform;
|
|
|
|
|
QString m_platformId;
|
|
|
|
|
QDateTime m_dateAdded;
|
|
|
|
|
QDateTime m_lastPlayed;
|
|
|
|
|
qint64 m_playTime = 0;
|
|
|
|
|
bool m_favorite = false;
|
|
|
|
|
bool m_hidden = false;
|
|
|
|
|
bool m_installed = true;
|
|
|
|
|
bool m_running = false;
|
|
|
|
|
};
|