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
|
|
|
|
|
|
|
Kirigami.ApplicationWindow {
|
|
|
|
id: appWindow
|
|
|
|
|
|
|
|
width: 1280
|
2023-12-20 17:09:26 -05:00
|
|
|
height: 800
|
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
|
|
|
|
|
2024-03-19 19:10:30 -04:00
|
|
|
pageStack {
|
2024-03-22 18:51:31 -04:00
|
|
|
globalToolBar {
|
|
|
|
style: Kirigami.ApplicationHeaderStyle.ToolBar
|
|
|
|
}
|
2024-03-19 19:10:30 -04:00
|
|
|
initialPage: Kirigami.Page {
|
|
|
|
Kirigami.LoadingPlaceholder {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-11 17:45:02 -04:00
|
|
|
onClosing: (close) => {
|
|
|
|
if (LauncherCore.isPatching()) {
|
|
|
|
applicationWindow().showPassiveNotification(i18n("Please do not quit while patching!"));
|
|
|
|
}
|
|
|
|
close.accepted = !LauncherCore.isPatching();
|
|
|
|
}
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
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
|
2024-03-23 10:38:21 -04:00
|
|
|
pageStack.layers.push(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
|
2024-03-23 10:38:21 -04:00
|
|
|
pageStack.layers.push(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) {
|
2024-03-23 10:38:21 -04:00
|
|
|
pageStack.layers.push(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 {
|
2024-03-19 19:10:30 -04:00
|
|
|
pageStack.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
|
2023-09-17 19:20:41 -04:00
|
|
|
}
|
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-12-17 12:47:13 -05:00
|
|
|
appWindow.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-12-17 12:47:13 -05:00
|
|
|
appWindow.checkSetup();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
2023-07-30 16:20:51 -04:00
|
|
|
|
|
|
|
function onSuccessfulLaunch() {
|
2023-10-11 13:25:24 -04:00
|
|
|
if (LauncherCore.settings.closeWhenLaunched) {
|
2023-12-17 12:47:13 -05:00
|
|
|
appWindow.hide();
|
2023-08-18 21:36:19 -04:00
|
|
|
} else {
|
2023-12-17 12:47:13 -05:00
|
|
|
appWindow.checkSetup();
|
2023-08-18 21:36:19 -04:00
|
|
|
}
|
2023-07-30 16:20:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function onGameClosed() {
|
2023-10-11 13:25:24 -04:00
|
|
|
if (LauncherCore.settings.closeWhenLaunched) {
|
2023-08-18 21:36:19 -04:00
|
|
|
Qt.callLater(Qt.quit);
|
|
|
|
} else {
|
2023-12-17 12:47:13 -05:00
|
|
|
appWindow.checkSetup();
|
2023-08-18 21:36:19 -04:00
|
|
|
}
|
2023-07-30 16:20:51 -04:00
|
|
|
}
|
2023-07-31 19:02:59 -04:00
|
|
|
|
2023-11-10 17:31:05 -05:00
|
|
|
function onCurrentProfileChanged() {
|
2023-12-17 12:47:13 -05:00
|
|
|
appWindow.checkSetup();
|
2023-11-10 17:31:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: LauncherCore.settings
|
|
|
|
|
2023-07-31 19:02:59 -04:00
|
|
|
function onShowNewsChanged() {
|
2023-10-08 13:19:23 -04:00
|
|
|
// workaround annoying Qt layout bug
|
2023-11-10 17:31:05 -05:00
|
|
|
// TODO: see if this changed in Qt7
|
2023-12-17 12:47:13 -05:00
|
|
|
appWindow.pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
|
2023-07-31 19:02:59 -04:00
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: checkSetup()
|
|
|
|
}
|