diff --git a/CalculateEndPage.qml b/CalculateEndPage.qml
new file mode 100644
index 0000000..9c36e13
--- /dev/null
+++ b/CalculateEndPage.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+Item {
+
+}
diff --git a/CalculatePage.qml b/CalculatePage.qml
index 6b126cb..0627134 100644
--- a/CalculatePage.qml
+++ b/CalculatePage.qml
@@ -3,215 +3,59 @@ import QtQuick.Controls 2.4
import "./"
Page {
- id: calculator
+ id: root
- property var nums: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
- property int currIndex: -1
- property int tickInterval: 1000
- property int numCount: 10
-
- signal pageOpened()
-
- onPageOpened: {
- console.log("opened calculator")
- calculator.state = "starting"
- }
-
- states: [
- State {
- name: "starting"
- PropertyChanges {
- target: calculatorStack
- currPage: calculatorStartPageComp
- }
- },
-
- State {
- name: "running"
- PropertyChanges {
- target: calculatorStack
- currPage: calculatorGamePageComp
- }
- }
- ]
-
- StackView {
- id: calculatorStack
-
- property var currPage;
-
- anchors.fill: parent
-
- onCurrPageChanged: {
- calculatorStack.replace(currPage)
- }
- onCurrentItemChanged: {
- calculatorStack.currentItem.pageOpened()
- }
-
- Component {
- id: calculatorStartPageComp
- Page {
- id: calculatorStartPage
- Label {
- id: calculatorStartPageHeading
- anchors {
- top: parent.top
- topMargin: parent.height * 0.05
- horizontalCenter: parent.horizontalCenter
- }
- font.pixelSize: parent.height * 0.15
- text: "Calculator"
- }
- SpinBox {
- id: calculatorTickInterval
- from: 1
- to: 100000
- stepSize: 1
- value: 1000
- anchors.horizontalCenter: parent.horizontalCenter
- editable: true
- anchors {
- left: parent.left
- top: parent.top
- leftMargin: parent.width * 0.5 - width * 0.5
- topMargin: parent.height * 0.3 - height * 0.5
- }
- onValueChanged: {
- calculator.tickInterval = calculatorTickInterval.value
- }
-
- }
- SpinBox {
- id: calculatorNumCount
- from: 1
- to: 100000
- stepSize: 1
- value: 10
- anchors.horizontalCenter: parent.horizontalCenter
- editable: true
- anchors {
- left: parent.left
- top: parent.top
- leftMargin: parent.width * 0.5 - width * 0.5
- topMargin: parent.height * 0.6 - height * 0.5
- }
- onValueChanged: {
- calculator.numCount = calculatorNumCount.value
- }
- }
- Button {
- id: calculatorStartButton
- text: "start"
- onClicked: {
- calculator.start()
- }
- }
- }
- }
-
- Component {
- id: calculatorGamePageComp
- Page {
- Label {
- id: num
- anchors.centerIn: parent
- font.pixelSize: calculator.height * 0.6
- text: calculator.nums[calculator.currIndex]
- }
-
-
- ProgressBar {
- id: prog
- property int progress: 0
- anchors {
- bottom: parent.bottom
- bottomMargin: parent.height * 0.02
- left: parent.left
- leftMargin: parent.width * 0.01
- right: parent.right
- rightMargin: parent.width * 0.01
- }
- value: progress/100
- onValueChanged: {
- console.log(value)
- }
-
- NumberAnimation {
- id: progAnim
- target: prog
- property: "progress"
- from: 100
- to: 0
- duration: tick.interval
- easing.type: Easing.Linear
- }
- }
-
- Timer {
- id: tick
- interval: calculator.tickInterval
- repeat: false
- running: calculator.state === "running"
-
- onTriggered: {
- if(calculator.currIndex+1 <= calculator.numCount-1){
- nextNumber()
- tick.start()
- }
- else {
-
- }
- }
-
- onRunningChanged: {
- if(running){
- progAnim.start()
- }
- }
- }
- }
- }
-
-
- replaceExit: Transition {
- NumberAnimation {
- from: 1
- to: 0
- property: "opacity"
- duration: 200
- easing.type: Easing.InOutQuad
- }
- }
-
- replaceEnter: Transition {
- NumberAnimation {
- from: 0
- to: 1
- property: "opacity"
- duration: 200
- easing.type: Easing.InOutQuad
- }
- }
+ Label {
+ id: num
+ anchors.centerIn: parent
+ font.pixelSize: calculator.height * 0.6
+ text: calculator.nums[calculator.currIndex]
}
- /*-------------------------
- ---------functions---------
- -------------------------*/
-
- function nextNumber(){
- var randNum = 0
- while(randNum === 0 || randNum === calculator.nums[currIndex]){
- randNum = Math.floor(Math.random() * 9)
+ ProgressBar {
+ id: prog
+ property int progress: 0
+ anchors {
+ bottom: parent.bottom
+ bottomMargin: parent.height * 0.02
+ left: parent.left
+ leftMargin: parent.width * 0.01
+ right: parent.right
+ rightMargin: parent.width * 0.01
+ }
+ value: progress/100
+ NumberAnimation {
+ id: progAnim
+ target: prog
+ property: "progress"
+ from: 100
+ to: 0
+ duration: tick.interval
+ easing.type: Easing.Linear
}
- calculator.nums[calculator.currIndex+1] = randNum
- console.log(randNum)
- calculator.currIndex += 1
}
- function start(){
- calculator.nextNumber()
- calculator.state = "running"
+ Timer {
+ id: tick
+ interval: calculator.tickInterval
+ repeat: false
+ running: calculator.state === "running"
+
+ onTriggered: {
+ if(calculator.currIndex+1 <= calculator.numCount-1){
+ nextNumber()
+ tick.start()
+ }
+ else {
+
+ }
+ }
+
+ onRunningChanged: {
+ if(running){
+ progAnim.start()
+ }
+ }
}
}
diff --git a/CalculateStartPage.qml b/CalculateStartPage.qml
new file mode 100644
index 0000000..7bed469
--- /dev/null
+++ b/CalculateStartPage.qml
@@ -0,0 +1,64 @@
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+
+Page {
+ id: calculatorStartPage
+
+ Label {
+ id: calculatorStartPageHeading
+ anchors {
+ top: parent.top
+ topMargin: parent.height * 0.05
+ horizontalCenter: parent.horizontalCenter
+ }
+ font.pixelSize: parent.height * 0.15
+ text: "Calculator"
+ }
+
+ SpinBox {
+ id: calculatorTickInterval
+ from: 1
+ to: 100000
+ stepSize: 1
+ value: 1000
+ anchors.horizontalCenter: parent.horizontalCenter
+ editable: true
+ anchors {
+ left: parent.left
+ top: parent.top
+ leftMargin: parent.width * 0.5 - width * 0.5
+ topMargin: parent.height * 0.3 - height * 0.5
+ }
+ onValueChanged: {
+ calculator.tickInterval = calculatorTickInterval.value
+ }
+
+ }
+
+ SpinBox {
+ id: calculatorNumCount
+ from: 1
+ to: 100000
+ stepSize: 1
+ value: 10
+ anchors.horizontalCenter: parent.horizontalCenter
+ editable: true
+ anchors {
+ left: parent.left
+ top: parent.top
+ leftMargin: parent.width * 0.5 - width * 0.5
+ topMargin: parent.height * 0.6 - height * 0.5
+ }
+ onValueChanged: {
+ calculator.numCount = calculatorNumCount.value
+ }
+ }
+
+ Button {
+ id: calculatorStartButton
+ text: "start"
+ onClicked: {
+ calculator.start()
+ }
+ }
+}
diff --git a/Calculator.qml b/Calculator.qml
new file mode 100644
index 0000000..ef8ccd0
--- /dev/null
+++ b/Calculator.qml
@@ -0,0 +1,104 @@
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+
+Item {
+ id: calculator
+
+ property var nums: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
+ property int currIndex: -1
+ property int tickInterval: 1000
+ property int numCount: 10
+
+ signal pageOpened()
+
+ onPageOpened: {
+ calculator.state = "starting"
+ }
+
+ states: [
+ State {
+ name: "starting"
+ PropertyChanges {
+ target: calculatorStack
+ currPage: calculatorStartPageComp
+ }
+ },
+
+ State {
+ name: "running"
+ PropertyChanges {
+ target: calculatorStack
+ currPage: calculatorGamePageComp
+ }
+ }
+ ]
+
+ StackView {
+ id: calculatorStack
+
+ property var currPage;
+
+ anchors.fill: parent
+
+ onCurrPageChanged: {
+ calculatorStack.replace(currPage)
+ }
+ onCurrentItemChanged: {
+ calculatorStack.currentItem.pageOpened()
+ }
+
+ Component {
+ id: calculatorStartPageComp
+ CalculateStartPage {
+ id: calculatorStartPage
+ }
+ }
+
+ Component {
+ id: calculatorGamePageComp
+ CalculatePage {
+
+ }
+ }
+
+
+ replaceExit: Transition {
+ NumberAnimation {
+ from: 1
+ to: 0
+ property: "opacity"
+ duration: 200
+ easing.type: Easing.InOutQuad
+ }
+ }
+
+ replaceEnter: Transition {
+ NumberAnimation {
+ from: 0
+ to: 1
+ property: "opacity"
+ duration: 200
+ easing.type: Easing.InOutQuad
+ }
+ }
+ }
+
+
+ /*-------------------------
+ ---------functions---------
+ -------------------------*/
+
+ function nextNumber(){
+ var randNum = 0
+ while(randNum === 0 || randNum === calculator.nums[currIndex]){
+ randNum = Math.floor(Math.random() * 9)
+ }
+ calculator.nums[calculator.currIndex+1] = randNum
+ calculator.currIndex += 1
+ }
+
+ function start(){
+ calculator.nextNumber()
+ calculator.state = "running"
+ }
+}
diff --git a/StartPage.qml b/StartPage.qml
index f6f0987..803df47 100644
--- a/StartPage.qml
+++ b/StartPage.qml
@@ -4,6 +4,7 @@ import "./"
Page {
id: root
+
signal pageOpened()
Button {
id: calenderButton
diff --git a/trainingforme.pro b/mathtrainingstuff.pro
similarity index 100%
rename from trainingforme.pro
rename to mathtrainingstuff.pro
diff --git a/qml.qrc b/qml.qrc
index 6f3ed69..d1f5bc3 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -4,5 +4,8 @@
CalenderPage.qml
StartPage.qml
CalculatePage.qml
+ CalculateStartPage.qml
+ CalculateEndPage.qml
+ Calculator.qml