-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsplash.qml
187 lines (163 loc) · 5.1 KB
/
splash.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/* Unvanquished Updater
* Copyright (C) Unvanquished Developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import Fluid.Controls 1.0 as FluidControls
import Fluid.Material 1.0
ApplicationWindow {
visible: true
id: splash
width: 745
height: 228
flags: Qt.SplashScreen | Qt.WindowStaysOnTopHint
Item {
focus: true
Keys.onSpacePressed: {
// Do the same as if timer runs out, but immediately
if (timer.running) {
timer.stop();
settingsAction.enabled = false;
splashController.autoLaunchOrUpdate();
}
}
}
Timer {
id: timer
interval: splashMilliseconds
repeat: false
running: true
onTriggered: {
settingsAction.enabled = false;
splashController.autoLaunchOrUpdate();
}
}
function showUpdater() {
splashDownloaderConnections.enabled = false;
updaterWindowLoader.active = true
splash.hide();
}
Connections {
target: splashController
onUpdateNeeded: { // game update only
if (updateNeeded) {
showUpdater()
} else {
splash.close();
gameLauncher.startGame(/*useConnectUrl=*/ true, /*failIfWindowsAdmin=*/ false);
}
}
onUpdaterUpdate: {
downloader.startUpdaterUpdate(version);
updaterUpdateLabel.visible = true;
// Now allow the window to go behind other windows in the z-order.
if (Qt.platform.os === "windows") {
// On Windows, additionally change the flags so that the app has an icon
// in the task bar (but remains borderless). The hide/show is needed to make the
// task bar icon appear.
splash.flags = Qt.Window | Qt.FramelessWindowHint;
splash.hide();
splash.show();
} else {
// Don't set the same window flags as on Windows because it makes the splash screen
// change position on GNOME.
// On Mac, WindowStaysOnTopHint doesn't even do anything and there is always
// a taskbar icon.
splash.flags &= ~Qt.WindowStaysOnTopHint;
}
}
}
Connections {
id: splashDownloaderConnections
target: downloader
onFatalMessage: {
updateFailed.errorDetail = message;
updateFailedWindow.show();
updateFailed.open();
splash.hide();
}
}
Image {
width: parent.width
height: parent.height
source: "qrc:/resources/splash.png"
}
FluidControls.BodyLabel {
id: updaterUpdateLabel
Material.theme: Material.Dark
text: "Updating launcher..."
visible: false
anchors.bottom: updaterUpdateProgress.top
anchors.left: parent.left
anchors.margins: { left: 20 }
font.pixelSize: 17
}
ActionButton {
id: settingsAction
anchors {
top: parent.top
right: parent.right
margins: {
top: 5
right: 9
}
}
height: 48
width: 48
iconName: "action/settings"
scale: 1.35
opacity: enabled ? 1 : 0.38
Material.elevation: 0
Material.background: Material.Teal
onClicked: {
timer.stop();
settingsAction.enabled = false;
if (splashController.relaunchForSettings()) {
splash.close();
} else {
showUpdater();
}
}
}
ProgressBar {
id: updaterUpdateProgress
anchors.bottom: parent.bottom
width: parent.width
from: 0.0
to: 1.0
indeterminate: false
value: downloader.completedSize / downloader.totalSize
Material.accent: Material.Teal
}
Loader {
id: updaterWindowLoader
active: false
source: "qrc:/main.qml"
}
ApplicationWindow {
id: updateFailedWindow
visible: false
width: updateFailed.width
height: updateFailed.height
maximumWidth: updateFailed.width
maximumHeight: updateFailed.height
UpdateFailed {
id: updateFailed
failedOperation: 'Launcher self-update'
}
}
}