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
|
|
|
|
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
|
|
|
|
import zone.xiv.astra
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
import "Pages"
|
|
|
|
|
|
|
|
Kirigami.ApplicationWindow {
|
|
|
|
id: appWindow
|
|
|
|
|
|
|
|
width: 1280
|
|
|
|
height: 720
|
2023-07-31 18:57:00 -04:00
|
|
|
|
|
|
|
minimumWidth: 800
|
|
|
|
minimumHeight: 500
|
|
|
|
|
2023-10-08 13:19:23 -04:00
|
|
|
title: "Astra"
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-17 19:30:22 -04:00
|
|
|
property bool checkedAutoLogin: false
|
|
|
|
|
2023-07-30 09:14:22 -04:00
|
|
|
pageStack.initialPage: Kirigami.Page {
|
2023-07-30 08:49:34 -04:00
|
|
|
Kirigami.LoadingPlaceholder {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkSetup() {
|
|
|
|
if (!LauncherCore.loadingFinished) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pageStack.layers.clear()
|
|
|
|
|
2023-09-16 20:12:01 -04:00
|
|
|
if (!LauncherCore.currentProfile.isGameInstalled) {
|
2023-07-30 08:49:34 -04:00
|
|
|
// User must set up the profile
|
2023-09-16 17:41:51 -04:00
|
|
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "SetupPage"), {
|
2023-09-16 20:12:01 -04:00
|
|
|
profile: LauncherCore.currentProfile
|
2023-07-30 08:49:34 -04:00
|
|
|
})
|
2023-09-16 20:12:01 -04:00
|
|
|
} else if (!LauncherCore.currentProfile.account) {
|
2023-07-30 08:49:34 -04:00
|
|
|
// User must select an account for the profile
|
2023-09-16 17:41:51 -04:00
|
|
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "AccountSetup"), {
|
2023-09-16 20:12:01 -04:00
|
|
|
profile: LauncherCore.currentProfile
|
2023-07-30 08:49:34 -04:00
|
|
|
})
|
|
|
|
} else {
|
2023-09-17 19:30:22 -04:00
|
|
|
if (LauncherCore.autoLoginProfile && !checkedAutoLogin) {
|
2023-09-17 19:20:41 -04:00
|
|
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "AutoLoginPage"))
|
2023-09-17 19:30:22 -04:00
|
|
|
checkedAutoLogin = true;
|
2023-09-17 19:20:41 -04:00
|
|
|
} else {
|
|
|
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-17 19:20:41 -04:00
|
|
|
function cancelAutoLogin() {
|
|
|
|
pageStack.layers.clear();
|
|
|
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage"));
|
|
|
|
}
|
|
|
|
|
2023-07-31 19:00:42 -04:00
|
|
|
function pushDialogLayer(url) {
|
|
|
|
if (LauncherCore.isSteamDeck) {
|
|
|
|
pageStack.layers.push(url)
|
|
|
|
} else {
|
|
|
|
pageStack.pushDialogLayer(url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function openUrl(url) {
|
|
|
|
if (LauncherCore.isSteamDeck) {
|
2023-09-16 17:41:51 -04:00
|
|
|
pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "BrowserPage"), {
|
2023-07-31 19:00:42 -04:00
|
|
|
url: url
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
Qt.openUrlExternally(url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
Connections {
|
|
|
|
target: LauncherCore
|
|
|
|
|
|
|
|
function onLoadingFinished() {
|
2023-08-18 21:36:19 -04:00
|
|
|
checkSetup();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
2023-07-30 16:20:51 -04:00
|
|
|
|
|
|
|
function onSuccessfulLaunch() {
|
2023-08-18 21:36:19 -04:00
|
|
|
if (LauncherCore.closeWhenLaunched) {
|
|
|
|
hide();
|
|
|
|
} else {
|
|
|
|
checkSetup();
|
|
|
|
}
|
2023-07-30 16:20:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function onGameClosed() {
|
2023-08-18 21:36:19 -04:00
|
|
|
if (LauncherCore.closeWhenLaunched) {
|
|
|
|
Qt.callLater(Qt.quit);
|
|
|
|
} else {
|
|
|
|
checkSetup();
|
|
|
|
}
|
2023-07-30 16:20:51 -04:00
|
|
|
}
|
2023-07-31 19:02:59 -04:00
|
|
|
|
|
|
|
function onShowNewsChanged() {
|
2023-10-08 13:19:23 -04:00
|
|
|
// workaround annoying Qt layout bug
|
2023-07-31 19:02:59 -04:00
|
|
|
// TODO: see if this changed in Qt6
|
2023-09-16 17:41:51 -04:00
|
|
|
pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
|
2023-07-31 19:02:59 -04:00
|
|
|
}
|
2023-09-16 20:12:01 -04:00
|
|
|
|
|
|
|
function onCurrentProfileChanged() {
|
|
|
|
checkSetup();
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: checkSetup()
|
2023-08-18 22:13:41 -04:00
|
|
|
|
2023-09-16 18:15:11 -04:00
|
|
|
property Item hoverLinkIndicator: QQC2.Control {
|
2023-08-18 22:13:41 -04:00
|
|
|
parent: overlay.parent
|
|
|
|
property alias text: linkText.text
|
|
|
|
opacity: text.length > 0 ? 1 : 0
|
|
|
|
|
|
|
|
Behavior on opacity {
|
|
|
|
OpacityAnimator {
|
|
|
|
duration: Kirigami.Units.longDuration
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
z: 999990
|
|
|
|
x: 0
|
|
|
|
y: parent.height - implicitHeight
|
2023-09-16 18:15:11 -04:00
|
|
|
contentItem: QQC2.Label {
|
2023-08-18 22:13:41 -04:00
|
|
|
id: linkText
|
|
|
|
}
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
|
|
|
background: Rectangle {
|
|
|
|
color: Kirigami.Theme.backgroundColor
|
|
|
|
}
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|