2023-01-13 15:31:42 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2024-10-14 10:54:52 +00:00
|
|
|
property string currentAnswerText: ""
|
|
|
|
property string nextAnswerText: ""
|
|
|
|
property bool canRequestAnswer: true
|
2023-01-13 15:31:42 +00:00
|
|
|
|
2024-10-14 10:54:52 +00:00
|
|
|
state: "DISABLED"
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "DISABLED"
|
|
|
|
PropertyChanges {
|
|
|
|
root.canRequestAnswer: true
|
|
|
|
answerText.visible: false
|
|
|
|
waitingPlaceholder.visible: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "WAITING"
|
|
|
|
PropertyChanges {
|
|
|
|
root.canRequestAnswer: false
|
|
|
|
answerText.visible: false
|
|
|
|
waitingPlaceholder.visible: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "SHOWING"
|
|
|
|
PropertyChanges {
|
|
|
|
root.canRequestAnswer: false
|
|
|
|
answerText.visible: true
|
|
|
|
waitingPlaceholder.visible: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "PAUSED"
|
|
|
|
PropertyChanges {
|
|
|
|
root.canRequestAnswer: true
|
|
|
|
answerText.visible: true
|
|
|
|
waitingPlaceholder.visible: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "HIDING"
|
|
|
|
PropertyChanges {
|
|
|
|
root.canRequestAnswer: false
|
|
|
|
answerText.visible: true
|
|
|
|
waitingPlaceholder.visible: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
from: "DISABLED,HIDING"
|
|
|
|
to: "WAITING"
|
|
|
|
SequentialAnimation {
|
|
|
|
id: waitingAnimation
|
|
|
|
loops: Animation.Infinite
|
|
|
|
|
|
|
|
ScaleAnimation {
|
|
|
|
target: root
|
|
|
|
mode: "ZoomIn"
|
|
|
|
}
|
|
|
|
|
|
|
|
ScaleAnimation {
|
|
|
|
target: root
|
|
|
|
mode: "ZoomOut"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onRunningChanged: {
|
|
|
|
if (!running) {
|
|
|
|
root.currentAnswerText = root.nextAnswerText;
|
|
|
|
root.nextAnswerText = "";
|
|
|
|
if (!root.currentAnswerText) {
|
|
|
|
root.state = "DISABLED";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
from: "WAITING,HIDING"
|
|
|
|
to: "SHOWING"
|
|
|
|
|
|
|
|
ScaleAnimation {
|
|
|
|
target: root
|
|
|
|
mode: "ZoomIn"
|
|
|
|
}
|
|
|
|
|
|
|
|
onRunningChanged: {
|
|
|
|
if (!running) {
|
|
|
|
root.state = "PAUSED";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
from: "PAUSED"
|
|
|
|
to: "HIDING"
|
|
|
|
|
|
|
|
ScaleAnimation {
|
|
|
|
target: root
|
|
|
|
mode: "ZoomOut"
|
|
|
|
}
|
|
|
|
|
|
|
|
onRunningChanged: {
|
|
|
|
if (!running) {
|
|
|
|
if (root.nextAnswerText) {
|
|
|
|
root.currentAnswerText = root.nextAnswerText;
|
|
|
|
root.nextAnswerText = "";
|
|
|
|
root.state = "SHOWING";
|
|
|
|
} else {
|
|
|
|
root.state = "WAITING";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
function addAnswer(answer: string): void {
|
|
|
|
root.nextAnswerText = answer;
|
|
|
|
if (root.state == "WAITING") {
|
|
|
|
root.state = "SHOWING";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function startWaiting(): void {
|
|
|
|
if (root.state == "PAUSED") {
|
|
|
|
root.state = "HIDING";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
root.state = "WAITING";
|
|
|
|
}
|
|
|
|
|
|
|
|
function cancelAnimation(): void {
|
|
|
|
root.state = "DISABLED";
|
|
|
|
}
|
2023-01-13 15:31:42 +00:00
|
|
|
|
|
|
|
MagicText {
|
2024-10-14 10:54:52 +00:00
|
|
|
id: answerText
|
2023-01-13 15:31:42 +00:00
|
|
|
anchors.centerIn: parent
|
2024-10-14 10:54:52 +00:00
|
|
|
font.pointSize: 20
|
2023-01-13 15:31:42 +00:00
|
|
|
color: "#2E53B6"
|
2024-10-14 10:54:52 +00:00
|
|
|
text: root.currentAnswerText
|
|
|
|
}
|
2023-01-13 15:31:42 +00:00
|
|
|
|
2024-10-14 10:54:52 +00:00
|
|
|
Row {
|
|
|
|
id: waitingPlaceholder
|
|
|
|
anchors.centerIn: parent
|
|
|
|
spacing: 12
|
2023-01-13 15:31:42 +00:00
|
|
|
|
2024-10-14 10:54:52 +00:00
|
|
|
Repeater {
|
|
|
|
model: 3
|
|
|
|
Rectangle {
|
|
|
|
width: 11
|
|
|
|
height: width
|
|
|
|
color: "#264BAF"
|
|
|
|
radius: 100
|
|
|
|
}
|
2023-01-13 15:31:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|