diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 4f1b292..25704a8 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -90,10 +90,10 @@ target_link_libraries(astra_static PUBLIC QCoro::Core QCoro::Network QCoro::Qml) -kconfig_target_kcfg_file(astra_static FILE config.kcfg CLASS_NAME Config MUTATORS GENERATE_PROPERTIES GENERATE_MOC DEFAULT_VALUE_GETTERS PARENT_IN_CONSTRUCTOR QML_REGISTRATION QML_UNCREATABLE) -kconfig_target_kcfg_file(astra_static FILE accountconfig.kcfg CLASS_NAME AccountConfig MUTATORS GENERATE_PROPERTIES GENERATE_MOC DEFAULT_VALUE_GETTERS PARENT_IN_CONSTRUCTOR QML_REGISTRATION QML_UNCREATABLE) +kconfig_target_kcfg_file(astra_static FILE config.kcfg CLASS_NAME Config MUTATORS GENERATE_PROPERTIES GENERATE_MOC DEFAULT_VALUE_GETTERS PARENT_IN_CONSTRUCTOR QML_REGISTRATION QML_UNCREATABLE USE_ENUM_TYPES) +kconfig_target_kcfg_file(astra_static FILE accountconfig.kcfg CLASS_NAME AccountConfig MUTATORS GENERATE_PROPERTIES GENERATE_MOC DEFAULT_VALUE_GETTERS PARENT_IN_CONSTRUCTOR QML_REGISTRATION QML_UNCREATABLE USE_ENUM_TYPES) kconfig_target_kcfg_file(astra_static FILE profileconfig.kcfg CLASS_NAME ProfileConfig MUTATORS GENERATE_PROPERTIES GENERATE_MOC DEFAULT_VALUE_GETTERS PARENT_IN_CONSTRUCTOR QML_REGISTRATION QML_UNCREATABLE) -target_include_directories(astra_static PUBLIC include ${CMAKE_BINARY_DIR}) +target_include_directories(astra_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}) if (NOT MSVC) target_compile_options(astra_static PUBLIC -fexceptions) diff --git a/launcher/accountconfig.kcfg b/launcher/accountconfig.kcfg index 700b7a7..f068a05 100644 --- a/launcher/accountconfig.kcfg +++ b/launcher/accountconfig.kcfg @@ -11,6 +11,7 @@ SPDX-License-Identifier: CC0-1.0 + account.h @@ -50,7 +51,7 @@ SPDX-License-Identifier: CC0-1.0 false - + diff --git a/launcher/include/account.h b/launcher/include/account.h index e0709c4..e052208 100644 --- a/launcher/include/account.h +++ b/launcher/include/account.h @@ -6,7 +6,7 @@ #include #include -#include "accountconfig.h" +class AccountConfig; class Account : public QObject { @@ -14,59 +14,24 @@ class Account : public QObject QML_ELEMENT QML_UNCREATABLE("Use from AccountManager") - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(int language READ language WRITE setLanguage NOTIFY languageChanged) - Q_PROPERTY(QString lodestoneId READ lodestoneId WRITE setLodestoneId NOTIFY lodestoneIdChanged) + Q_PROPERTY(AccountConfig *config READ config CONSTANT) Q_PROPERTY(QString avatarUrl READ avatarUrl NOTIFY avatarUrlChanged) - Q_PROPERTY(bool isSapphire READ isSapphire WRITE setIsSapphire NOTIFY isSapphireChanged) - Q_PROPERTY(QString lobbyUrl READ lobbyUrl WRITE setLobbyUrl NOTIFY lobbyUrlChanged) - Q_PROPERTY(bool rememberPassword READ rememberPassword WRITE setRememberPassword NOTIFY rememberPasswordChanged) - Q_PROPERTY(bool rememberOTP READ rememberOTP WRITE setRememberOTP NOTIFY rememberOTPChanged) - Q_PROPERTY(bool useOTP READ useOTP WRITE setUseOTP NOTIFY useOTPChanged) - Q_PROPERTY(GameLicense license READ license WRITE setLicense NOTIFY licenseChanged) - Q_PROPERTY(bool isFreeTrial READ isFreeTrial WRITE setIsFreeTrial NOTIFY isFreeTrialChanged) Q_PROPERTY(bool needsPassword READ needsPassword NOTIFY needsPasswordChanged) public: explicit Account(const QString &key, QObject *parent = nullptr); - enum class GameLicense { WindowsStandalone, WindowsSteam, macOS }; + enum GameLicense { + WindowsStandalone, + WindowsSteam, + macOS + }; Q_ENUM(GameLicense) [[nodiscard]] QString uuid() const; - [[nodiscard]] QString name() const; - void setName(const QString &name); - - [[nodiscard]] int language() const; - void setLanguage(int value); - - [[nodiscard]] QString lodestoneId() const; - void setLodestoneId(const QString &id); - [[nodiscard]] QString avatarUrl() const; - [[nodiscard]] bool isSapphire() const; - void setIsSapphire(bool value); - - [[nodiscard]] QString lobbyUrl() const; - void setLobbyUrl(const QString &url); - - [[nodiscard]] bool rememberPassword() const; - void setRememberPassword(bool value); - - [[nodiscard]] bool rememberOTP() const; - void setRememberOTP(bool value); - - [[nodiscard]] bool useOTP() const; - void setUseOTP(bool value); - - [[nodiscard]] GameLicense license() const; - void setLicense(GameLicense license); - - [[nodiscard]] bool isFreeTrial() const; - void setIsFreeTrial(bool value); - Q_INVOKABLE QString getPassword(); void setPassword(const QString &password); @@ -81,18 +46,10 @@ public: [[nodiscard]] bool needsPassword() const; + AccountConfig *config() const; + Q_SIGNALS: - void nameChanged(); - void languageChanged(); - void lodestoneIdChanged(); void avatarUrlChanged(); - void isSapphireChanged(); - void lobbyUrlChanged(); - void rememberPasswordChanged(); - void rememberOTPChanged(); - void useOTPChanged(); - void licenseChanged(); - void isFreeTrialChanged(); bool needsPasswordChanged(); private: @@ -108,8 +65,8 @@ private: */ QCoro::Task getKeychainValue(const QString &key); - AccountConfig m_config; + AccountConfig *m_config; QString m_key; QString m_avatarUrl; bool m_needsPassword = false; -}; \ No newline at end of file +}; diff --git a/launcher/src/account.cpp b/launcher/src/account.cpp index 812793c..74c730e 100644 --- a/launcher/src/account.cpp +++ b/launcher/src/account.cpp @@ -7,6 +7,7 @@ #include #include +#include "accountconfig.h" #include "astra_log.h" #include "utility.h" @@ -14,7 +15,7 @@ using namespace Qt::StringLiterals; Account::Account(const QString &key, QObject *parent) : QObject(parent) - , m_config(key) + , m_config(new AccountConfig(key)) , m_key(key) { fetchPassword(); @@ -25,151 +26,11 @@ QString Account::uuid() const return m_key; } -QString Account::name() const -{ - return m_config.name(); -} - -void Account::setName(const QString &name) -{ - if (m_config.name() != name) { - m_config.setName(name); - m_config.save(); - Q_EMIT nameChanged(); - } -} - -int Account::language() const -{ - return m_config.language(); -} - -void Account::setLanguage(const int value) -{ - if (m_config.language() != value) { - m_config.setLanguage(value); - m_config.save(); - Q_EMIT languageChanged(); - } -} - -QString Account::lodestoneId() const -{ - return m_config.lodestoneId(); -} - -void Account::setLodestoneId(const QString &id) -{ - if (m_config.lodestoneId() != id) { - m_config.setLodestoneId(id); - m_config.save(); - Q_EMIT lodestoneIdChanged(); - } -} - QString Account::avatarUrl() const { return m_avatarUrl; } -bool Account::isSapphire() const -{ - return m_config.isSapphire(); -} - -void Account::setIsSapphire(const bool value) -{ - if (m_config.isSapphire() != value) { - m_config.setIsSapphire(value); - m_config.save(); - Q_EMIT isSapphireChanged(); - } -} - -QString Account::lobbyUrl() const -{ - return m_config.lobbyUrl(); -} - -void Account::setLobbyUrl(const QString &url) -{ - if (m_config.lobbyUrl() != url) { - m_config.setLobbyUrl(url); - m_config.save(); - Q_EMIT lobbyUrlChanged(); - } -} - -bool Account::rememberPassword() const -{ - return m_config.rememberPassword(); -} - -void Account::setRememberPassword(const bool value) -{ - if (m_config.rememberPassword() != value) { - m_config.setRememberPassword(value); - m_config.save(); - Q_EMIT rememberPasswordChanged(); - } -} - -bool Account::rememberOTP() const -{ - return m_config.rememberOTP(); -} - -void Account::setRememberOTP(const bool value) -{ - if (m_config.rememberOTP() != value) { - m_config.setRememberOTP(value); - m_config.save(); - Q_EMIT rememberOTPChanged(); - } -} - -bool Account::useOTP() const -{ - return m_config.useOTP(); -} - -void Account::setUseOTP(const bool value) -{ - if (m_config.useOTP() != value) { - m_config.setUseOTP(value); - m_config.save(); - Q_EMIT useOTPChanged(); - } -} - -Account::GameLicense Account::license() const -{ - return static_cast(m_config.license()); -} - -void Account::setLicense(const GameLicense license) -{ - if (static_cast(m_config.license()) != license) { - m_config.setLicense(static_cast(license)); - m_config.save(); - Q_EMIT licenseChanged(); - } -} - -bool Account::isFreeTrial() const -{ - return m_config.isFreeTrial(); -} - -void Account::setIsFreeTrial(const bool value) -{ - if (m_config.isFreeTrial() != value) { - m_config.setIsFreeTrial(value); - m_config.save(); - Q_EMIT isFreeTrialChanged(); - } -} - QString Account::getPassword() { return QCoro::waitFor(getKeychainValue(QStringLiteral("password"))); @@ -291,4 +152,9 @@ QCoro::Task<> Account::fetchPassword() co_return; } -#include "moc_account.cpp" \ No newline at end of file +AccountConfig *Account::config() const +{ + return m_config; +} + +#include "moc_account.cpp" diff --git a/launcher/src/accountmanager.cpp b/launcher/src/accountmanager.cpp index 4005850..0f49681 100644 --- a/launcher/src/accountmanager.cpp +++ b/launcher/src/accountmanager.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "accountmanager.h" +#include "accountconfig.h" #include "astra_log.h" #include @@ -57,10 +58,10 @@ QHash AccountManager::roleNames() const Account *AccountManager::createSquareEnixAccount(const QString &username, const int licenseType, const bool isFreeTrial) { const auto account = new Account(QUuid::createUuid().toString(), this); - account->setIsSapphire(false); - account->setLicense(static_cast(licenseType)); - account->setIsFreeTrial(isFreeTrial); - account->setName(username); + account->config()->setIsSapphire(false); + account->config()->setLicense(static_cast(licenseType)); + account->config()->setIsFreeTrial(isFreeTrial); + account->config()->setName(username); insertAccount(account); @@ -70,9 +71,9 @@ Account *AccountManager::createSquareEnixAccount(const QString &username, const Account *AccountManager::createSapphireAccount(const QString &lobbyUrl, const QString &username) { const auto account = new Account(QUuid::createUuid().toString(), this); - account->setIsSapphire(true); - account->setName(username); - account->setLobbyUrl(lobbyUrl); + account->config()->setIsSapphire(true); + account->config()->setName(username); + account->config()->setLobbyUrl(lobbyUrl); insertAccount(account); diff --git a/launcher/src/gamerunner.cpp b/launcher/src/gamerunner.cpp index 03af062..fe3b907 100644 --- a/launcher/src/gamerunner.cpp +++ b/launcher/src/gamerunner.cpp @@ -7,6 +7,7 @@ #include #endif +#include "accountconfig.h" #include "astra_log.h" #include "encryptedarg.h" #include "launchercore.h" @@ -156,7 +157,7 @@ void GameRunner::beginDalamudGame(const QString &gameExecutablePath, Profile &pr QStringLiteral("--dalamud-configuration-path=") + Utility::toWindowsPath(dalamudConfigPath), QStringLiteral("--dalamud-plugin-directory=") + Utility::toWindowsPath(dalamudPluginDir), QStringLiteral("--dalamud-asset-directory=") + Utility::toWindowsPath(dalamudAssetDir), - QStringLiteral("--dalamud-client-language=") + QString::number(profile.account()->language()), + QStringLiteral("--dalamud-client-language=") + QString::number(profile.account()->config()->language()), QStringLiteral("--dalamud-delay-initialize=") + QString::number(profile.dalamudInjectDelay()), QStringLiteral("--logpath=") + Utility::toWindowsPath(logDir), QStringLiteral("--"), @@ -206,7 +207,7 @@ QString GameRunner::getGameArgs(const Profile &profile, const std::optionallanguage())}); + gameArgs.push_back({QStringLiteral("language"), QString::number(profile.account()->config()->language())}); gameArgs.push_back({QStringLiteral("UserPath"), Utility::toWindowsPath(profile.account()->getConfigDir().absolutePath())}); Utility::createPathIfNeeded(profile.account()->getConfigDir().absolutePath()); @@ -236,7 +237,7 @@ QString GameRunner::getGameArgs(const Profile &profile, const std::optionallicense() == Account::GameLicense::WindowsSteam) { + if (profile.account()->config()->license() == Account::GameLicense::WindowsSteam) { gameArgs.push_back({QStringLiteral("IsSteam"), QString::number(1)}); } } @@ -260,7 +261,7 @@ void GameRunner::launchExecutable(const Profile &profile, QProcess *process, con #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) // FFXIV detects this as a "macOS" build by checking if Wine shows up if (!profile.isBenchmark()) { - const int value = profile.account()->license() == Account::GameLicense::macOS ? 0 : 1; + const int value = profile.account()->config()->license() == Account::GameLicense::macOS ? 0 : 1; addRegistryKey(profile, QStringLiteral("HKEY_CURRENT_USER\\Software\\Wine"), QStringLiteral("HideWineExports"), QString::number(value)); } @@ -348,7 +349,7 @@ void GameRunner::launchExecutable(const Profile &profile, QProcess *process, con arguments.push_back(profile.winePath()); #endif - if (!profile.isBenchmark() && profile.account()->license() == Account::GameLicense::WindowsSteam) { + if (!profile.isBenchmark() && profile.account()->config()->license() == Account::GameLicense::WindowsSteam) { env.insert(QStringLiteral("IS_FFXIV_LAUNCH_FROM_STEAM"), QStringLiteral("1")); } diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index 7d0108d..263bd65 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -12,6 +12,7 @@ #include #include "account.h" +#include "accountconfig.h" #include "assetupdater.h" #include "astra_log.h" #include "benchmarkinstaller.h" @@ -100,7 +101,7 @@ void LauncherCore::login(Profile *profile, const QString &username, const QStrin loginInformation->password = password; loginInformation->oneTimePassword = oneTimePassword; - if (profile->account()->rememberPassword()) { + if (profile->account()->config()->rememberPassword()) { profile->account()->setPassword(password); } } @@ -113,8 +114,8 @@ bool LauncherCore::autoLogin(Profile *profile) Q_ASSERT(profile != nullptr); QString otp; - if (profile->account()->useOTP()) { - if (!profile->account()->rememberOTP()) { + if (profile->account()->config()->useOTP()) { + if (!profile->account()->config()->rememberOTP()) { Q_EMIT loginError(i18n("This account does not have an OTP secret set, but requires it for login.")); return false; } @@ -126,7 +127,7 @@ bool LauncherCore::autoLogin(Profile *profile) } } - login(profile, profile->account()->name(), profile->account()->getPassword(), otp); + login(profile, profile->account()->config()->name(), profile->account()->getPassword(), otp); return true; } @@ -172,21 +173,21 @@ BenchmarkInstaller *LauncherCore::createBenchmarkInstallerFromExisting(Profile * void LauncherCore::fetchAvatar(Account *account) { - if (account->lodestoneId().isEmpty()) { + if (account->config()->lodestoneId().isEmpty()) { return; } const QString cacheLocation = QStandardPaths::standardLocations(QStandardPaths::CacheLocation)[0] + QStringLiteral("/avatars"); Utility::createPathIfNeeded(cacheLocation); - const QString filename = QStringLiteral("%1/%2.jpg").arg(cacheLocation, account->lodestoneId()); + const QString filename = QStringLiteral("%1/%2.jpg").arg(cacheLocation, account->config()->lodestoneId()); if (!QFile(filename).exists()) { - qDebug(ASTRA_LOG) << "Did not find lodestone character " << account->lodestoneId() << " in cache, fetching from Lodestone."; + qDebug(ASTRA_LOG) << "Did not find lodestone character " << account->config()->lodestoneId() << " in cache, fetching from Lodestone."; QUrl url; url.setScheme(config()->preferredProtocol()); url.setHost(QStringLiteral("na.%1").arg(config()->mainServer())); // TODO: NA isnt the only thing in the world... - url.setPath(QStringLiteral("/lodestone/character/%1").arg(account->lodestoneId())); + url.setPath(QStringLiteral("/lodestone/character/%1").arg(account->config()->lodestoneId())); const QNetworkRequest request(url); Utility::printRequest(QStringLiteral("GET"), request); @@ -347,7 +348,7 @@ void LauncherCore::buildRequest(const Profile &settings, QNetworkRequest &reques { Utility::setSSL(request); - if (settings.account()->license() == Account::GameLicense::macOS) { + if (settings.account()->config()->license() == Account::GameLicense::macOS) { request.setHeader(QNetworkRequest::UserAgentHeader, QByteArrayLiteral("macSQEXAuthor/2.0.0(MacOSX; ja-jp)")); } else { request.setHeader(QNetworkRequest::UserAgentHeader, @@ -468,8 +469,8 @@ QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info) std::optional auth; if (!info.profile->isBenchmark()) { - if (info.profile->account()->isSapphire()) { - auth = co_await m_sapphireLogin->login(info.profile->account()->lobbyUrl(), info); + if (info.profile->account()->config()->isSapphire()) { + auth = co_await m_sapphireLogin->login(info.profile->account()->config()->lobbyUrl(), info); } else { auth = co_await m_squareEnixLogin->login(&info); } diff --git a/launcher/src/squareenixlogin.cpp b/launcher/src/squareenixlogin.cpp index 725ded6..63f8d8f 100644 --- a/launcher/src/squareenixlogin.cpp +++ b/launcher/src/squareenixlogin.cpp @@ -14,6 +14,7 @@ #include #include "account.h" +#include "accountconfig.h" #include "astra_log.h" #include "launchercore.h" #include "utility.h" @@ -176,7 +177,7 @@ QCoro::Task SquareEnixLogin::checkBootUpdates() url.setQuery(query); auto request = QNetworkRequest(url); - if (m_info->profile->account()->license() == Account::GameLicense::macOS) { + if (m_info->profile->account()->config()->license() == Account::GameLicense::macOS) { request.setHeader(QNetworkRequest::KnownHeaders::UserAgentHeader, macosPatchUserAgent); } else { request.setHeader(QNetworkRequest::KnownHeaders::UserAgentHeader, patchUserAgent); @@ -225,12 +226,12 @@ QCoro::Task> SquareEnixLogin::getStor query.addQueryItem(QStringLiteral("lng"), QStringLiteral("en")); // for some reason, we always use region 3. the actual region is acquired later query.addQueryItem(QStringLiteral("rgn"), QString::number(3)); - query.addQueryItem(QStringLiteral("isft"), QString::number(m_info->profile->account()->isFreeTrial() ? 1 : 0)); + query.addQueryItem(QStringLiteral("isft"), QString::number(m_info->profile->account()->config()->isFreeTrial() ? 1 : 0)); query.addQueryItem(QStringLiteral("cssmode"), QString::number(1)); query.addQueryItem(QStringLiteral("isnew"), QString::number(1)); query.addQueryItem(QStringLiteral("launchver"), QString::number(3)); - if (m_info->profile->account()->license() == Account::GameLicense::WindowsSteam) { + if (m_info->profile->account()->config()->license() == Account::GameLicense::WindowsSteam) { query.addQueryItem(QStringLiteral("issteam"), QString::number(1)); // TODO: get steam ticket information from steam api @@ -255,7 +256,7 @@ QCoro::Task> SquareEnixLogin::getStor const QString str = QString::fromUtf8(reply->readAll()); // fetches Steam username - if (m_info->profile->account()->license() == Account::GameLicense::WindowsSteam) { + if (m_info->profile->account()->config()->license() == Account::GameLicense::WindowsSteam) { const static QRegularExpression re(QStringLiteral(R"lit(.*)""\/>)lit")); const QRegularExpressionMatch match = re.match(str); diff --git a/launcher/ui/Pages/LoginPage.qml b/launcher/ui/Pages/LoginPage.qml index eb2fe67..1f28b03 100644 --- a/launcher/ui/Pages/LoginPage.qml +++ b/launcher/ui/Pages/LoginPage.qml @@ -31,7 +31,7 @@ QQC2.Control { return i18n("Password is required."); } - if (LauncherCore.currentProfile.account.useOTP && !LauncherCore.currentProfile.account.rememberOTP && otpField.text.length === 0) { + if (LauncherCore.currentProfile.account.config.useOTP && !LauncherCore.currentProfile.account.config.rememberOTP && otpField.text.length === 0) { return i18n("OTP is required."); } @@ -55,7 +55,7 @@ QQC2.Control { return false; } - if (LauncherCore.currentProfile.account.useOTP && !LauncherCore.currentProfile.account.rememberOTP && otpField.text.length === 0) { + if (LauncherCore.currentProfile.account.config.useOTP && !LauncherCore.currentProfile.account.config.rememberOTP && otpField.text.length === 0) { return false; } @@ -63,9 +63,9 @@ QQC2.Control { } function updateFields(): void { - usernameField.text = LauncherCore.currentProfile.account.name; - passwordField.text = !LauncherCore.currentProfile.account.needsPassword && LauncherCore.currentProfile.account.rememberPassword ? LauncherCore.currentProfile.account.getPassword() : ""; - if (LauncherCore.currentProfile.account.rememberOTP) { + usernameField.text = LauncherCore.currentProfile.account.config.name; + passwordField.text = !LauncherCore.currentProfile.account.needsPassword && LauncherCore.currentProfile.account.config.rememberPassword ? LauncherCore.currentProfile.account.getPassword() : ""; + if (LauncherCore.currentProfile.account.config.rememberOTP) { otpField.text = "Auto-generated"; } else { otpField.text = ""; @@ -83,7 +83,7 @@ QQC2.Control { return; } - if (LauncherCore.currentProfile.account.useOTP) { + if (LauncherCore.currentProfile.account.config.useOTP) { otpField.forceActiveFocus(); return; } @@ -165,13 +165,13 @@ QQC2.Control { id: currentAccountDelegate enabled: LauncherCore.accountManager.numAccounts > 1 - text: LauncherCore.currentProfile.account.name + text: LauncherCore.currentProfile.account.config.name leading: Components.Avatar { implicitWidth: Kirigami.Units.iconSizes.medium implicitHeight: Kirigami.Units.iconSizes.medium - name: LauncherCore.currentProfile.account.name + name: LauncherCore.currentProfile.account.config.name source: LauncherCore.currentProfile.account.avatarUrl } @@ -191,7 +191,7 @@ QQC2.Control { required property var account QQC2.MenuItem { - text: menuItem.account.name + text: menuItem.account.config.name icon.name: menuItem.account.avatarUrl.length === 0 ? "actor" : "" icon.source: menuItem.account.avatarUrl @@ -214,8 +214,8 @@ QQC2.Control { FormCard.FormTextFieldDelegate { id: usernameField - label: LauncherCore.currentProfile.account.isSapphire ? i18n("Username") : i18n("Square Enix ID") - text: LauncherCore.currentProfile.account.name + label: LauncherCore.currentProfile.account.config.isSapphire ? i18n("Username") : i18n("Square Enix ID") + text: LauncherCore.currentProfile.account.config.name enabled: false QQC2.ToolTip.text: i18n("The username can only be changed under account settings.") @@ -230,7 +230,7 @@ QQC2.Control { FormCard.FormPasswordFieldDelegate { id: passwordField - label: LauncherCore.currentProfile.account.isSapphire ? i18n("Password") : i18n("Square Enix Password") + label: LauncherCore.currentProfile.account.config.isSapphire ? i18n("Password") : i18n("Square Enix Password") focus: true onAccepted: { if (otpField.visible) { @@ -243,15 +243,15 @@ QQC2.Control { FormCard.FormDelegateSeparator { above: passwordField - below: LauncherCore.currentProfile.account.useOTP ? otpField : loginButton + below: LauncherCore.currentProfile.account.config.useOTP ? otpField : loginButton } FormCard.FormTextFieldDelegate { id: otpField - enabled: !LauncherCore.currentProfile.account.rememberOTP + enabled: !LauncherCore.currentProfile.account.config.rememberOTP label: i18n("One-time Password") - visible: LauncherCore.currentProfile.account.useOTP + visible: LauncherCore.currentProfile.account.config.useOTP onAccepted: { if (page.isLoginValid) { loginButton.clicked() @@ -260,9 +260,9 @@ QQC2.Control { } FormCard.FormDelegateSeparator { - above: LauncherCore.currentProfile.account.useOTP ? otpField : passwordField + above: LauncherCore.currentProfile.account.config.useOTP ? otpField : passwordField below: loginButton - visible: LauncherCore.currentProfile.account.useOTP + visible: LauncherCore.currentProfile.account.config.useOTP } FormCard.FormButtonDelegate { @@ -281,7 +281,7 @@ QQC2.Control { FormCard.FormDelegateSeparator { above: loginButton below: forgotPasswordButton - visible: !LauncherCore.currentProfile.account.isSapphire + visible: !LauncherCore.currentProfile.account.config.isSapphire } FormCard.FormButtonDelegate { @@ -289,7 +289,7 @@ QQC2.Control { text: i18n("Forgot ID or Password") icon.name: "question-symbolic" - visible: !LauncherCore.currentProfile.account.isSapphire + visible: !LauncherCore.currentProfile.account.config.isSapphire onClicked: applicationWindow().openUrl('https://secure.square-enix.com/account/app/svc/reminder') } } @@ -325,7 +325,7 @@ QQC2.Control { FormCard.FormLinkDelegate { text: i18nc("@action:button", "The Lodestone") icon.name: "internet-services-symbolic" - visible: !LauncherCore.currentProfile.account.isSapphire + visible: !LauncherCore.currentProfile.account.config.isSapphire // TODO: how do we link to a "worldwide" lodestone, if that even exists? url: 'https://na.finalfantasyxiv.com/lodestone/' onClicked: applicationWindow().openUrl(url) @@ -336,7 +336,7 @@ QQC2.Control { FormCard.FormLinkDelegate { text: i18nc("@action:button", "Mog Station") icon.name: "internet-services-symbolic" - visible: !LauncherCore.currentProfile.account.isSapphire + visible: !LauncherCore.currentProfile.account.config.isSapphire url: 'https://secure.square-enix.com/account/app/svc/mogstation/' onClicked: applicationWindow().openUrl(url) } diff --git a/launcher/ui/Settings/AccountSettings.qml b/launcher/ui/Settings/AccountSettings.qml index 76d4195..14e7350 100644 --- a/launcher/ui/Settings/AccountSettings.qml +++ b/launcher/ui/Settings/AccountSettings.qml @@ -67,8 +67,8 @@ FormCard.FormCardPage { id: usernameDelegate label: i18n("Username") - text: page.account.name - onTextChanged: page.account.name = text + text: page.account.config.name + onTextChanged: page.account.config.name = text } FormCard.FormDelegateSeparator { @@ -81,8 +81,8 @@ FormCard.FormCardPage { text: i18n("Account type") model: ["Square Enix", "Sapphire"] - currentIndex: page.account.isSapphire ? 1 : 0 - onCurrentIndexChanged: page.account.isSapphire = (currentIndex === 1) + currentIndex: page.account.config.isSapphire ? 1 : 0 + onCurrentIndexChanged: page.account.config.isSapphire = (currentIndex === 1) } FormCard.FormDelegateSeparator { @@ -96,13 +96,13 @@ FormCard.FormCardPage { text: i18n("Language") description: i18n("The language used in the game client.") model: ["Japanese", "English", "German", "French"] - currentIndex: page.account.language - onCurrentIndexChanged: page.account.language = currentIndex + currentIndex: page.account.config.language + onCurrentIndexChanged: page.account.config.language = currentIndex } } FormCard.FormCard { - visible: accountAction.checked && !page.account.isSapphire + visible: accountAction.checked && !page.account.config.isSapphire Layout.fillWidth: true Layout.topMargin: Kirigami.Units.largeSpacing * 4 @@ -113,8 +113,8 @@ FormCard.FormCardPage { text: i18n("License") description: i18n("If the account holds multiple licenses, choose the preferred one.") model: ["Windows", "Steam", "macOS"] - currentIndex: page.account.license - onCurrentIndexChanged: page.account.license = currentIndex + currentIndex: page.account.config.license + onCurrentIndexChanged: page.account.config.license = currentIndex } FormCard.FormDelegateSeparator { @@ -126,8 +126,8 @@ FormCard.FormCardPage { id: freeTrialField text: i18n("Free trial") description: i18n("If the account has a free trial license.") - checked: page.account.isFreeTrial - onCheckedChanged: page.account.isFreeTrial = checked + checked: page.account.config.isFreeTrial + onCheckedChanged: page.account.config.isFreeTrial = checked } FormCard.FormDelegateSeparator { @@ -140,8 +140,8 @@ FormCard.FormCardPage { text: i18n("Needs a one-time password") description: i18n("Prompt for the one-time password when logging in.") - checked: page.account.useOTP - onCheckedChanged: page.account.useOTP = checked + checked: page.account.config.useOTP + onCheckedChanged: page.account.config.useOTP = checked } FormCard.FormDelegateSeparator { @@ -161,11 +161,11 @@ FormCard.FormCardPage { standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel - onAccepted: page.account.lodestoneId = lodestoneIdField.text + onAccepted: page.account.config.lodestoneId = lodestoneIdField.text QQC2.TextField { id: lodestoneIdField - text: page.account.lodestoneId + text: page.account.config.lodestoneId placeholderText: qsTr("123456...") } } @@ -175,7 +175,7 @@ FormCard.FormCardPage { } FormCard.FormCard { - visible: accountAction.checked && page.account.isSapphire + visible: accountAction.checked && page.account.config.isSapphire Layout.fillWidth: true Layout.topMargin: Kirigami.Units.largeSpacing * 4 @@ -184,9 +184,9 @@ FormCard.FormCardPage { id: lobbyURLDelegate label: i18n("Lobby URL") - text: page.account.lobbyUrl - onTextChanged: page.account.lobbyUrl = text - visible: page.account.isSapphire + text: page.account.config.lobbyUrl + onTextChanged: page.account.config.lobbyUrl = text + visible: page.account.config.isSapphire placeholderText: "neolobby0X.ffxiv.com" } } @@ -202,8 +202,8 @@ FormCard.FormCardPage { text: i18n("Remember password") description: i18n("Stores the password on the device, using it's existing secure credential storage.") - checked: page.account.rememberPassword - onCheckedChanged: page.account.rememberPassword = checked + checked: page.account.config.rememberPassword + onCheckedChanged: page.account.config.rememberPassword = checked } FormCard.FormDelegateSeparator { @@ -217,10 +217,10 @@ FormCard.FormCardPage { text: i18n("Automatically generate one-time passwords") description: i18n("Stores the one-time password secret on this device, making it inherently insecure. Only use this feature if you understand the risks.") - checked: page.account.rememberOTP - onCheckedChanged: page.account.rememberOTP = checked - enabled: page.account.useOTP - visible: !page.account.isSapphire + checked: page.account.config.rememberOTP + onCheckedChanged: page.account.config.rememberOTP = checked + enabled: page.account.config.useOTP + visible: !page.account.config.isSapphire } FormCard.FormDelegateSeparator { @@ -235,7 +235,7 @@ FormCard.FormCardPage { text: i18n("Enter OTP Secret") icon.name: "list-add-symbolic" - enabled: page.account.rememberOTP + enabled: page.account.config.rememberOTP visible: generateOTPField.visible Kirigami.PromptDialog { id: otpDialog diff --git a/launcher/ui/Settings/AccountsPage.qml b/launcher/ui/Settings/AccountsPage.qml index 860d08e..99d63c6 100644 --- a/launcher/ui/Settings/AccountsPage.qml +++ b/launcher/ui/Settings/AccountsPage.qml @@ -52,12 +52,12 @@ FormCard.FormCardPage { spacing: 0 FormCard.FormButtonDelegate { - text: layout.account.name - description: layout.account.isSapphire ? i18n("Sapphire") : i18n("Square Enix") + text: layout.account.config.name + description: layout.account.config.isSapphire ? i18n("Sapphire") : i18n("Square Enix") leading: Components.Avatar { - name: layout.account.name + name: layout.account.config.name source: layout.account.avatarUrl } diff --git a/launcher/ui/Setup/AccountSetup.qml b/launcher/ui/Setup/AccountSetup.qml index d2dbcbd..811517f 100644 --- a/launcher/ui/Setup/AccountSetup.qml +++ b/launcher/ui/Setup/AccountSetup.qml @@ -45,7 +45,7 @@ FormCard.FormCardPage { FormCard.FormButtonDelegate { required property var account - text: account.name + text: account.config.name onClicked: { page.profile.account = account @@ -91,4 +91,4 @@ FormCard.FormCardPage { }) } } -} \ No newline at end of file +}