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 . Layouts
2023-09-20 16:44:43 -04:00
import QtQuick . Window
2023-09-16 18:15:11 -04:00
import org . kde . kirigami as Kirigami
2023-10-08 20:01:17 -04:00
import org . kde . kirigamiaddons . formcard as FormCard
2023-09-16 18:15:11 -04:00
import zone . xiv . astra
2023-07-30 08:49:34 -04:00
2023-10-08 20:01:17 -04:00
FormCard . FormCardPage {
2023-07-30 08:49:34 -04:00
id: page
2024-05-26 06:18:30 -04:00
readonly property bool isValid: usernameField . text . length !== 0
2023-07-30 08:49:34 -04:00
property var profile
title: i18n ( "Add Square Enix Account" )
2023-10-08 20:01:17 -04:00
FormCard . FormCard {
Layout.fillWidth: true
2024-05-26 06:18:30 -04:00
Layout.topMargin: Kirigami . Units . largeSpacing
2023-07-30 08:49:34 -04:00
2023-10-08 20:01:17 -04:00
FormCard . FormTextDelegate {
id: helpTextDelegate
2024-05-26 06:18:30 -04:00
2023-10-08 20:01:17 -04:00
description: i18n ( "The password will be entered on the login page. A username will be associated with this account but can always be changed later." )
}
FormCard . FormDelegateSeparator {
above: helpTextDelegate
below: usernameField
}
FormCard . FormTextFieldDelegate {
id: usernameField
2024-05-26 06:18:30 -04:00
2023-10-08 20:01:17 -04:00
label: i18n ( "Username" )
}
FormCard . FormDelegateSeparator {
above: usernameField
below: licenseField
}
FormCard . FormComboBoxDelegate {
id: licenseField
2024-05-26 06:18:30 -04:00
currentIndex: 0
2023-10-08 20:01:17 -04:00
description: i18n ( "If the account holds multiple licenses, choose the preferred one." )
model: [ "Windows" , "Steam" , "macOS" ]
2024-05-26 06:18:30 -04:00
text: i18n ( "License" )
2023-07-30 08:49:34 -04:00
2024-05-26 06:18:30 -04:00
onCurrentIndexChanged: {
if ( currentIndex === 1 ) {
currentIndex = 0 ;
errorDialog . open ( ) ;
}
}
}
2023-10-08 20:01:17 -04:00
FormCard . FormDelegateSeparator {
above: licenseField
below: freeTrialField
}
FormCard . FormCheckDelegate {
id: freeTrialField
2024-05-26 06:18:30 -04:00
2023-10-08 20:01:17 -04:00
description: i18n ( "Check if the account is currently on free trial." )
2024-05-26 06:18:30 -04:00
text: i18n ( "Free Trial" )
2023-10-08 20:01:17 -04:00
}
FormCard . FormDelegateSeparator {
above: freeTrialField
below: buttonDelegate
}
FormCard . FormButtonDelegate {
id: buttonDelegate
2024-05-26 06:18:30 -04:00
2023-10-08 20:01:17 -04:00
enabled: page . isValid
2024-05-26 06:18:30 -04:00
icon.name: "list-add-symbolic"
text: i18n ( "Add Account" )
2023-10-08 20:01:17 -04:00
onClicked: {
2024-05-26 06:18:30 -04:00
let account = LauncherCore . accountManager . createSquareEnixAccount ( usernameField . text , licenseField . currentIndex , freeTrialField . checkState === Qt . Checked ) ;
2023-10-08 20:01:17 -04:00
if ( page . profile ) {
2024-05-26 06:18:30 -04:00
page . profile . account = account ;
applicationWindow ( ) . checkSetup ( ) ;
2023-10-08 20:01:17 -04:00
} else {
2024-05-26 06:18:30 -04:00
page . Window . window . pageStack . layers . pop ( ) ;
2023-07-30 08:49:34 -04:00
}
}
}
}
2024-05-26 06:18:30 -04:00
Kirigami . PromptDialog {
id: errorDialog
showCloseButton: false
standardButtons: Kirigami . Dialog . Ok
title: i18n ( "Steam Warning" )
subtitle: i18n ( "Steam linked Square Enix accounts are not currently supported. You will have to use another launcher that supports these, such as the official launcher or XIVLauncher.Core." )
}
2023-07-30 08:49:34 -04:00
}