-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.qml
141 lines (116 loc) · 3.99 KB
/
Main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls as QQC2
import org.kde.kirigami as Kirigami
import zone.xiv.astra
Kirigami.ApplicationWindow {
id: appWindow
width: 1280
height: 800
minimumWidth: 800
minimumHeight: 500
title: pageStack.currentItem !== undefined ? pageStack.currentItem.title : ""
property bool checkedAutoLogin: false
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
}
}
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;
} else {
pageStack.push(Qt.createComponent("zone.xiv.astra", "MainPage"))
}
}
}
function cancelAutoLogin() {
pageStack.clear();
pageStack.layers.clear();
pageStack.push(Qt.createComponent("zone.xiv.astra", "MainPage"));
}
function pushDialogLayer(url) {
if (LauncherCore.isSteamDeck) {
pageStack.layers.push(url)
} else {
pageStack.pushDialogLayer(url)
}
}
function openUrl(url) {
if (LauncherCore.isSteamDeck) {
appWindow.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "BrowserPage"), {
url: url
})
} else {
Qt.openUrlExternally(url)
}
}
Connections {
target: LauncherCore
function onLoadingFinished() {
appWindow.checkSetup();
}
function onSuccessfulLaunch() {
if (LauncherCore.settings.closeWhenLaunched) {
appWindow.hide();
} else {
appWindow.checkSetup();
}
}
function onGameClosed() {
if (!LauncherCore.settings.closeWhenLaunched) {
appWindow.checkSetup();
}
}
function onCurrentProfileChanged() {
appWindow.checkSetup();
}
function onShowWindow() {
appWindow.show();
}
}
Connections {
target: LauncherCore.settings
function onShowNewsChanged() {
// workaround annoying Qt layout bug
// TODO: see if this changed in Qt7
appWindow.pageStack.replace(Qt.createComponent("zone.xiv.astra", "MainPage"))
}
}
Component.onCompleted: checkSetup()
}