From f1b68bc1b4979c14fbf6fd8ee0a0418364391dfe Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 4 May 2025 19:27:52 -0400 Subject: [PATCH] Save settings under more circumstances --- launcher/ui/Settings/AccountSettings.qml | 90 +++++++++++++++++----- launcher/ui/Settings/DeveloperSettings.qml | 25 ++++-- launcher/ui/Settings/GeneralSettings.qml | 15 +++- launcher/ui/Settings/ProfileSettings.qml | 65 ++++++++++++---- launcher/ui/Settings/SyncSettings.qml | 5 +- 5 files changed, 160 insertions(+), 40 deletions(-) diff --git a/launcher/ui/Settings/AccountSettings.qml b/launcher/ui/Settings/AccountSettings.qml index da2053c..5d36434 100644 --- a/launcher/ui/Settings/AccountSettings.qml +++ b/launcher/ui/Settings/AccountSettings.qml @@ -73,7 +73,10 @@ FormCard.FormCardPage { label: i18n("Username") text: page.account.config.name - onTextChanged: page.account.config.name = text + onTextChanged: { + page.account.config.name = text; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -88,7 +91,10 @@ FormCard.FormCardPage { description: i18n("The language used in the game client.") model: ["Japanese", "English", "German", "French"] currentIndex: page.account.config.language - onCurrentIndexChanged: page.account.config.language = currentIndex + onCurrentIndexChanged: { + page.account.config.language = currentIndex; + page.account.config.save(); + } } } @@ -105,7 +111,10 @@ FormCard.FormCardPage { description: i18n("If the account holds multiple licenses, choose the preferred one.") model: ["Windows", "Steam", "macOS"] currentIndex: page.account.config.license - onCurrentIndexChanged: page.account.config.license = currentIndex + onCurrentIndexChanged: { + page.account.config.license = currentIndex; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -118,7 +127,10 @@ FormCard.FormCardPage { text: i18n("Free trial") description: i18n("If the account has a free trial license.") checked: page.account.config.isFreeTrial - onCheckedChanged: page.account.config.isFreeTrial = checked + onCheckedChanged: { + page.account.config.isFreeTrial = checked; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -132,7 +144,10 @@ FormCard.FormCardPage { text: i18n("Needs a one-time password") description: i18n("Prompt for the one-time password when logging in.") checked: page.account.config.useOTP - onCheckedChanged: page.account.config.useOTP = checked + onCheckedChanged: { + page.account.config.useOTP = checked; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -152,7 +167,10 @@ FormCard.FormCardPage { standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel parent: page - onAccepted: page.account.config.lodestoneId = lodestoneIdField.text + onAccepted: { + page.account.config.lodestoneId = lodestoneIdField.text; + page.account.config.save(); + } QQC2.TextField { id: lodestoneIdField @@ -177,7 +195,10 @@ FormCard.FormCardPage { text: i18n("Remember password") description: i18n("Stores the password on the device, using it's existing secure credential storage.") checked: page.account.config.rememberPassword - onCheckedChanged: page.account.config.rememberPassword = checked + onCheckedChanged: { + page.account.config.rememberPassword = checked; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -192,7 +213,10 @@ FormCard.FormCardPage { 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.config.rememberOTP - onCheckedChanged: page.account.config.rememberOTP = checked + onCheckedChanged: { + page.account.config.rememberOTP = checked; + page.account.config.save(); + } enabled: page.account.config.useOTP } @@ -240,7 +264,10 @@ FormCard.FormCardPage { label: i18n("Preferred Protocol") text: page.account.config.preferredProtocol - onTextChanged: page.account.config.preferredProtocol = text + onTextChanged: { + page.account.config.preferredProtocol = text; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -254,7 +281,10 @@ FormCard.FormCardPage { label: i18n("Old Server") text: page.account.config.oldServer placeholderText: "ffxiv.com" - onTextChanged: page.account.config.oldServer = text + onTextChanged: { + page.account.config.oldServer = text; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -268,7 +298,10 @@ FormCard.FormCardPage { label: i18n("Login Server") text: page.account.config.loginServer placeholderText: "square-enix.com" - onTextChanged: page.account.config.loginServer = text + onTextChanged: { + page.account.config.loginServer = text; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -282,7 +315,10 @@ FormCard.FormCardPage { label: i18n("New Server") text: page.account.config.newServer placeholderText: "finalfantasyxiv.com" - onTextChanged: page.account.config.newServer = text + onTextChanged: { + page.account.config.newServer = text; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -296,7 +332,10 @@ FormCard.FormCardPage { label: i18n("Lobby Server") text: page.account.config.lobbyServer placeholderText: i18nc("@info:placeholder", "(Default value in client)") - onTextChanged: page.account.config.lobbyServer = text + onTextChanged: { + page.account.config.lobbyServer = text; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -309,7 +348,10 @@ FormCard.FormCardPage { label: i18n("Lobby Port") value: page.account.config.lobbyPort - onValueChanged: page.account.config.lobbyPort = value + onValueChanged: { + page.account.config.lobbyPort = value; + page.account.config.save(); + } from: 0 to: 999999 } @@ -325,7 +367,10 @@ FormCard.FormCardPage { label: i18n("Frontier Server") text: page.account.config.frontierServer placeholderText: i18nc("@info:placeholder", "(Default value in client)") - onTextChanged: page.account.config.frontierServer = text + onTextChanged: { + page.account.config.frontierServer = text; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -339,7 +384,10 @@ FormCard.FormCardPage { label: i18n("Save Data Bank Server") text: page.account.config.saveDataBankServer placeholderText: i18nc("@info:placeholder", "(Default value in client)") - onTextChanged: page.account.config.saveDataBankServer = text + onTextChanged: { + page.account.config.saveDataBankServer = text; + page.account.config.save(); + } } FormCard.FormDelegateSeparator { @@ -352,7 +400,10 @@ FormCard.FormCardPage { label: i18n("Save Data Bank Port") value: page.account.config.saveDataBankPort - onValueChanged: page.account.config.saveDataBankPort = value + onValueChanged: { + page.account.config.saveDataBankPort = value; + page.account.config.save(); + } from: 0 to: 999999 } @@ -368,7 +419,10 @@ FormCard.FormCardPage { label: i18n("Data Center Travel Server") text: page.account.config.dataCenterTravelServer placeholderText: i18nc("@info:placeholder", "(Default value in client)") - onTextChanged: page.account.config.dataCenterTravelServer = text + onTextChanged: { + page.account.config.dataCenterTravelServer = text; + page.account.config.save(); + } } } diff --git a/launcher/ui/Settings/DeveloperSettings.qml b/launcher/ui/Settings/DeveloperSettings.qml index 44e33f0..893488a 100644 --- a/launcher/ui/Settings/DeveloperSettings.qml +++ b/launcher/ui/Settings/DeveloperSettings.qml @@ -29,7 +29,10 @@ FormCard.FormCardPage { text: i18n("Keep Patches") description: i18n("Do not delete patches after they're used. Astra will not download patch data, if found.") checked: LauncherCore.config.keepPatches - onCheckedChanged: LauncherCore.config.keepPatches = checked + onCheckedChanged: { + LauncherCore.config.keepPatches = checked; + LauncherCore.config.save(); + } } } @@ -60,7 +63,10 @@ FormCard.FormCardPage { text: i18n("Encrypt Game Arguments") description: i18n("Disable encryption if you want to inspect the raw arguments passed to the game.") checked: LauncherCore.config.encryptArguments - onCheckedChanged: LauncherCore.config.encryptArguments = checked + onCheckedChanged: { + LauncherCore.config.encryptArguments = checked; + LauncherCore.config.save(); + } } FormCard.FormDelegateSeparator { @@ -74,7 +80,10 @@ FormCard.FormCardPage { text: i18n("Allow RenderDoc Capture") description: i18n("Inject the RenderDoc capture layer.") checked: LauncherCore.config.enableRenderDocCapture - onCheckedChanged: LauncherCore.config.enableRenderDocCapture = checked + onCheckedChanged: { + LauncherCore.config.enableRenderDocCapture = checked; + LauncherCore.config.save(); + } } } @@ -90,7 +99,10 @@ FormCard.FormCardPage { label: i18n("Preferred Protocol") text: LauncherCore.config.preferredProtocol - onTextChanged: LauncherCore.config.preferredProtocol = text + onTextChanged: { + LauncherCore.config.preferredProtocol = text; + LauncherCore.config.save(); + } } FormCard.FormDelegateSeparator { @@ -103,7 +115,10 @@ FormCard.FormCardPage { label: i18n("Dalamud Distribution Server") text: LauncherCore.config.dalamudDistribServer - onTextChanged: LauncherCore.config.dalamudDistribServer = text + onTextChanged: { + LauncherCore.config.dalamudDistribServer = text; + LauncherCore.config.save(); + } } } } diff --git a/launcher/ui/Settings/GeneralSettings.qml b/launcher/ui/Settings/GeneralSettings.qml index 27ee1c1..873900a 100644 --- a/launcher/ui/Settings/GeneralSettings.qml +++ b/launcher/ui/Settings/GeneralSettings.qml @@ -26,7 +26,10 @@ FormCard.FormCardPage { text: i18n("Hide Astra when game is launched") checked: LauncherCore.config.closeWhenLaunched - onCheckedChanged: LauncherCore.config.closeWhenLaunched = checked + onCheckedChanged: { + LauncherCore.config.closeWhenLaunched = checked; + LauncherCore.config.save(); + } } FormCard.FormDelegateSeparator { @@ -40,7 +43,10 @@ FormCard.FormCardPage { text: i18n("Show Developer Settings") description: i18n("Enable settings that are useful for developers and tinkerers.") checked: LauncherCore.config.showDevTools - onCheckedChanged: LauncherCore.config.showDevTools = checked + onCheckedChanged: { + LauncherCore.config.showDevTools = checked; + LauncherCore.config.save(); + } } FormCard.FormDelegateSeparator { @@ -54,7 +60,10 @@ FormCard.FormCardPage { text: i18n("Screenshots Folder") folder: LauncherCore.config.screenshotDir - onAccepted: (folder) => LauncherCore.config.screenshotDir = folder + onAccepted: (folder) => { + LauncherCore.config.screenshotDir = folder; + LauncherCore.config.save(); + } } } diff --git a/launcher/ui/Settings/ProfileSettings.qml b/launcher/ui/Settings/ProfileSettings.qml index 34ec417..5a7b5a9 100644 --- a/launcher/ui/Settings/ProfileSettings.qml +++ b/launcher/ui/Settings/ProfileSettings.qml @@ -69,7 +69,10 @@ FormCard.FormCardPage { label: i18n("Name") text: page.profile.config.name - onTextChanged: page.profile.config.name = text + onTextChanged: { + page.profile.config.name = text; + page.profile.config.save(); + } } FormCard.FormDelegateSeparator { @@ -83,7 +86,10 @@ FormCard.FormCardPage { text: i18n("Game Folder") folder: page.profile.config.gamePath - onAccepted: (folder) => page.profile.config.gamePath = folder + onAccepted: (folder) => { + page.profile.config.gamePath = folder; + page.profile.config.save(); + } } FormCard.FormDelegateSeparator { @@ -97,7 +103,10 @@ FormCard.FormCardPage { text: i18n("DirectX Version") model: ["DirectX 11", "DirectX 9"] currentIndex: page.profile.config.directx9Enabled ? 1 : 0 - onCurrentIndexChanged: page.profile.config.directx9Enabled = (currentIndex === 1) + onCurrentIndexChanged: { + page.profile.config.directx9Enabled = (currentIndex === 1); + page.profile.config.save(); + } visible: page.profile.hasDirectx9 } @@ -112,7 +121,10 @@ FormCard.FormCardPage { text: i18n("Allow Updating") description: i18n("If unchecked, Astra won't try to update the game automatically.") checked: page.profile.config.allowPatching - onCheckedChanged: page.profile.config.allowPatching = checked + onCheckedChanged: { + page.profile.config.allowPatching = checked; + page.profile.config.save(); + } visible: LauncherCore.config.showDevTools } @@ -138,7 +150,10 @@ FormCard.FormCardPage { text: i18n("Wine Type") model: [i18n("Built-in"), i18n("Custom")] currentIndex: page.profile.config.wineType - onCurrentIndexChanged: page.profile.config.wineType = currentIndex + onCurrentIndexChanged: { + page.profile.config.wineType = currentIndex; + page.profile.config.save(); + } } FormCard.FormDelegateSeparator { @@ -153,7 +168,10 @@ FormCard.FormCardPage { file: page.profile.winePath visible: page.profile.config.wineType !== Profile.BuiltIn - onAccepted: (path) => page.profile.winePath = path + onAccepted: (path) => { + page.profile.winePath = path; + page.profile.config.save(); + } } FormCard.FormDelegateSeparator { @@ -190,7 +208,10 @@ FormCard.FormCardPage { text: i18n("Enable Dalamud") description: i18n("Dalamud extends the game with useful plugins, but use at your own risk.") checked: page.profile.config.dalamudEnabled - onCheckedChanged: page.profile.config.dalamudEnabled = checked + onCheckedChanged: { + page.profile.config.dalamudEnabled = checked; + page.profile.config.save(); + } } FormCard.FormDelegateSeparator { @@ -204,7 +225,10 @@ FormCard.FormCardPage { text: i18n("Update Channel") model: LauncherCore.config.showDevTools ? [i18n("Stable"), i18n("Staging"), i18n("Local")] : [i18n("Stable"), i18n("Staging")] currentIndex: page.profile.config.dalamudChannel - onCurrentIndexChanged: page.profile.config.dalamudChannel = currentIndex + onCurrentIndexChanged: { + page.profile.config.dalamudChannel = currentIndex; + page.profile.config.save(); + } enabled: page.profile.config.dalamudEnabled } @@ -222,7 +246,10 @@ FormCard.FormCardPage { description: "It shouldn't be necessary to change this setting, unless you're running into issues injecting Dalamud." model: ["Entrypoint", "DLL Injection"] currentIndex: page.profile.config.dalamudInjectMethod - onCurrentIndexChanged: page.profile.config.dalamudInjectMethod = currentIndex + onCurrentIndexChanged: { + page.profile.config.dalamudInjectMethod = currentIndex; + page.profile.config.save(); + } enabled: page.profile.config.dalamudEnabled } @@ -237,7 +264,10 @@ FormCard.FormCardPage { visible: LauncherCore.config.showDevTools label: i18n("Injection Delay") value: page.profile.config.dalamudInjectDelay - onValueChanged: page.profile.config.dalamudInjectDelay = value + onValueChanged: { + page.profile.config.dalamudInjectDelay = value; + page.profile.config.save(); + } enabled: page.profile.config.dalamudEnabled } @@ -261,7 +291,10 @@ FormCard.FormCardPage { label: i18n("Platform") text: page.profile.config.platform - onTextChanged: page.profile.config.platform = text + onTextChanged: { + page.profile.config.platform = text; + page.profile.config.save(); + } } FormCard.FormDelegateSeparator { @@ -274,7 +307,10 @@ FormCard.FormCardPage { label: i18n("Boot Update Channel") text: page.profile.config.bootUpdateChannel - onTextChanged: page.profile.config.bootUpdateChannel = text + onTextChanged: { + page.profile.config.bootUpdateChannel = text; + page.profile.config.save(); + } } FormCard.FormDelegateSeparator { @@ -287,7 +323,10 @@ FormCard.FormCardPage { label: i18n("Game Update Channel") text: page.profile.config.gameUpdateChannel - onTextChanged: page.profile.config.gameUpdateChannel = text + onTextChanged: { + page.profile.config.gameUpdateChannel = text; + page.profile.config.save(); + } } } diff --git a/launcher/ui/Settings/SyncSettings.qml b/launcher/ui/Settings/SyncSettings.qml index 90cc103..37ae34c 100644 --- a/launcher/ui/Settings/SyncSettings.qml +++ b/launcher/ui/Settings/SyncSettings.qml @@ -39,7 +39,10 @@ FormCard.FormCardPage { text: i18n("Enable Sync") description: i18n("Syncing will occur before login, and after the game exits.") checked: LauncherCore.config.enableSync - onCheckedChanged: LauncherCore.config.enableSync = checked + onCheckedChanged: { + LauncherCore.config.enableSync = checked + LauncherCore.config.save(); + } } }