From 22a99ecbd8f4dc354f8d69db214bbaacfaf3d779 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 17 Dec 2023 11:23:17 -0500 Subject: [PATCH] Move CurrentProfile setting to astrastaterc --- launcher/config.kcfg | 2 -- launcher/include/launchersettings.h | 3 +++ launcher/src/launchercore.cpp | 4 ++-- launcher/src/launchersettings.cpp | 12 ++++++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/launcher/config.kcfg b/launcher/config.kcfg index 5b2cae1..5af51f2 100644 --- a/launcher/config.kcfg +++ b/launcher/config.kcfg @@ -23,8 +23,6 @@ SPDX-License-Identifier: CC0-1.0 - - QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + QDir::separator() + QStringLiteral("FFXIV") diff --git a/launcher/include/launchersettings.h b/launcher/include/launchersettings.h index cefdd10..b5d5d8a 100644 --- a/launcher/include/launchersettings.h +++ b/launcher/include/launchersettings.h @@ -63,6 +63,9 @@ public: [[nodiscard]] bool argumentsEncrypted() const; void setArgumentsEncrypted(bool value); + [[nodiscard]] QString currentProfile() const; + void setCurrentProfile(const QString &value); + Config *config(); Q_SIGNALS: diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index fdbccec..136592c 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -42,7 +42,7 @@ LauncherCore::LauncherCore() } // set default profile, if found - if (auto profile = m_profileManager->getProfileByUUID(m_settings->config()->currentProfile()); profile != nullptr) { + if (auto profile = m_profileManager->getProfileByUUID(m_settings->currentProfile()); profile != nullptr) { setCurrentProfile(profile); } @@ -132,7 +132,7 @@ void LauncherCore::setCurrentProfile(Profile *profile) const int newIndex = m_profileManager->getProfileIndex(profile->uuid()); if (newIndex != m_currentProfileIndex) { m_currentProfileIndex = newIndex; - m_settings->config()->setCurrentProfile(profile->uuid()); + m_settings->setCurrentProfile(profile->uuid()); m_settings->config()->save(); Q_EMIT currentProfileChanged(); } diff --git a/launcher/src/launchersettings.cpp b/launcher/src/launchersettings.cpp index e41fdb8..a0db988 100644 --- a/launcher/src/launchersettings.cpp +++ b/launcher/src/launchersettings.cpp @@ -163,6 +163,18 @@ void LauncherSettings::setArgumentsEncrypted(const bool value) } } +QString LauncherSettings::currentProfile() const +{ + return KSharedConfig::openStateConfig()->group(QStringLiteral("General")).readEntry(QStringLiteral("CurrentProfile")); +} + +void LauncherSettings::setCurrentProfile(const QString &value) +{ + auto stateConfig = KSharedConfig::openStateConfig(); + stateConfig->group(QStringLiteral("General")).writeEntry(QStringLiteral("CurrentProfile"), value); + stateConfig->sync(); +} + Config *LauncherSettings::config() { return m_config;