1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00
astra/launcher/ui/Main.qml

140 lines
4 KiB
QML
Raw Normal View History

// 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
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
title: pageStack.currentItem !== undefined ? pageStack.currentItem.title : ""
property bool checkedAutoLogin: false
2024-03-19 19:10:30 -04:00
pageStack {
globalToolBar {
style: Kirigami.ApplicationHeaderStyle.ToolBar
// TODO: they should really do this check in kirigami
showNavigationButtons: if (pageStack.currentItem?.globalToolBarStyle === Kirigami.ApplicationHeaderStyle.ToolBar) {
Kirigami.ApplicationHeaderStyle.ShowBackButton
} else {
Kirigami.ApplicationHeaderStyle.NoNavigationButtons
}
}
2024-03-19 19:10:30 -04:00
initialPage: Kirigami.Page {
Kirigami.LoadingPlaceholder {
anchors.centerIn: parent
}
}
}
onClosing: (close) => {
if (LauncherCore.isPatching()) {
applicationWindow().showPassiveNotification(i18n("Please do not quit while patching!"));
}
close.accepted = !LauncherCore.isPatching();
}
function checkSetup() {
if (!LauncherCore.loadingFinished) {
return
}
pageStack.clear()
pageStack.layers.clear();
if (!LauncherCore.currentProfile.isGameInstalled) {
// User must set up the profile
pageStack.push(Qt.createComponent("zone.xiv.astra", "SetupPage"), {
profile: LauncherCore.currentProfile
})
} else if (!LauncherCore.currentProfile.account && !LauncherCore.currentProfile.isBenchmark) {
// User must select an account for the profile
pageStack.push(Qt.createComponent("zone.xiv.astra", "AccountSetup"), {
profile: LauncherCore.currentProfile
})
} else {
if (LauncherCore.autoLoginProfile && !checkedAutoLogin) {
pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "AutoLoginPage"))
checkedAutoLogin = true;
2023-09-17 19:20:41 -04:00
} else {
pageStack.push(Qt.createComponent("zone.xiv.astra", "MainPage"))
2023-09-17 19:20:41 -04:00
}
}
}
2023-09-17 19:20:41 -04:00
function cancelAutoLogin() {
pageStack.clear();
2023-09-17 19:20:41 -04:00
pageStack.layers.clear();
pageStack.push(Qt.createComponent("zone.xiv.astra", "MainPage"));
2023-09-17 19:20:41 -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"), {
url: url
})
} else {
Qt.openUrlExternally(url)
}
}
Connections {
target: LauncherCore
function onLoadingFinished() {
2023-12-17 12:47:13 -05:00
appWindow.checkSetup();
}
function onSuccessfulLaunch() {
if (LauncherCore.settings.closeWhenLaunched) {
2023-12-17 12:47:13 -05:00
appWindow.hide();
} else {
2023-12-17 12:47:13 -05:00
appWindow.checkSetup();
}
}
function onGameClosed() {
if (LauncherCore.settings.closeWhenLaunched) {
Qt.callLater(Qt.quit);
} else {
2023-12-17 12:47:13 -05:00
appWindow.checkSetup();
}
}
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
function onShowNewsChanged() {
// workaround annoying Qt layout bug
2023-11-10 17:31:05 -05:00
// TODO: see if this changed in Qt7
appWindow.pageStack.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
}
}
Component.onCompleted: checkSetup()
}