2022-01-24 02:23:08 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.0
|
|
|
|
import QtQuick.Window 2.0
|
2022-03-23 11:40:28 +00:00
|
|
|
import "Logic.js" as Logic
|
2022-03-01 05:18:00 +00:00
|
|
|
import "Pages"
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
Window {
|
|
|
|
id: mainWindow
|
|
|
|
visible: true
|
|
|
|
width: 720
|
|
|
|
height: 480
|
2022-03-23 11:40:28 +00:00
|
|
|
property var callbacks: Logic.callbacks
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-01 05:18:00 +00:00
|
|
|
StackView {
|
|
|
|
id: mainStack
|
|
|
|
visible: !mainWindow.busy
|
|
|
|
initialItem: init
|
2022-01-24 02:23:08 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
|
2022-03-01 05:18:00 +00:00
|
|
|
Component {
|
|
|
|
id: init
|
|
|
|
Init {}
|
|
|
|
}
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-01 05:18:00 +00:00
|
|
|
Component {
|
|
|
|
id: lobby
|
|
|
|
Lobby {}
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 05:18:00 +00:00
|
|
|
Component {
|
|
|
|
id: room
|
|
|
|
Room {}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: createRoom
|
|
|
|
CreateRoom {}
|
|
|
|
}
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-03-01 05:18:00 +00:00
|
|
|
property bool busy: false
|
2022-01-24 02:23:08 +00:00
|
|
|
BusyIndicator {
|
|
|
|
running: true
|
|
|
|
anchors.centerIn: parent
|
2022-03-01 05:18:00 +00:00
|
|
|
visible: mainWindow.busy === true
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: toast
|
|
|
|
opacity: 0
|
|
|
|
z: 998
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
y: parent.height * 0.8
|
|
|
|
radius: 16
|
|
|
|
color: "#F2808A87"
|
|
|
|
height: toast_text.height + 20
|
|
|
|
width: toast_text.width + 40
|
|
|
|
Text {
|
|
|
|
id: toast_text
|
|
|
|
text: "FreeKill"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
color: "white"
|
|
|
|
}
|
|
|
|
Behavior on opacity {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 240
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SequentialAnimation {
|
|
|
|
id: keepAnim
|
|
|
|
running: toast.opacity == 1
|
|
|
|
PauseAnimation {
|
|
|
|
duration: 2800
|
|
|
|
}
|
|
|
|
|
|
|
|
ScriptAction {
|
|
|
|
script: {
|
2022-03-01 05:18:00 +00:00
|
|
|
toast.opacity = 0;
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function show(text) {
|
2022-03-01 05:18:00 +00:00
|
|
|
opacity = 1;
|
|
|
|
toast_text.text = text;
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: Backend
|
2022-03-02 12:56:37 +00:00
|
|
|
function onNotifyUI(command, jsonData) {
|
2022-01-24 02:23:08 +00:00
|
|
|
let cb = callbacks[command]
|
|
|
|
if (typeof(cb) === "function") {
|
2022-03-02 12:56:37 +00:00
|
|
|
cb(jsonData);
|
2022-01-24 02:23:08 +00:00
|
|
|
} else {
|
2022-03-02 12:56:37 +00:00
|
|
|
callbacks["ErrorMsg"]("Unknown command " + command + "!");
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|