2022-01-24 10:23:08 +08:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.0
|
|
|
|
import QtQuick.Window 2.0
|
2022-03-23 19:40:28 +08:00
|
|
|
import "Logic.js" as Logic
|
2022-03-01 13:18:00 +08:00
|
|
|
import "Pages"
|
2022-01-24 10:23:08 +08:00
|
|
|
|
|
|
|
Window {
|
2022-04-30 15:27:56 +08:00
|
|
|
id: mainWindow
|
|
|
|
visible: true
|
|
|
|
width: 720
|
|
|
|
height: 480
|
|
|
|
property var callbacks: Logic.callbacks
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
StackView {
|
|
|
|
id: mainStack
|
|
|
|
visible: !mainWindow.busy
|
|
|
|
initialItem: init
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Component { id: init; Init {} }
|
|
|
|
Component { id: lobby; Lobby {} }
|
|
|
|
Component { id: generalsOverview; GeneralsOverview {} }
|
|
|
|
Component { id: cardsOverview; CardsOverview {} }
|
|
|
|
Component { id: room; Room {} }
|
2022-03-01 13:18:00 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
property bool busy: false
|
|
|
|
BusyIndicator {
|
|
|
|
running: true
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: mainWindow.busy === true
|
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Config {
|
|
|
|
id: config
|
|
|
|
}
|
2022-03-24 21:23:42 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
// global popup. it is modal and just lower than toast
|
|
|
|
Rectangle {
|
|
|
|
id: globalPopupDim
|
|
|
|
anchors.fill: parent
|
|
|
|
color: "black"
|
|
|
|
opacity: 0
|
|
|
|
visible: !mainWindow.busy
|
2022-03-27 20:00:29 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
property bool stateVisible: false
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
when: globalPopupDim.stateVisible
|
|
|
|
PropertyChanges { target: globalPopupDim; opacity: 0.5 }
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
when: !globalPopupDim.stateVisible
|
|
|
|
PropertyChanges { target: globalPopupDim; opacity: 0.0 }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
transitions: Transition {
|
|
|
|
NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad }
|
2022-03-27 20:00:29 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-03-27 20:00:29 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Popup {
|
|
|
|
id: globalPopup
|
|
|
|
property string source: ""
|
|
|
|
modal: true
|
|
|
|
dim: false // cannot animate the dim
|
|
|
|
focus: true
|
|
|
|
opacity: mainWindow.busy ? 0 : 1
|
|
|
|
closePolicy: Popup.CloseOnEscape
|
|
|
|
anchors.centerIn: parent
|
2022-03-27 20:00:29 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
onAboutToShow: {
|
|
|
|
globalPopupDim.stateVisible = true
|
|
|
|
}
|
2022-03-27 20:00:29 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
enter: Transition {
|
|
|
|
NumberAnimation { properties: "opacity"; from: 0; to: 1 }
|
|
|
|
NumberAnimation { properties: "scale"; from: 0.4; to: 1 }
|
|
|
|
}
|
2022-03-27 20:00:29 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
onAboutToHide: {
|
|
|
|
globalPopupDim.stateVisible = false
|
|
|
|
}
|
2022-03-27 20:00:29 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
exit: Transition {
|
|
|
|
NumberAnimation { properties: "opacity"; from: 1; to: 0 }
|
|
|
|
NumberAnimation { properties: "scale"; from: 1; to: 0.4 }
|
2022-03-27 20:00:29 +08:00
|
|
|
}
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Loader {
|
|
|
|
visible: !mainWindow.busy
|
|
|
|
source: globalPopup.source === "" ? "" : "GlobalPopups/" + globalPopup.source
|
|
|
|
onSourceChanged: {
|
|
|
|
if (item === null)
|
|
|
|
return;
|
|
|
|
item.finished.connect(() => {
|
|
|
|
globalPopup.close();
|
|
|
|
globalPopup.source = "";
|
|
|
|
});
|
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ToastManager {
|
|
|
|
id: toast
|
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Connections {
|
|
|
|
target: Backend
|
|
|
|
function onNotifyUI(command, jsonData) {
|
|
|
|
let cb = callbacks[command]
|
|
|
|
if (typeof(cb) === "function") {
|
|
|
|
cb(jsonData);
|
|
|
|
} else {
|
|
|
|
callbacks["ErrorMsg"]("Unknown command " + command + "!");
|
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
}
|