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
|
|
|
|
|
|
|
|
property var profile
|
|
|
|
|
|
|
|
title: i18n("Add Sapphire Account")
|
|
|
|
|
2023-10-08 20:01:17 -04:00
|
|
|
readonly property bool isValid: usernameField.text.length !== 0 && lobbyUrlField.text.length !== 0
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 20:01:17 -04:00
|
|
|
FormCard.FormCard {
|
|
|
|
Layout.topMargin: Kirigami.Units.largeSpacing
|
|
|
|
Layout.fillWidth: true
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 20:01:17 -04:00
|
|
|
FormCard.FormTextDelegate {
|
|
|
|
id: helpTextDelegate
|
|
|
|
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.")
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 20:01:17 -04:00
|
|
|
FormCard.FormDelegateSeparator {
|
|
|
|
above: helpTextDelegate
|
|
|
|
below: usernameField
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 20:01:17 -04:00
|
|
|
FormCard.FormTextFieldDelegate {
|
|
|
|
id: usernameField
|
|
|
|
label: i18n("Username")
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 20:01:17 -04:00
|
|
|
FormCard.FormDelegateSeparator {
|
|
|
|
above: usernameField
|
|
|
|
below: lobbyUrlField
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 20:01:17 -04:00
|
|
|
FormCard.FormTextFieldDelegate {
|
|
|
|
id: lobbyUrlField
|
|
|
|
label: i18n("Lobby URL")
|
|
|
|
}
|
|
|
|
|
|
|
|
FormCard.FormDelegateSeparator {
|
|
|
|
above: lobbyUrlField
|
|
|
|
below: buttonDelegate
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 20:01:17 -04:00
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
id: buttonDelegate
|
|
|
|
text: i18n("Add Account")
|
|
|
|
icon.name: "list-add-symbolic"
|
|
|
|
enabled: page.isValid
|
|
|
|
onClicked: {
|
|
|
|
let account = LauncherCore.accountManager.createSapphireAccount(lobbyUrlField.text, usernameField.text)
|
|
|
|
if (page.profile) {
|
|
|
|
page.profile.account = account
|
|
|
|
applicationWindow().checkSetup()
|
|
|
|
} else {
|
|
|
|
page.Window.window.pageStack.layers.pop()
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|