/
times.qml
97 lines (85 loc) · 2.26 KB
/
times.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
import QtQuick 2.6
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.0
import QtQuick.Window 2.2
import org.julialang 1.0
ApplicationWindow {
id: appRoot
title: "Times Problems"
width: 600
height: 400
visible: true
property double fontSize: 0.35*questionBar.height
ColumnLayout {
spacing: 6
anchors.fill: parent
RowLayout {
id: questionBar
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
Layout.topMargin: 5
Layout.preferredHeight: appRoot.height*0.4
Text {
id: questionText
text: problem.prompt
font.pixelSize: appRoot.fontSize
}
TextField {
id: answer
Layout.preferredWidth: 0.2*appRoot.width
Layout.preferredHeight: 0.5*appRoot.height*0.4
font.pixelSize: appRoot.fontSize
horizontalAlignment: TextInput.AlignHCenter
validator: IntValidator {}
focus: true
onAccepted: Julia.submit(text)
}
Button {
Layout.preferredWidth: 0.15*appRoot.width
Layout.preferredHeight: answer.height
text: "OK"
onClicked: Julia.submit(answer.text)
enabled: answer.acceptableInput
}
}
Rectangle {
id: feedback
Layout.fillWidth: true
Layout.fillHeight: true
color: "white"
state: problem.statusstring
ColumnLayout {
spacing: 6
anchors.fill: parent
Text {
id: statusText
text: qsTr("Please solve the problem")
Layout.alignment: Qt.AlignCenter
font.pixelSize: appRoot.fontSize/2
}
}
states: [
State {
name: "Correct!"
PropertyChanges { target: feedback; color: "green"}
PropertyChanges {
target: statusText;
text: problem.resultstring + qsTr(" is correct, try the next one!")
}
},
State {
name: "Incorrect!"
PropertyChanges { target: feedback; color: "red"}
PropertyChanges {
target: statusText;
text: problem.resultstring + qsTr(" is incorrect, please try again.")
}
}
]
}
}
Connections {
target: problem
function onResultstringChanged() { answer.clear(); }
}
}