mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-02-09 21:13:08 +00:00
Select the couch launch profile based on effective UI mode so profile choice is consistent across games. Update details and edit UI to toggle and reflect couch mode globally, and fix duplicate QML property declarations.
177 lines
6.2 KiB
C++
177 lines
6.2 KiB
C++
// 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>
|
|
#include <QVariantMap>
|
|
|
|
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)
|
|
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)
|
|
Q_PROPERTY(QString activeLaunchProfile READ activeLaunchProfile WRITE setActiveLaunchProfile NOTIFY activeLaunchProfileChanged)
|
|
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);
|
|
|
|
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);
|
|
|
|
QString activeLaunchProfile() const;
|
|
void setActiveLaunchProfile(const QString &profileId);
|
|
|
|
Q_INVOKABLE QVariantMap launchProfileConfig(const QString &profileId) const;
|
|
Q_INVOKABLE void setLaunchProfileConfig(const QString &profileId, const QVariantMap &config);
|
|
QVariantMap effectiveLaunchConfigForProfile(const QString &profileId) const;
|
|
QVariantMap effectiveLaunchConfig() const;
|
|
|
|
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();
|
|
void launchEnvChanged();
|
|
void launchRunnerChanged();
|
|
void launchRunnerPathChanged();
|
|
void launchPrefixPathChanged();
|
|
void activeLaunchProfileChanged();
|
|
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;
|
|
QVariantMap m_launchEnv;
|
|
QString m_launchRunner;
|
|
QString m_launchRunnerPath;
|
|
QString m_launchPrefixPath;
|
|
QString m_activeLaunchProfile = QStringLiteral("default");
|
|
QVariantMap m_launchProfiles;
|
|
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;
|
|
};
|