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-12-17 12:47:13 -05:00
|
|
|
pragma ComponentBehavior: Bound
|
|
|
|
|
2023-09-16 18:15:11 -04:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls as QQC2
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
import org.kde.kirigamiaddons.formcard as FormCard
|
2023-09-16 17:32:38 -04:00
|
|
|
import org.kde.kirigamiaddons.components as Components
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-16 18:15:11 -04:00
|
|
|
import zone.xiv.astra
|
|
|
|
|
|
|
|
QQC2.Control {
|
2023-07-30 08:49:34 -04:00
|
|
|
id: page
|
|
|
|
|
2024-08-04 22:53:39 -04:00
|
|
|
bottomPadding: Kirigami.Units.largeSpacing
|
|
|
|
|
2023-09-17 19:33:43 -04:00
|
|
|
readonly property string invalidLoginReason: {
|
|
|
|
if (!LauncherCore.currentProfile.account) {
|
|
|
|
return i18n("Profile has no associated account.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (usernameField.text.length === 0) {
|
|
|
|
return i18n("Username is required.");
|
|
|
|
}
|
|
|
|
|
2023-12-20 19:47:57 -05:00
|
|
|
if (LauncherCore.currentProfile.account.needsPassword && passwordField.text.length === 0) {
|
2023-09-17 19:33:43 -04:00
|
|
|
return i18n("Password is required.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LauncherCore.currentProfile.account.useOTP && !LauncherCore.currentProfile.account.rememberOTP && otpField.text.length === 0) {
|
|
|
|
return i18n("OTP is required.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LauncherCore.currentProfile.loggedIn) {
|
|
|
|
return i18n("Already logged in.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
readonly property bool isLoginValid: {
|
2023-09-16 20:12:01 -04:00
|
|
|
if (!LauncherCore.currentProfile.account) {
|
2023-10-08 13:21:49 -04:00
|
|
|
return false;
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (usernameField.text.length === 0) {
|
2023-10-08 13:21:49 -04:00
|
|
|
return false;
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-20 19:47:57 -05:00
|
|
|
if (LauncherCore.currentProfile.account.needsPassword && passwordField.text.length === 0) {
|
2023-10-08 13:21:49 -04:00
|
|
|
return false;
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-09-16 20:12:01 -04:00
|
|
|
if (LauncherCore.currentProfile.account.useOTP && !LauncherCore.currentProfile.account.rememberOTP && otpField.text.length === 0) {
|
2023-10-08 13:21:49 -04:00
|
|
|
return false;
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2024-05-26 08:43:33 -04:00
|
|
|
return !LauncherCore.currentProfile.loggedIn;
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateFields() {
|
2024-05-26 08:43:33 -04:00
|
|
|
console.info(!LauncherCore.currentProfile.account.needsPassword && LauncherCore.currentProfile.account.rememberPassword);
|
2023-10-08 13:21:49 -04:00
|
|
|
usernameField.text = LauncherCore.currentProfile.account.name;
|
2023-12-20 19:47:57 -05:00
|
|
|
passwordField.text = !LauncherCore.currentProfile.account.needsPassword && LauncherCore.currentProfile.account.rememberPassword ? LauncherCore.currentProfile.account.getPassword() : "";
|
2024-08-04 22:43:32 -04:00
|
|
|
if (LauncherCore.currentProfile.account.rememberOTP) {
|
|
|
|
otpField.text = "Auto-generated";
|
|
|
|
} else {
|
|
|
|
otpField.text = "";
|
2023-09-16 20:12:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: LauncherCore.currentProfile
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
function onAccountChanged() {
|
2023-12-17 12:47:13 -05:00
|
|
|
page.updateFields();
|
2023-10-08 13:21:49 -04:00
|
|
|
|
2023-12-20 19:47:57 -05:00
|
|
|
if (LauncherCore.currentProfile.account.needsPassword) {
|
2023-10-08 13:21:49 -04:00
|
|
|
passwordField.forceActiveFocus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LauncherCore.currentProfile.account.useOTP) {
|
|
|
|
otpField.forceActiveFocus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
loginButton.forceActiveFocus();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-26 08:43:33 -04:00
|
|
|
Component.onCompleted: 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
|
|
|
|
2023-10-08 20:24:35 -04:00
|
|
|
spacing: Kirigami.Units.largeSpacing
|
|
|
|
|
2024-03-22 20:12:06 -04:00
|
|
|
Image {
|
|
|
|
readonly property real aspectRatio: sourceSize.height / sourceSize.width
|
|
|
|
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: "file://" + LauncherCore.cachedLogoImage
|
|
|
|
verticalAlignment: Image.AlignTop
|
|
|
|
sourceClipRect: Qt.rect(0, sourceSize.height / 2, sourceSize.width, sourceSize.height / 2)
|
|
|
|
|
|
|
|
Component.onCompleted: LauncherCore.refreshLogoImage()
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
Layout.preferredHeight: width * aspectRatio
|
|
|
|
}
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormCard {
|
2023-10-08 20:24:35 -04:00
|
|
|
maximumWidth: Kirigami.Units.gridUnit * 25
|
2023-12-31 17:28:31 -05:00
|
|
|
visible: LauncherCore.profileManager.numProfiles > 1
|
2023-10-08 20:24:35 -04:00
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormButtonDelegate {
|
2024-03-19 18:46:15 -04:00
|
|
|
id: currentProfileDelegate
|
|
|
|
|
2024-04-01 15:11:13 -04:00
|
|
|
text: LauncherCore.currentProfile.name
|
2023-07-31 19:03:15 -04:00
|
|
|
|
2023-09-16 18:15:11 -04:00
|
|
|
QQC2.Menu {
|
2023-08-19 10:30:52 -04:00
|
|
|
id: profileMenu
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2024-03-19 18:46:15 -04:00
|
|
|
modal: true
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Repeater {
|
|
|
|
model: LauncherCore.profileManager
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-16 18:15:11 -04:00
|
|
|
QQC2.MenuItem {
|
2023-12-17 12:47:13 -05:00
|
|
|
id: profileMenuItem
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
required property var profile
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-16 18:15:11 -04:00
|
|
|
QQC2.MenuItem {
|
2023-12-17 12:47:13 -05:00
|
|
|
text: profileMenuItem.profile.name
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
onClicked: {
|
2023-12-17 12:47:13 -05:00
|
|
|
LauncherCore.currentProfile = profileMenuItem.profile;
|
|
|
|
profileMenu.close();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-08-19 10:30:52 -04:00
|
|
|
|
2024-04-01 15:11:13 -04:00
|
|
|
onClicked: profileMenu.popup(currentProfileDelegate, currentProfileDelegate.width - profileMenu.width, currentProfileDelegate.height)
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormCard {
|
2024-04-19 20:29:28 -04:00
|
|
|
id: regularLoginCard
|
|
|
|
|
|
|
|
visible: !LauncherCore.currentProfile.isBenchmark
|
2023-10-08 20:24:35 -04:00
|
|
|
maximumWidth: Kirigami.Units.gridUnit * 25
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormButtonDelegate {
|
2023-10-08 13:21:49 -04:00
|
|
|
id: currentAccountDelegate
|
|
|
|
|
2024-04-01 15:15:30 -04:00
|
|
|
enabled: LauncherCore.accountManager.numAccounts > 1
|
2024-04-01 15:11:13 -04:00
|
|
|
text: LauncherCore.currentProfile.account.name
|
2023-07-31 19:03:15 -04:00
|
|
|
|
2023-10-08 13:21:49 -04:00
|
|
|
leading: Components.Avatar {
|
2024-04-01 15:11:13 -04:00
|
|
|
implicitWidth: Kirigami.Units.iconSizes.medium
|
|
|
|
implicitHeight: Kirigami.Units.iconSizes.medium
|
|
|
|
|
2023-12-17 11:26:25 -05:00
|
|
|
name: LauncherCore.currentProfile.account.name
|
2023-09-16 20:12:01 -04:00
|
|
|
source: LauncherCore.currentProfile.account.avatarUrl
|
2023-08-19 10:30:52 -04:00
|
|
|
}
|
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-09-16 18:15:11 -04:00
|
|
|
QQC2.Menu {
|
2023-08-19 10:30:52 -04:00
|
|
|
id: accountMenu
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2024-03-19 18:46:15 -04:00
|
|
|
modal: true
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Repeater {
|
|
|
|
model: LauncherCore.accountManager
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-16 18:15:11 -04:00
|
|
|
QQC2.MenuItem {
|
2023-12-17 12:47:13 -05:00
|
|
|
id: menuItem
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
required property var account
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-16 18:15:11 -04:00
|
|
|
QQC2.MenuItem {
|
2023-12-17 12:47:13 -05:00
|
|
|
text: menuItem.account.name
|
|
|
|
icon.name: menuItem.account.avatarUrl.length === 0 ? "actor" : ""
|
|
|
|
icon.source: menuItem.account.avatarUrl
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
onClicked: {
|
2023-12-17 12:47:13 -05:00
|
|
|
LauncherCore.currentProfile.account = menuItem.account;
|
|
|
|
accountMenu.close();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-01 15:11:13 -04:00
|
|
|
onClicked: accountMenu.popup(currentAccountDelegate, currentAccountDelegate.width - accountMenu.width, currentAccountDelegate.height)
|
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 {
|
2023-10-08 13:21:49 -04:00
|
|
|
above: currentAccountDelegate
|
|
|
|
below: usernameField
|
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.FormTextFieldDelegate {
|
|
|
|
id: usernameField
|
2023-09-16 20:12:01 -04:00
|
|
|
label: LauncherCore.currentProfile.account.isSapphire ? i18n("Username") : i18n("Square Enix ID")
|
|
|
|
text: LauncherCore.currentProfile.account.name
|
2023-08-19 10:30:52 -04:00
|
|
|
enabled: false
|
2024-04-01 15:11:13 -04:00
|
|
|
|
|
|
|
QQC2.ToolTip.text: i18n("The username can only be changed under account settings.")
|
|
|
|
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
|
|
|
QQC2.ToolTip.visible: hovered
|
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 {
|
2023-10-08 13:21:49 -04:00
|
|
|
above: usernameField
|
|
|
|
below: passwordField
|
2023-08-19 10:30:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
FormCard.FormTextFieldDelegate {
|
|
|
|
id: passwordField
|
2023-09-16 20:12:01 -04:00
|
|
|
label: LauncherCore.currentProfile.account.isSapphire ? i18n("Password") : i18n("Square Enix Password")
|
2023-08-19 10:30:52 -04:00
|
|
|
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
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormDelegateSeparator {
|
2023-10-08 13:21:49 -04:00
|
|
|
above: passwordField
|
2023-10-11 12:59:34 -04:00
|
|
|
below: LauncherCore.currentProfile.account.useOTP ? otpField : loginButton
|
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.FormTextFieldDelegate {
|
|
|
|
id: otpField
|
2024-08-04 22:43:32 -04:00
|
|
|
|
|
|
|
enabled: !LauncherCore.currentProfile.account.rememberOTP
|
2023-08-19 10:30:52 -04:00
|
|
|
label: i18n("One-time Password")
|
2023-09-16 20:12:01 -04:00
|
|
|
visible: LauncherCore.currentProfile.account.useOTP
|
2023-10-08 13:21:49 -04:00
|
|
|
onAccepted: {
|
|
|
|
if (page.isLoginValid) {
|
|
|
|
loginButton.clicked()
|
|
|
|
}
|
|
|
|
}
|
2023-08-19 10:30:52 -04:00
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 13:21:49 -04:00
|
|
|
FormCard.FormDelegateSeparator {
|
2023-10-11 12:59:34 -04:00
|
|
|
above: LauncherCore.currentProfile.account.useOTP ? otpField : passwordField
|
2023-10-08 13:21:49 -04:00
|
|
|
below: loginButton
|
2023-10-11 12:59:34 -04:00
|
|
|
visible: LauncherCore.currentProfile.account.useOTP
|
2023-10-08 13:21:49 -04:00
|
|
|
}
|
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")
|
2023-12-17 12:47:13 -05:00
|
|
|
description: page.invalidLoginReason
|
2023-08-19 10:30:52 -04:00
|
|
|
icon.name: "unlock"
|
|
|
|
enabled: page.isLoginValid
|
|
|
|
onClicked: {
|
2023-09-16 20:12:01 -04:00
|
|
|
LauncherCore.login(LauncherCore.currentProfile, usernameField.text, passwordField.text, otpField.text)
|
2023-12-20 17:09:32 -05:00
|
|
|
page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage"))
|
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 {
|
2023-10-08 13:21:49 -04:00
|
|
|
above: loginButton
|
|
|
|
below: forgotPasswordButton
|
2024-03-22 20:12:06 -04:00
|
|
|
visible: !LauncherCore.currentProfile.account.isSapphire
|
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.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"
|
2023-09-16 20:12:01 -04:00
|
|
|
visible: !LauncherCore.currentProfile.account.isSapphire
|
2023-08-19 10:30:52 -04:00
|
|
|
onClicked: applicationWindow().openUrl('https://secure.square-enix.com/account/app/svc/reminder')
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
2024-03-22 20:53:38 -04:00
|
|
|
|
2024-04-19 20:29:28 -04:00
|
|
|
FormCard.FormCard {
|
|
|
|
id: benchmarkLaunchCard
|
|
|
|
|
|
|
|
visible: LauncherCore.currentProfile.isBenchmark
|
|
|
|
maximumWidth: Kirigami.Units.gridUnit * 25
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
id: launchBenchmarkDelegate
|
|
|
|
|
|
|
|
text: i18n("Launch Benchmark")
|
|
|
|
onClicked: {
|
|
|
|
LauncherCore.login(LauncherCore.currentProfile, "", "", "")
|
|
|
|
page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-22 20:53:38 -04:00
|
|
|
Item {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
|
|
|
|
FormCard.FormCard {
|
|
|
|
maximumWidth: Kirigami.Units.gridUnit * 25
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
|
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
text: i18nc("@action:button", "The Lodestone")
|
|
|
|
icon.name: "internet-services-symbolic"
|
|
|
|
visible: !LauncherCore.currentProfile.account.isSapphire
|
|
|
|
// TODO: how do we link to a "worldwide" lodestone, if that even exists?
|
|
|
|
onClicked: applicationWindow().openUrl('https://na.finalfantasyxiv.com/lodestone/')
|
|
|
|
}
|
|
|
|
|
|
|
|
FormCard.FormDelegateSeparator {}
|
|
|
|
|
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
text: i18nc("@action:button", "Mog Station")
|
|
|
|
icon.name: "internet-services-symbolic"
|
|
|
|
visible: !LauncherCore.currentProfile.account.isSapphire
|
|
|
|
onClicked: applicationWindow().openUrl('https://secure.square-enix.com/account/app/svc/mogstation/')
|
|
|
|
}
|
|
|
|
}
|
2023-10-08 13:21:49 -04:00
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|