2023-07-30 08:49:34 -04:00
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
2023-09-16 18:15:11 -04:00
import QtQuick
import QtQuick . Controls as QQC2
2023-09-20 16:44:43 -04:00
import QtQuick . Window
2023-09-16 18:15:11 -04:00
import QtQuick . Layouts
import org . kde . kirigami as Kirigami
import org . kde . kirigamiaddons . formcard as FormCard
import zone . xiv . astra
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormCardPage {
2023-07-30 08:49:34 -04:00
id: page
property var account
2023-09-20 15:30:50 -04:00
title: i18nc ( "@title:window" , "Edit Account" )
2023-07-30 08:49:34 -04:00
2024-03-26 17:42:52 -04:00
actions: [
2024-04-19 20:50:14 -04:00
Kirigami . Action {
text: i18n ( "Open User Folder…" )
tooltip: i18n ( "The user folder contains saved appearance data and character settings for this account." )
icon.name: "folder-open-symbolic"
onTriggered: Qt . openUrlExternally ( "file://" + page . account . getConfigPath ( ) )
} ,
2024-03-26 17:42:52 -04:00
Kirigami . Action {
2024-04-01 15:19:15 -04:00
text: i18n ( "Delete Account…" )
2024-03-26 17:42:52 -04:00
tooltip: ! enabled ? i18n ( "Cannot delete the only account." ) : ""
icon.name: "delete"
enabled: LauncherCore . accountManager . canDelete ( page . account )
onTriggered: deletePrompt . open ( )
}
]
2023-08-19 10:30:52 -04:00
FormCard . FormHeader {
title: i18n ( "General" )
}
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormCard {
Layout.fillWidth: true
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormTextFieldDelegate {
id: usernameDelegate
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
label: i18n ( "Username" )
text: page . account . name
onTextChanged: page . account . name = text
}
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormDelegateSeparator {
above: usernameDelegate
below: accountTypeDelegate
}
2023-08-18 22:36:33 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormComboBoxDelegate {
id: accountTypeDelegate
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
text: i18n ( "Account type" )
model: [ "Square Enix" , "Sapphire" ]
currentIndex: page . account . isSapphire ? 1 : 0
onCurrentIndexChanged: page . account . isSapphire = ( currentIndex === 1 )
}
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormDelegateSeparator {
above: accountTypeDelegate
2023-10-08 13:23:18 -04:00
below: languageDelegate
2023-08-19 10:30:52 -04:00
}
2023-07-30 08:49:34 -04:00
2023-10-08 13:23:18 -04:00
FormCard . FormComboBoxDelegate {
id: languageDelegate
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
}
}
FormCard . FormHeader {
title: i18n ( "Square Enix" )
visible: ! page . account . isSapphire
}
FormCard . FormCard {
visible: ! page . account . isSapphire
Layout.fillWidth: true
2023-08-19 10:30:52 -04:00
FormCard . FormComboBoxDelegate {
id: licenseField
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
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
}
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormDelegateSeparator {
above: licenseField
below: freeTrialField
}
2023-07-31 19:01:58 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormCheckDelegate {
id: freeTrialField
text: i18n ( "Free trial" )
2023-10-08 13:23:18 -04:00
description: i18n ( "If the account has a free trial license." )
2023-08-19 10:30:52 -04:00
checked: page . account . isFreeTrial
onCheckedChanged: page . account . isFreeTrial = checked
}
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormDelegateSeparator {
above: freeTrialField
below: needOTPField
}
FormCard . FormCheckDelegate {
id: needOTPField
text: i18n ( "Needs a one-time password" )
2023-10-08 13:23:18 -04:00
description: i18n ( "Prompt for the one-time password when logging in." )
2023-08-19 10:30:52 -04:00
checked: page . account . useOTP
onCheckedChanged: page . account . useOTP = checked
}
FormCard . FormDelegateSeparator {
above: needOTPField
below: lodestoneDelegate
}
2023-07-31 19:01:58 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormButtonDelegate {
id: lodestoneDelegate
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
text: i18n ( "Set Lodestone Character" )
2023-10-08 13:23:18 -04:00
description: i18n ( "Associate a character's avatar with this account for easier identification." )
2023-08-19 10:30:52 -04:00
icon.name: "actor"
Kirigami . PromptDialog {
id: lodestoneDialog
title: i18n ( "Enter Lodestone Id" )
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
standardButtons: Kirigami . Dialog . Ok | Kirigami . Dialog . Cancel
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
onAccepted: page . account . lodestoneId = lodestoneIdField . text
2023-07-30 08:49:34 -04:00
2023-09-16 18:15:11 -04:00
QQC2 . TextField {
2023-08-19 10:30:52 -04:00
id: lodestoneIdField
text: page . account . lodestoneId
placeholderText: qsTr ( "123456..." )
2023-07-30 08:49:34 -04:00
}
}
2023-08-19 10:30:52 -04:00
onClicked: lodestoneDialog . open ( )
2023-07-30 08:49:34 -04:00
}
2023-08-19 10:30:52 -04:00
}
2023-07-30 08:49:34 -04:00
2023-10-08 13:23:18 -04:00
FormCard . FormHeader {
title: i18n ( "Sapphire" )
visible: page . account . isSapphire
}
FormCard . FormCard {
visible: page . account . isSapphire
Layout.fillWidth: true
FormCard . FormTextFieldDelegate {
id: lobbyURLDelegate
label: i18n ( "Lobby URL" )
text: page . account . lobbyUrl
onTextChanged: page . account . lobbyUrl = text
visible: page . account . isSapphire
placeholderText: "neolobby0X.ffxiv.com"
}
}
2023-08-19 10:30:52 -04:00
FormCard . FormHeader {
title: i18n ( "Login" )
}
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormCard {
Layout.fillWidth: true
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormCheckDelegate {
id: rememberPasswordDelegate
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
text: i18n ( "Remember password" )
2023-10-08 13:23:18 -04:00
description: i18n ( "Stores the password on the device, using it's existing secure credential storage." )
2023-08-19 10:30:52 -04:00
checked: page . account . rememberPassword
onCheckedChanged: page . account . rememberPassword = checked
}
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormDelegateSeparator {
above: rememberPasswordDelegate
below: generateOTPField
}
2023-07-31 19:01:58 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormCheckDelegate {
id: generateOTPField
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
text: i18n ( "Automatically generate one-time passwords" )
2023-10-08 13:23:18 -04:00
description: i18n ( "Stores the one-time password secret on this device, making it inherently insecure. Only use this feature if you understand the risks." )
2023-08-19 10:30:52 -04:00
checked: page . account . rememberOTP
onCheckedChanged: page . account . rememberOTP = checked
enabled: page . account . useOTP
visible: ! page . account . isSapphire
}
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
FormCard . FormDelegateSeparator {
above: generateOTPField
below: otpSecretDelegate
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
visible: generateOTPField . visible
}
FormCard . FormButtonDelegate {
id: otpSecretDelegate
text: i18n ( "Enter OTP Secret" )
icon.name: "list-add-symbolic"
enabled: page . account . rememberOTP
visible: generateOTPField . visible
Kirigami . PromptDialog {
id: otpDialog
title: i18n ( "Enter OTP Secret" )
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
standardButtons: Kirigami . Dialog . Ok | Kirigami . Dialog . Cancel
2023-07-30 08:49:34 -04:00
2023-08-19 10:30:52 -04:00
onAccepted: page . account . setOTPSecret ( otpSecretField . text )
2023-07-30 08:49:34 -04:00
2023-09-16 18:15:11 -04:00
QQC2 . TextField {
2023-08-19 10:30:52 -04:00
id: otpSecretField
placeholderText: qsTr ( "ABCD EFGH..." )
2023-07-30 08:49:34 -04:00
}
}
2023-08-19 10:30:52 -04:00
onClicked: otpDialog . open ( )
2023-07-30 08:49:34 -04:00
}
2023-08-19 10:30:52 -04:00
}
2023-07-30 08:49:34 -04:00
2024-03-26 17:42:52 -04:00
Kirigami . PromptDialog {
id: deletePrompt
2023-08-19 10:30:52 -04:00
2024-03-26 17:42:52 -04:00
title: i18nc ( "@title" , "Delete Account" )
subtitle: i18nc ( "@label" , "Are you sure you want to delete this account?" )
standardButtons: Kirigami . Dialog . Ok | Kirigami . Dialog . Cancel
showCloseButton: false
2023-08-19 10:53:41 -04:00
2024-03-26 17:42:52 -04:00
onAccepted: {
LauncherCore . accountManager . deleteAccount ( page . account ) ;
page . Window . window . pageStack . layers . pop ( ) ;
2023-07-30 08:49:34 -04:00
}
}
}