2023-07-30 08:49:34 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Window 2.15
|
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
|
|
|
import QtQuick.Controls 2.15 as Controls
|
|
|
|
import QtQuick.Layouts 1.15
|
2023-08-19 10:30:52 -04:00
|
|
|
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
2023-09-16 17:32:38 -04:00
|
|
|
import org.kde.kirigamiaddons.components as Components
|
2023-08-06 11:52:35 -04:00
|
|
|
import zone.xiv.astra 1.0
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-07-30 09:14:22 -04:00
|
|
|
Controls.Control {
|
2023-07-30 08:49:34 -04:00
|
|
|
id: page
|
|
|
|
|
|
|
|
property var profile: LauncherCore.profileManager.getProfile(0)
|
|
|
|
readonly property bool isLoginValid: {
|
|
|
|
if (!profile.account) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if (usernameField.text.length === 0) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!profile.account.rememberPassword && passwordField.text.length === 0) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if (profile.account.useOTP && !profile.account.rememberOTP && otpField.text.length === 0) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateFields() {
|
|
|
|
usernameField.text = profile.account.name
|
|
|
|
passwordField.text = profile.account.rememberPassword ? profile.account.getPassword() : ""
|
|
|
|
otpField.text = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: profile
|
|
|
|
|
|
|
|
function onAccountChanged() {
|
|
|
|
updateFields()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onProfileChanged: updateFields()
|
|
|
|
|
2023-07-30 09:14:22 -04:00
|
|
|
contentItem: ColumnLayout {
|
2023-07-30 08:49:34 -04:00
|
|
|
width: parent.width
|
2023-08-19 10:30:52 -04:00
|
|
|
|
|
|
|
FormCard.FormCard {
|
2023-07-30 08:49:34 -04:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
text: i18n("Current Profile")
|
|
|
|
description: page.profile.name
|
2023-07-31 19:03:15 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Controls.Menu {
|
|
|
|
id: profileMenu
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Repeater {
|
|
|
|
model: LauncherCore.profileManager
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Controls.MenuItem {
|
|
|
|
required property var profile
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
Controls.MenuItem {
|
2023-08-19 10:30:52 -04:00
|
|
|
text: profile.name
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
onClicked: {
|
|
|
|
page.profile = profile
|
|
|
|
profileMenu.close()
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-08-19 10:30:52 -04:00
|
|
|
|
|
|
|
onClicked: profileMenu.popup()
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormCard {
|
2023-07-30 08:49:34 -04:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
text: i18n("Current Account")
|
|
|
|
description: page.profile.account.name
|
2023-07-31 19:03:15 -04:00
|
|
|
|
2023-09-16 17:32:38 -04:00
|
|
|
leading: Components.Avatar
|
2023-08-19 10:30:52 -04:00
|
|
|
{
|
|
|
|
source: page.profile.account.avatarUrl
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
leadingPadding: Kirigami.Units.largeSpacing * 2
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Controls.Menu {
|
|
|
|
id: accountMenu
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Repeater {
|
|
|
|
model: LauncherCore.accountManager
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Controls.MenuItem {
|
|
|
|
required property var account
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
Controls.MenuItem {
|
2023-08-19 10:30:52 -04:00
|
|
|
text: account.name
|
|
|
|
icon.name: account.avatarUrl.length === 0 ? "actor" : ""
|
|
|
|
icon.source: account.avatarUrl
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
onClicked: {
|
|
|
|
page.profile.account = account
|
|
|
|
accountMenu.close()
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
onClicked: accountMenu.popup()
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormDelegateSeparator {
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormTextFieldDelegate {
|
|
|
|
id: usernameField
|
|
|
|
label: page.profile.account.isSapphire ? i18n("Username") : i18n("Square Enix ID")
|
|
|
|
text: page.profile.account.name
|
|
|
|
enabled: false
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormDelegateSeparator {
|
|
|
|
}
|
|
|
|
|
|
|
|
FormCard.FormTextFieldDelegate {
|
|
|
|
id: passwordField
|
|
|
|
label: page.profile.account.isSapphire ? i18n("Password") : i18n("Square Enix Password")
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
focus: true
|
|
|
|
onAccepted: {
|
|
|
|
if (otpField.visible) {
|
|
|
|
otpField.clicked();
|
|
|
|
} else {
|
|
|
|
loginButton.clicked();
|
2023-08-18 22:16:45 -04:00
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
2023-08-19 10:30:52 -04:00
|
|
|
text: page.profile.account.rememberPassword ? "abcdefg" : ""
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormDelegateSeparator {
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormTextFieldDelegate {
|
|
|
|
id: otpField
|
|
|
|
label: i18n("One-time Password")
|
|
|
|
visible: page.profile.account.useOTP
|
|
|
|
onAccepted: loginButton.clicked()
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormDelegateSeparator {}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
id: loginButton
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
text: i18n("Log In")
|
|
|
|
icon.name: "unlock"
|
|
|
|
enabled: page.isLoginValid
|
|
|
|
onClicked: {
|
|
|
|
LauncherCore.login(page.profile, usernameField.text, passwordField.text, otpField.text)
|
|
|
|
pageStack.layers.push('qrc:/ui/Pages/StatusPage.qml')
|
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-08-19 10:30:52 -04:00
|
|
|
FormCard.FormDelegateSeparator {
|
|
|
|
visible: forgotPasswordButton.visible
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
id: forgotPasswordButton
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
text: i18n("Forgot ID or Password")
|
|
|
|
icon.name: "dialog-password"
|
|
|
|
visible: !page.profile.account.isSapphire
|
|
|
|
onClicked: applicationWindow().openUrl('https://secure.square-enix.com/account/app/svc/reminder')
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-08-18 22:16:45 -04:00
|
|
|
|
|
|
|
Component.onCompleted: passwordField.forceActiveFocus()
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|