Core: persist per-game runner launch config

This commit is contained in:
Marco Allegretti 2026-02-09 13:58:19 +01:00
parent ded8ad83da
commit d87c227347
2 changed files with 32 additions and 1 deletions

View file

@ -159,6 +159,19 @@ void Game::setLaunchRunner(const QString &runner)
}
}
QString Game::launchRunnerId() const
{
return m_launchRunnerId;
}
void Game::setLaunchRunnerId(const QString &runnerId)
{
if (m_launchRunnerId != runnerId) {
m_launchRunnerId = runnerId;
Q_EMIT launchRunnerIdChanged();
}
}
QString Game::launchRunnerPath() const
{
return m_launchRunnerPath;
@ -323,7 +336,8 @@ QJsonObject Game::toJson() const
obj[QStringLiteral("hidden")] = m_hidden;
obj[QStringLiteral("installed")] = m_installed;
const bool hasLaunchConfig = !m_launchEnv.isEmpty() || !m_launchRunner.isEmpty() || !m_launchRunnerPath.isEmpty() || !m_launchPrefixPath.isEmpty();
const bool hasLaunchConfig =
!m_launchEnv.isEmpty() || !m_launchRunner.isEmpty() || !m_launchRunnerId.isEmpty() || !m_launchRunnerPath.isEmpty() || !m_launchPrefixPath.isEmpty();
if (hasLaunchConfig) {
QJsonObject launchObj;
@ -338,6 +352,9 @@ QJsonObject Game::toJson() const
if (!m_launchRunner.isEmpty()) {
launchObj.insert(QStringLiteral("runner"), m_launchRunner);
}
if (!m_launchRunnerId.isEmpty()) {
launchObj.insert(QStringLiteral("runnerId"), m_launchRunnerId);
}
if (!m_launchRunnerPath.isEmpty()) {
launchObj.insert(QStringLiteral("runnerPath"), m_launchRunnerPath);
}
@ -391,6 +408,7 @@ Game *Game::fromJson(const QJsonObject &json, QObject *parent)
QVariantMap env;
QString runner;
QString runnerId;
QString runnerPath;
QString prefixPath;
const QJsonValue launchValue = json.value(QStringLiteral("launch"));
@ -402,6 +420,7 @@ Game *Game::fromJson(const QJsonObject &json, QObject *parent)
}
runner = launchObj.value(QStringLiteral("runner")).toString();
runnerId = launchObj.value(QStringLiteral("runnerId")).toString();
runnerPath = launchObj.value(QStringLiteral("runnerPath")).toString();
prefixPath = launchObj.value(QStringLiteral("prefixPath")).toString();
}
@ -414,6 +433,9 @@ Game *Game::fromJson(const QJsonObject &json, QObject *parent)
if (runner.isEmpty()) {
runner = json.value(QStringLiteral("launchRunner")).toString();
}
if (runnerId.isEmpty()) {
runnerId = json.value(QStringLiteral("launchRunnerId")).toString();
}
if (runnerPath.isEmpty()) {
runnerPath = json.value(QStringLiteral("launchRunnerPath")).toString();
}
@ -428,6 +450,9 @@ Game *Game::fromJson(const QJsonObject &json, QObject *parent)
if (!runner.isEmpty()) {
game->setLaunchRunner(runner);
}
if (!runnerId.isEmpty()) {
game->setLaunchRunnerId(runnerId);
}
if (!runnerPath.isEmpty()) {
game->setLaunchRunnerPath(runnerPath);
}

View file

@ -28,6 +28,7 @@ class Game : public QObject
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 launchRunnerId READ launchRunnerId WRITE setLaunchRunnerId NOTIFY launchRunnerIdChanged)
Q_PROPERTY(QString launchRunnerPath READ launchRunnerPath WRITE setLaunchRunnerPath NOTIFY launchRunnerPathChanged)
Q_PROPERTY(QString launchPrefixPath READ launchPrefixPath WRITE setLaunchPrefixPath NOTIFY launchPrefixPathChanged)
Q_PROPERTY(QString platform READ platform WRITE setPlatform NOTIFY platformChanged)
@ -76,6 +77,9 @@ public:
QString launchRunner() const;
void setLaunchRunner(const QString &runner);
QString launchRunnerId() const;
void setLaunchRunnerId(const QString &runnerId);
QString launchRunnerPath() const;
void setLaunchRunnerPath(const QString &path);
@ -127,6 +131,7 @@ Q_SIGNALS:
void workingDirectoryChanged();
void launchEnvChanged();
void launchRunnerChanged();
void launchRunnerIdChanged();
void launchRunnerPathChanged();
void launchPrefixPathChanged();
void platformChanged();
@ -151,6 +156,7 @@ private:
QString m_workingDirectory;
QVariantMap m_launchEnv;
QString m_launchRunner;
QString m_launchRunnerId;
QString m_launchRunnerPath;
QString m_launchPrefixPath;
QString m_platform;