mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-02-10 05:13:08 +00:00
Core: persist per-game runner launch config
This commit is contained in:
parent
ded8ad83da
commit
d87c227347
2 changed files with 32 additions and 1 deletions
27
src/game.cpp
27
src/game.cpp
|
|
@ -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
|
QString Game::launchRunnerPath() const
|
||||||
{
|
{
|
||||||
return m_launchRunnerPath;
|
return m_launchRunnerPath;
|
||||||
|
|
@ -323,7 +336,8 @@ QJsonObject Game::toJson() const
|
||||||
obj[QStringLiteral("hidden")] = m_hidden;
|
obj[QStringLiteral("hidden")] = m_hidden;
|
||||||
obj[QStringLiteral("installed")] = m_installed;
|
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) {
|
if (hasLaunchConfig) {
|
||||||
QJsonObject launchObj;
|
QJsonObject launchObj;
|
||||||
|
|
||||||
|
|
@ -338,6 +352,9 @@ QJsonObject Game::toJson() const
|
||||||
if (!m_launchRunner.isEmpty()) {
|
if (!m_launchRunner.isEmpty()) {
|
||||||
launchObj.insert(QStringLiteral("runner"), m_launchRunner);
|
launchObj.insert(QStringLiteral("runner"), m_launchRunner);
|
||||||
}
|
}
|
||||||
|
if (!m_launchRunnerId.isEmpty()) {
|
||||||
|
launchObj.insert(QStringLiteral("runnerId"), m_launchRunnerId);
|
||||||
|
}
|
||||||
if (!m_launchRunnerPath.isEmpty()) {
|
if (!m_launchRunnerPath.isEmpty()) {
|
||||||
launchObj.insert(QStringLiteral("runnerPath"), m_launchRunnerPath);
|
launchObj.insert(QStringLiteral("runnerPath"), m_launchRunnerPath);
|
||||||
}
|
}
|
||||||
|
|
@ -391,6 +408,7 @@ Game *Game::fromJson(const QJsonObject &json, QObject *parent)
|
||||||
|
|
||||||
QVariantMap env;
|
QVariantMap env;
|
||||||
QString runner;
|
QString runner;
|
||||||
|
QString runnerId;
|
||||||
QString runnerPath;
|
QString runnerPath;
|
||||||
QString prefixPath;
|
QString prefixPath;
|
||||||
const QJsonValue launchValue = json.value(QStringLiteral("launch"));
|
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();
|
runner = launchObj.value(QStringLiteral("runner")).toString();
|
||||||
|
runnerId = launchObj.value(QStringLiteral("runnerId")).toString();
|
||||||
runnerPath = launchObj.value(QStringLiteral("runnerPath")).toString();
|
runnerPath = launchObj.value(QStringLiteral("runnerPath")).toString();
|
||||||
prefixPath = launchObj.value(QStringLiteral("prefixPath")).toString();
|
prefixPath = launchObj.value(QStringLiteral("prefixPath")).toString();
|
||||||
}
|
}
|
||||||
|
|
@ -414,6 +433,9 @@ Game *Game::fromJson(const QJsonObject &json, QObject *parent)
|
||||||
if (runner.isEmpty()) {
|
if (runner.isEmpty()) {
|
||||||
runner = json.value(QStringLiteral("launchRunner")).toString();
|
runner = json.value(QStringLiteral("launchRunner")).toString();
|
||||||
}
|
}
|
||||||
|
if (runnerId.isEmpty()) {
|
||||||
|
runnerId = json.value(QStringLiteral("launchRunnerId")).toString();
|
||||||
|
}
|
||||||
if (runnerPath.isEmpty()) {
|
if (runnerPath.isEmpty()) {
|
||||||
runnerPath = json.value(QStringLiteral("launchRunnerPath")).toString();
|
runnerPath = json.value(QStringLiteral("launchRunnerPath")).toString();
|
||||||
}
|
}
|
||||||
|
|
@ -428,6 +450,9 @@ Game *Game::fromJson(const QJsonObject &json, QObject *parent)
|
||||||
if (!runner.isEmpty()) {
|
if (!runner.isEmpty()) {
|
||||||
game->setLaunchRunner(runner);
|
game->setLaunchRunner(runner);
|
||||||
}
|
}
|
||||||
|
if (!runnerId.isEmpty()) {
|
||||||
|
game->setLaunchRunnerId(runnerId);
|
||||||
|
}
|
||||||
if (!runnerPath.isEmpty()) {
|
if (!runnerPath.isEmpty()) {
|
||||||
game->setLaunchRunnerPath(runnerPath);
|
game->setLaunchRunnerPath(runnerPath);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ class Game : public QObject
|
||||||
Q_PROPERTY(QString workingDirectory READ workingDirectory WRITE setWorkingDirectory NOTIFY workingDirectoryChanged)
|
Q_PROPERTY(QString workingDirectory READ workingDirectory WRITE setWorkingDirectory NOTIFY workingDirectoryChanged)
|
||||||
Q_PROPERTY(QVariantMap launchEnv READ launchEnv WRITE setLaunchEnv NOTIFY launchEnvChanged)
|
Q_PROPERTY(QVariantMap launchEnv READ launchEnv WRITE setLaunchEnv NOTIFY launchEnvChanged)
|
||||||
Q_PROPERTY(QString launchRunner READ launchRunner WRITE setLaunchRunner NOTIFY launchRunnerChanged)
|
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 launchRunnerPath READ launchRunnerPath WRITE setLaunchRunnerPath NOTIFY launchRunnerPathChanged)
|
||||||
Q_PROPERTY(QString launchPrefixPath READ launchPrefixPath WRITE setLaunchPrefixPath NOTIFY launchPrefixPathChanged)
|
Q_PROPERTY(QString launchPrefixPath READ launchPrefixPath WRITE setLaunchPrefixPath NOTIFY launchPrefixPathChanged)
|
||||||
Q_PROPERTY(QString platform READ platform WRITE setPlatform NOTIFY platformChanged)
|
Q_PROPERTY(QString platform READ platform WRITE setPlatform NOTIFY platformChanged)
|
||||||
|
|
@ -76,6 +77,9 @@ public:
|
||||||
QString launchRunner() const;
|
QString launchRunner() const;
|
||||||
void setLaunchRunner(const QString &runner);
|
void setLaunchRunner(const QString &runner);
|
||||||
|
|
||||||
|
QString launchRunnerId() const;
|
||||||
|
void setLaunchRunnerId(const QString &runnerId);
|
||||||
|
|
||||||
QString launchRunnerPath() const;
|
QString launchRunnerPath() const;
|
||||||
void setLaunchRunnerPath(const QString &path);
|
void setLaunchRunnerPath(const QString &path);
|
||||||
|
|
||||||
|
|
@ -127,6 +131,7 @@ Q_SIGNALS:
|
||||||
void workingDirectoryChanged();
|
void workingDirectoryChanged();
|
||||||
void launchEnvChanged();
|
void launchEnvChanged();
|
||||||
void launchRunnerChanged();
|
void launchRunnerChanged();
|
||||||
|
void launchRunnerIdChanged();
|
||||||
void launchRunnerPathChanged();
|
void launchRunnerPathChanged();
|
||||||
void launchPrefixPathChanged();
|
void launchPrefixPathChanged();
|
||||||
void platformChanged();
|
void platformChanged();
|
||||||
|
|
@ -151,6 +156,7 @@ private:
|
||||||
QString m_workingDirectory;
|
QString m_workingDirectory;
|
||||||
QVariantMap m_launchEnv;
|
QVariantMap m_launchEnv;
|
||||||
QString m_launchRunner;
|
QString m_launchRunner;
|
||||||
|
QString m_launchRunnerId;
|
||||||
QString m_launchRunnerPath;
|
QString m_launchRunnerPath;
|
||||||
QString m_launchPrefixPath;
|
QString m_launchPrefixPath;
|
||||||
QString m_platform;
|
QString m_platform;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue