diff --git a/CalenderPage.qml b/CalenderPage.qml
deleted file mode 100644
index fa79245..0000000
--- a/CalenderPage.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls 2.4
-import "./"
-
-Page {
- id: cal
- signal pageOpened()
- Rectangle {
- anchors.fill: parent
- color: "red"
- }
-}
diff --git a/StartPage.qml b/StartPage.qml
deleted file mode 100644
index d8da026..0000000
--- a/StartPage.qml
+++ /dev/null
@@ -1,44 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls 2.4
-import "./"
-
-Page {
- id: root
-
- signal pageOpened()
- RoundButton {
- id: calenderButton
- text: "calender"
- height: parent.width * 0.2
- width: height
- font.pixelSize: parent.width * 0.03
- anchors {
- left: parent.left
- top: parent.top
- leftMargin: parent.width * 0.5 - width * 0.5
- topMargin: parent.height * 0.3 - height * 0.5
- }
-
- onClicked: {
- game.calender()
- }
- }
-
- RoundButton {
- id: calculatorButton
- text: "calculator"
- height: parent.width * 0.2
- width: height
- font.pixelSize: parent.width * 0.03
- anchors {
- left: parent.left
- top: parent.top
- leftMargin: parent.width * 0.5 - width * 0.5
- topMargin: parent.height * 0.6 - height * 0.5
- }
-
- onClicked: {
- game.calculator()
- }
- }
-}
diff --git a/android-sources/AndroidManifest.xml b/android-sources/AndroidManifest.xml
new file mode 100644
index 0000000..434affb
--- /dev/null
+++ b/android-sources/AndroidManifest.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/calculator/Calculator.qml b/calculator/Calculator.qml
deleted file mode 100644
index 81e1019..0000000
--- a/calculator/Calculator.qml
+++ /dev/null
@@ -1,152 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-import "./"
-
-Item {
- id: calculator
-
- property int sum: 0
- property int nextNum: 0
- property int lastNum: 0
- property int actualNumCount: 0
- property int min: 1
- property int max: 9
- property int tickInterval: 1000
- property int numCount: 10
- property bool endPageVisibility: false
- property string endPageLabelText: "You Lose!"
-
- signal pageOpened()
-
- onPageOpened: {
- calculator.start()
- }
-
- states: [
- State {
- name: "starting"
- PropertyChanges {
- target: calculatorStack
- currPage: calculatorStartPageComp
- }
- },
-
- State {
- name: "running"
- PropertyChanges {
- target: calculatorStack
- currPage: calculatorRunningPageComp
- }
- },
- State {
- name: "gameOver"
- PropertyChanges {
- target: calculatorStack
- currPage: calculatorGameOverPageComp
- }
- }
- ]
-
- StackView {
- id: calculatorStack
-
- property var currPage;
-
- anchors.fill: parent
-
- onCurrPageChanged: {
- calculatorStack.replace(currPage)
- }
- onCurrentItemChanged: {
- calculatorStack.currentItem.pageOpened()
- }
-
- Component {
- id: calculatorStartPageComp
- CalculatorStartPage {
- }
- }
-
- Component {
- id: calculatorRunningPageComp
- CalculatorRunningPage {
- }
- }
-
- Component {
- id: calculatorGameOverPageComp
- CalculatorGameOverPage {
- }
- }
-
-
- 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 start() {
- calculator.reset()
- calculator.state = "starting"
- }
-
- function run() {
- calculator.nextNumber()
- calculator.state = "running"
- }
-
- function gameOver() {
- calculator.state = "gameOver"
- }
-
- function reset() {
- calculator.sum = 0
- calculator.actualNumCount = 0
- calculator.endPageLabelText = "You Lose!"
- calculator.endPageVisibility = false
- calculator.lastNum = 0
- calculator.nextNum = 0
- }
-
- function nextNumber(){
- var randNum = 0
- var range = calculator.max - calculator.min
- lastNum = nextNum
- while(randNum===0 || randNum === lastNum){
- randNum = Math.floor((Math.random()*(range+1))+min)
- }
- nextNum = randNum
- calculator.sum += randNum
- actualNumCount += 1
- }
-
- function checkSum(sumInputText) {
- if (sumInputText !== "") {
- if (calculator.sum === parseInt(sumInputText)) {
- calculator.endPageLabelText = "You Won!"
- }
- calculator.endPageVisibility = true
- }
- }
-}
diff --git a/calculator/CalculatorGameOverPage.qml b/calculator/CalculatorGameOverPage.qml
deleted file mode 100644
index 395006d..0000000
--- a/calculator/CalculatorGameOverPage.qml
+++ /dev/null
@@ -1,96 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-import "./"
-
-Page {
- id: root
-
- signal pageOpened()
-
- TextField {
- id: sumInput
- placeholderText: "sum"
- visible: !endPageVisibility
- validator: IntValidator {bottom: -1000000; top: 1000000;}
- anchors {
- horizontalCenter: parent.horizontalCenter
- top: parent.top
- topMargin: parent.height * 0.1
- }
- Keys.onReturnPressed: calculator.checkSum(sumInput.text)
- }
-
- RoundButton {
- id: checkButton
- height: parent.width * 0.2
- width: height
- text: "check"
- font.pixelSize: parent.width * 0.03
- visible: !calculator.endPageVisibility
- anchors {
- horizontalCenter: parent.horizontalCenter
- top: parent.top
- topMargin: parent.height * 0.3
- }
- onClicked: {
- calculator.checkSum(sumInput.text)
- }
- }
-
- Label {
- id: won
- text: calculator.endPageLabelText
- font.pixelSize: parent.width * 0.2
- visible: calculator.endPageVisibility
- anchors {
- horizontalCenter: parent.horizontalCenter
- top: parent.top
- topMargin: parent.height * 0.05
- }
- }
-
- Label {
- id: sum
- text: "Sum: " + calculator.sum
- font.pixelSize: parent.width * 0.1
- visible: calculator.endPageVisibility ? ( won.text==="You Lose!" ? true:false):false
- anchors {
- horizontalCenter: parent.horizontalCenter
- top: parent.top
- topMargin: parent.height * 0.4
- }
- }
-
- Row {
- id: buttonRow
- anchors {
- horizontalCenter: parent.horizontalCenter
- bottom: parent.bottom
- bottomMargin: parent.height * 0.15
- }
- height: childrenRect.height
- width: childrenRect.width
- spacing: parent.width * 0.1
- visible: calculator.endPageVisibility ? true:false
-
- RoundButton {
- id: homeButton
- height: root.width * 0.2
- width: height
- text: "home"
- onClicked: {
- game.start()
- }
- }
-
- RoundButton {
- id: startButtons
- height: root.width * 0.2
- width: height
- text: "start"
- onClicked: {
- calculator.start()
- }
- }
- }
-}
diff --git a/calculator/CalculatorRunningPage.qml b/calculator/CalculatorRunningPage.qml
deleted file mode 100644
index 02a1de0..0000000
--- a/calculator/CalculatorRunningPage.qml
+++ /dev/null
@@ -1,110 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls 2.4
-import "./"
-
-Page {
- id: root
-
- signal pageOpened()
-
- Label {
- id: num
- anchors.centerIn: parent
- font.pixelSize: parent.height * 0.6
- text: calculator.nextNum
- }
-
- Label {
- id: gameProcess
- text: calculator.actualNumCount + " of " + calculator.numCount
- font.pixelSize: parent.width * 0.05
- anchors {
- right: parent.right
- rightMargin: parent.width * 0.025
- bottom: parent.bottom
- bottomMargin: parent.height * 0.05
- }
- }
-
-
- ProgressBar {
- id: prog
- property int progress: 0
- property string color: "green"
- value: progress/100
- 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
- }
-
- contentItem: Item {
- Rectangle {
- width: prog.visualPosition * parent.width
- height: parent.height
- color: prog.color
- }
- }
-
- NumberAnimation {
- id: progNumAnim
- target: prog
- property: "progress"
- from: 100
- to: 0
- duration: tick.interval
- easing.type: Easing.Linear
- }
-
- SequentialAnimation {
- id: progColAnim
- loops: 1
- ColorAnimation {
- id: progColAnim1
- target: prog
- property: "color"
- from: "green"
- to: "goldenrod"
- duration: tick.interval/2
- easing.type: Easing.Linear
- }
- ColorAnimation {
- id: progColAnim2
- target: prog
- property: "color"
- from: "goldenrod"
- to: "darkRed"
- duration: tick.interval/2
- easing.type: Easing.Linear
- }
- }
-
- }
-
- Timer {
- id: tick
- interval: calculator.tickInterval
- repeat: false
- running: calculator.state === "running"
-
- onTriggered: {
- if (calculator.actualNumCount < calculator.numCount) {
- nextNumber()
- tick.start()
- }
- else {
- calculator.state = "gameOver"
- }
- }
-
- onRunningChanged: {
- if(running){
- progNumAnim.start()
- progColAnim.start()
- }
- }
- }
-}
diff --git a/calculator/CalculatorStartPage.qml b/calculator/CalculatorStartPage.qml
deleted file mode 100644
index 2db9c16..0000000
--- a/calculator/CalculatorStartPage.qml
+++ /dev/null
@@ -1,133 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-import QtQuick.Layouts 1.3
-import "./"
-
-Page {
- id: root
-
- signal pageOpened()
-
- ColumnLayout {
- id: column
- //spacing: height / 40
- width: parent.width
- anchors.fill: parent
- anchors.topMargin: parent.height * 0.02
- anchors.bottomMargin: parent.height * 0.02
-
- Label {
- id: heading
- font.pixelSize: parent.width * 0.075
- text: "Calculator"
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.5 - width * 0.5
- Layout.rightMargin: parent.width * 0.5 - width * 0.5
- }
-
- Label {
- id: tickIntervalInfo
- text: "Interval:"
- font.pixelSize: parent.height * 0.05
- Layout.leftMargin: parent.width * 0.05
- }
-
-
- TextField {
- id: tickInterval
- text: calculator.tickInterval
- placeholderText: "interval"
- validator: IntValidator {bottom: 1; top: 100000;}
- horizontalAlignment: Qt.AlignHCenter
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- Keys.onReturnPressed: root.start()
- }
-
- Label {
- id: numCountInfo
- text: "Summands:"
- font.pixelSize: parent.height * 0.05
- Layout.leftMargin: parent.width * 0.05
- }
-
- TextField {
- id: numCount
- text: calculator.numCount
- placeholderText: "summands"
- validator: IntValidator {bottom: 1; top: 100000;}
- horizontalAlignment: Qt.AlignHCenter
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- Keys.onReturnPressed: root.start()
- }
-
- Label {
- id: minInfo
- text: "Minimum:"
- font.pixelSize: parent.height * 0.05
- Layout.leftMargin: parent.width * 0.05
- }
-
- TextField {
- id: min
- text: calculator.min
- placeholderText: "minimum"
- validator: IntValidator {bottom: -100000; top: 100000;}
- horizontalAlignment: Qt.AlignHCenter
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- Keys.onReturnPressed: root.start()
- }
-
- Label {
- id: maxInfo
- text: "Maximum:"
- font.pixelSize: parent.height * 0.05
- Layout.leftMargin: parent.width * 0.05
- }
-
- TextField {
- id: max
- text: calculator.max
- placeholderText: "maximum"
- validator: IntValidator {bottom: -100000; top: 100000;}
- horizontalAlignment: Qt.AlignHCenter
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- Keys.onReturnPressed: root.start()
- }
-
- RoundButton {
- id: startButton
- text: "start"
- height: parent.width * 0.1
- width: height
- //font.pixelSize: parent.width * 0.03
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- onClicked: {
- root.start()
- }
- }
- }
- function start() {
- if (tickInterval.text > 0 && numCount.text > 0 && max.text > min.text) {
- root.updateVars()
- calculator.run()
- }
- }
-
- function updateVars() {
- calculator.tickInterval = tickInterval.text
- calculator.numCount = numCount.text
- calculator.min = min.text
- calculator.max = max.text
-
- }
-}
diff --git a/calender/Calender.qml b/calender/Calender.qml
deleted file mode 100644
index 8dc9dd9..0000000
--- a/calender/Calender.qml
+++ /dev/null
@@ -1,197 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-import "./"
-
-Item {
- id: calender
-
- property string nextDate: "31.12.1799"
- property string lastDate: "30.12.1799"
- property int actualDateCount: 0
- property int min: 1800
- property int max: 2199
- property int tickInterval: 10000
- property int dateCount: 10
- property int correct: 0
- property int wrong: 0
- property int weekDay: 1
- property bool runningPageState: true
-
- signal pageOpened()
-
- onPageOpened: {
- calender.start()
- }
-
- states: [
- State {
- name: "starting"
- PropertyChanges {
- target: calenderStack
- currPage: calenderStartPageComp
- }
- },
-
- State {
- name: "running"
- PropertyChanges {
- target: calenderStack
- currPage: calenderRunningPageComp
- }
- },
- State {
- name: "gameOver"
- PropertyChanges {
- target: calenderStack
- currPage: calenderGameOverPageComp
- }
- }
- ]
-
- StackView {
- id: calenderStack
-
- property var currPage;
-
- anchors.fill: parent
-
- onCurrPageChanged: {
- calenderStack.replace(currPage)
- }
- onCurrentItemChanged: {
- calenderStack.currentItem.pageOpened()
- }
-
- Component {
- id: calenderStartPageComp
- CalenderStartPage {
- }
- }
-
- Component {
- id: calenderRunningPageComp
- CalenderRunningPage {
- }
- }
-
- Component {
- id: calenderGameOverPageComp
- CalenderGameOverPage {
- }
- }
-
-
- 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 start() {
- calender.reset()
- calender.state = "starting"
- }
-
- function run() {
- calender.generateNextDate()
- calender.state = "running"
- }
-
- function gameOver() {
- calender.state = "gameOver"
- }
-
- function reset() {
- calender.actualDateCount = 0
- calender.lastDate = 0
- calender.nextDate = 0
- calender.correct = 0
- calender.wrong = 0
- }
-
- function generateNextDate() {
- var daysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
- var monthCodes = [6, 2, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]
- var yearCode = 0
- var randDate = calender.nextDate
- var randDay = 31
- var randMonth = 12
- var randYear = 1799
- var range = calender.max - calender.min
- var century = 17
- var weekDay = 1
- calender.lastDate = calender.nextDate
- while (randDate === calender.lastDate) {
- //console.log("entered mainwhile " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- randYear = Math.floor((Math.random()*(range+1))+calender.min)
- //console.log("generated year " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- century = Math.floor(randYear/100)
- //console.log("calculated century " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- yearCode = (randYear - century * 100) + Math.floor((randYear - century * 100)/4)
- //console.log("generated yearCode " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- while (century > 21) {
- century -= 4
- //console.log("down count century " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- }
- switch (century) {
- case 18:
- yearCode += 3
- break
- case 19:
- yearCode += 1
- break
- case 21:
- yearCode += 5
- break
- default:
- //console.log("added century specified value to yearCode " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- }
- randMonth = Math.floor((Math.random()*(12))+1)
- //console.log("generated month " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- if (randYear % 4 === 0 && randMonth <= 2) {
- yearCode += 6
- //console.log("if leap-year " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- }
- while (yearCode >= 7) {
- yearCode -= 7
- //console.log("down count yearCode " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- }
- randDay = Math.floor((Math.random()*(daysPerMonth[randMonth-1]))+1)
- //console.log("generated Day " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- randDate = String(randDay) + "." + String(randMonth) + "." + String(randYear)
- //console.log("generated randDate " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- }
- weekDay = (yearCode + monthCodes[randMonth-1] + randDay) // - 7*Math.floor((yearCode + monthCodes[randMonth-1] + randDay)/7)
- //console.log("generated weekday " + "yearCode: " + yearCode + " randDate: " + randDate + " randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + " century: " + century + " weekDay: " + weekDay)
- //weekDay -= 7*Math.floor(weekDay/7)
- while (weekDay >= 7) {
- weekDay -= 7
- //console.log("down count weekday " + "yearCode: " + yearCode + " randDate: " + randDate + /*" randDay: " + randDay + " randMonth: " + randMonth + " randYear: " + randYear + " Range: " + range + */ " century: " + century + " weekDay: " + weekDay)
- }
- console.log("randDate: " + randDate + " yearCode: " + yearCode + " century: " + century + " weekDay: " + weekDay)
- calender.weekDay = weekDay
- calender.nextDate = randDate
- calender.actualDateCount += 1
- }
-}
-
diff --git a/calender/CalenderGameOverPage.qml b/calender/CalenderGameOverPage.qml
deleted file mode 100644
index 7867f30..0000000
--- a/calender/CalenderGameOverPage.qml
+++ /dev/null
@@ -1,52 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-import "./"
-
-Page {
- id: root
-
- signal pageOpened()
-
- Label {
- id: percent
- text: "You had " + calender.dateCount/calender.correct*100 + "% right!"
- font.pixelSize: parent.width * 0.05
- anchors {
- horizontalCenter: parent.horizontalCenter
- top: parent.top
- topMargin: parent.height * 0.2
- }
- }
-
- Row {
- id: buttonRow
- anchors {
- horizontalCenter: parent.horizontalCenter
- bottom: parent.bottom
- bottomMargin: parent.height * 0.15
- }
- height: childrenRect.height
- width: childrenRect.width
- spacing: parent.width * 0.1
-
- RoundButton {
- id: homeButton
- height: root.width * 0.2
- width: height
- text: "home"
- onClicked: {
- game.start()
- }
- }
-
- RoundButton {
- id: startButtons
- height: root.width * 0.2
- width: height
- text: "start"
- onClicked: {
- calender.start()
- }
- }
- }
-}
diff --git a/calender/CalenderRunningPage.qml b/calender/CalenderRunningPage.qml
deleted file mode 100644
index 4f07dfe..0000000
--- a/calender/CalenderRunningPage.qml
+++ /dev/null
@@ -1,138 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls 2.4
-import "./"
-
-Page {
- id: root
-
- signal pageOpened()
-
- Label {
- id: date
- anchors.centerIn: parent
- font.pixelSize: parent.height * 0.2
- text: calender.nextDate
- visible: calender.runningPageState ? true:false
- }
-
- Label {
- id: gameProcess
- text: calender.actualDateCount + " of " + calender.dateCount
- font.pixelSize: parent.width * 0.05
- anchors {
- right: parent.right
- rightMargin: parent.width * 0.025
- bottom: parent.bottom
- bottomMargin: parent.height * 0.05
- }
- }
-
-
- ProgressBar {
- id: prog
- property int progress: 0
- property string color: "green"
- value: progress/100
- 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
- }
- visible: calender.runningPageState ? true:false
- contentItem: Item {
- Rectangle {
- width: prog.visualPosition * parent.width
- height: parent.height
- color: prog.color
- }
- }
-
- NumberAnimation {
- id: progNumAnim
- target: prog
- property: "progress"
- from: 100
- to: 0
- duration: tick.interval
- easing.type: Easing.Linear
- }
-
- SequentialAnimation {
- id: progColAnim
- loops: 1
- ColorAnimation {
- id: progColAnim1
- target: prog
- property: "color"
- from: "green"
- to: "goldenrod"
- duration: tick.interval/2
- easing.type: Easing.Linear
- }
- ColorAnimation {
- id: progColAnim2
- target: prog
- property: "color"
- from: "goldenrod"
- to: "darkRed"
- duration: tick.interval/2
- easing.type: Easing.Linear
- }
- }
- }
-
- ComboBox {
- id: comboBox
- model: ["None", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
- anchors.centerIn: parent
- visible: calender.runningPageState ? false:true
- onCurrentTextChanged: {
- if (currentIndex !== 0) {
- if (currentIndex === calender.weekDay) {
- calender.correct += 1
- }
- else {
- calender.wrong += 1
- }
- /*
- Timer, {
- id: pause
- interval: 200
- repeat: false
- }
- */
-
- if (calender.actualDateCount < calender.dateCount) {
- calender.generateNextDate()
- tick.start()
- calender.runningPageState = true
- }
- else {
- calender.state = "gameOver"
- }
- }
- }
- }
-
- Timer {
- id: tick
- interval: calender.tickInterval
- repeat: false
- running: calender.state === "running"
-
- onTriggered: {
- calender.runningPageState = false
- comboBox.currentIndex = 0
- }
-
- onRunningChanged: {
- if(running){
- progNumAnim.start()
- progColAnim.start()
- }
- }
- }
-}
diff --git a/calender/CalenderStartPage.qml b/calender/CalenderStartPage.qml
deleted file mode 100644
index 79334a4..0000000
--- a/calender/CalenderStartPage.qml
+++ /dev/null
@@ -1,132 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-import QtQuick.Layouts 1.3
-import "./"
-
-Page {
- id: root
-
- signal pageOpened()
-
- ColumnLayout {
- id: column
- //spacing: height / 40
- width: parent.width
- anchors.fill: parent
- anchors.topMargin: parent.height * 0.02
- anchors.bottomMargin: parent.height * 0.02
-
- Label {
- id: heading
- font.pixelSize: parent.width * 0.075
- text: "Calender"
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.5 - width * 0.5
- Layout.rightMargin: parent.width * 0.5 - width * 0.5
- }
-
- Label {
- id: tickIntervalInfo
- text: "Interval:"
- font.pixelSize: parent.height * 0.05
- Layout.leftMargin: parent.width * 0.05
- }
-
-
- TextField {
- id: tickInterval
- text: calender.tickInterval
- placeholderText: "interval"
- validator: IntValidator {bottom: 1; top: 1000000;}
- horizontalAlignment: Qt.AlignHCenter
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- Keys.onReturnPressed: root.start()
- }
-
- Label {
- id: dateCountInfo
- text: "Dates:"
- font.pixelSize: parent.height * 0.05
- Layout.leftMargin: parent.width * 0.05
- }
-
- TextField {
- id: dateCount
- text: calender.dateCount
- placeholderText: "dates"
- validator: IntValidator {bottom: 1; top: 100000;}
- horizontalAlignment: Qt.AlignHCenter
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- Keys.onReturnPressed: root.start()
- }
-
- Label {
- id: minInfo
- text: "Minimum:"
- font.pixelSize: parent.height * 0.05
- Layout.leftMargin: parent.width * 0.05
- }
-
- TextField {
- id: min
- text: calender.min
- placeholderText: "minimum"
- validator: IntValidator {bottom: 1800; top: 10000;}
- horizontalAlignment: Qt.AlignHCenter
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- Keys.onReturnPressed: root.start()
- }
-
- Label {
- id: maxInfo
- text: "Maximum:"
- font.pixelSize: parent.height * 0.05
- Layout.leftMargin: parent.width * 0.05
- }
-
- TextField {
- id: max
- text: calender.max
- placeholderText: "maximum"
- validator: IntValidator {bottom: 1800; top: 10000;}
- horizontalAlignment: Qt.AlignHCenter
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- Keys.onReturnPressed: root.start()
- }
-
- RoundButton {
- id: startButton
- text: "start"
- height: parent.width * 0.1
- width: height
- //font.pixelSize: parent.width * 0.03
- Layout.fillWidth: true
- Layout.leftMargin: parent.width * 0.05
- Layout.rightMargin: parent.width * 0.05
- onClicked: {
- root.start()
- }
- }
- }
- function start() {
- if (tickInterval.text > 0 && dateCount.text > 0 && min.text >= 1800 && max.text >= min.text) {
- root.updateVars()
- calender.run()
- }
- }
-
- function updateVars() {
- calender.tickInterval = tickInterval.text
- calender.dateCount = dateCount.text
- calender.min = min.text
- calender.max = max.text
- }
-}
diff --git a/headers/appsettings.h b/headers/appsettings.h
new file mode 100644
index 0000000..4071294
--- /dev/null
+++ b/headers/appsettings.h
@@ -0,0 +1,42 @@
+#ifndef APPSETTINGS_H
+#define APPSETTINGS_H
+
+#include
+#include
+#include
+#include
+
+class AppSettings : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit AppSettings(QObject *parent = nullptr);
+ // This is the Constructor of the AppSettings class
+
+ ~AppSettings();
+ // This is the Destructor of the AppSettings class
+
+private:
+ QSettings *settingsManager;
+ // QSettings object which cares about our settings.ini file
+ QSettings *themeSettingsManager;
+ // QSettings object which cares about our themes
+
+signals:
+
+public slots:
+ Q_INVOKABLE QString read(const QString &key);
+ // function to read values from the settings file
+
+ Q_INVOKABLE void write(const QString &key, const QVariant &value);
+ // function to write values from the settings file
+
+ Q_INVOKABLE void setDefault(const QString &key, const QVariant &defaultValue);
+ // function to create a key (/ setting) with a default value if it hasn't been created yet
+
+ Q_INVOKABLE QString theme(QString key);
+ // function to get style settings from a theme file
+};
+
+#endif // APPSETTINGS_H
diff --git a/main.qml b/main.qml
deleted file mode 100644
index 7d18353..0000000
--- a/main.qml
+++ /dev/null
@@ -1,106 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Window 2.3
-import QtQuick.Controls 2.4
-import "./calender"
-import "./calculator"
-
-
-Window {
- visible: true
- width: 640
- height: 480
- title: qsTr("Training")
- Item {
- id: game
- anchors.fill: parent
-
- state: "starting"
-
- states: [
- State {
- name: "starting"
- PropertyChanges {
- target: mainStack
- currPage: startPageComp
- }
- },
-
- State {
- name: "calender"
- PropertyChanges {
- target: mainStack
- currPage: calenderPageComp
- }
- },
- State {
- name: "calculator"
- PropertyChanges {
- target: mainStack
- currPage: calculatorPageComp
- }
- }
- ]
-
- StackView {
- id: mainStack
-
- property var currPage
-
- anchors.fill: parent
-
- onCurrPageChanged: {
- mainStack.replace(currPage)
- }
- onCurrentItemChanged: {
- mainStack.currentItem.pageOpened()
- }
-
- Component {
- id: startPageComp
- StartPage {
- }
- }
-
- Component {
- id: calenderPageComp
- Calender {
- }
- }
-
- Component {
- id: calculatorPageComp
- Calculator {
- }
- }
-
- 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
- }
- }
- }
- function start() {
- game.state = "starting"
- }
- function calender() {
- game.state = "calender"
- }
- function calculator() {
- game.state = "calculator"
- }
- }
-}
diff --git a/mathtrainingstuff.pro b/mathtrainingstuff.pro
index de5e319..bda1f90 100644
--- a/mathtrainingstuff.pro
+++ b/mathtrainingstuff.pro
@@ -13,9 +13,16 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
- sources\main.cpp
+ sources/main.cpp \
+ sources/appsettings.cpp
+
+RESOURCES += qml/qml.qrc \
+ shared/shared.qrc
+
+HEADERS += \
+ headers/ \
+ headers/appsettings.h
-RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
@@ -27,3 +34,10 @@ QML_DESIGNER_IMPORT_PATH =
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
+
+DISTFILES += \
+ android-sources/AndroidManifest.xml
+
+android {
+ ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources
+}
diff --git a/qml.qrc b/qml.qrc
deleted file mode 100644
index 5d8ae33..0000000
--- a/qml.qrc
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
- main.qml
- calender/Calender.qml
- StartPage.qml
- calculator/CalculatorRunningPage.qml
- calculator/CalculatorStartPage.qml
- calculator/CalculatorGameOverPage.qml
- calculator/Calculator.qml
- calender/CalenderStartPage.qml
- calender/CalenderRunningPage.qml
- calender/CalenderGameOverPage.qml
-
-
diff --git a/qml/components/GameButton.qml b/qml/components/GameButton.qml
new file mode 100644
index 0000000..2d4b221
--- /dev/null
+++ b/qml/components/GameButton.qml
@@ -0,0 +1,37 @@
+import QtQuick 2.0
+import QtQuick.Controls 2.2
+
+Button {
+ id: control
+
+ width: height
+
+ font.pixelSize: width * 0.15
+
+ scale: pressed ? 0.8:1
+
+ contentItem: Text {
+ text: control.text
+ font: control.font
+ opacity: enabled ? 1.0 : 0.3
+ color: settings.theme("ButtonTextColor")
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ elide: Text.ElideRight
+ }
+
+ background: Rectangle {
+ color: settings.theme("ButtonBackgroundColor")
+ radius: width * 0.5
+ border.color: settings.theme("ButtonBorderColor")
+ border.width: parseInt(settings.theme("ButtonBorderWidth"))
+ }
+
+ Behavior on scale {
+ NumberAnimation {
+ easing.type: Easing.InOutQuad
+ duration: 200
+ }
+ }
+}
+
diff --git a/shared/shared.qrc b/shared/shared.qrc
new file mode 100644
index 0000000..fc82e42
--- /dev/null
+++ b/shared/shared.qrc
@@ -0,0 +1,5 @@
+
+
+ themes/default.ini
+
+
diff --git a/shared/themes/default.ini b/shared/themes/default.ini
new file mode 100644
index 0000000..dd494be
--- /dev/null
+++ b/shared/themes/default.ini
@@ -0,0 +1,8 @@
+[MathTrainingStuffTheme]
+PageBackgroundColor=white
+PageTextColor=black
+
+ButtonBackgroundColor=black
+ButtonTextColor=white
+ButtonBorderWidth=0
+ButtonBorderColor=
diff --git a/sources/appsettings.cpp b/sources/appsettings.cpp
new file mode 100644
index 0000000..bec5a05
--- /dev/null
+++ b/sources/appsettings.cpp
@@ -0,0 +1,86 @@
+#include "headers/appsettings.h"
+
+AppSettings::AppSettings(QObject* parent)
+ :QObject(parent)
+{
+ // This is the Constructor of the AppSettings class
+
+ // get writable path to store the settings.ini file
+ QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
+
+ qDebug() << "app settings path: " << path;
+
+ // create or open the settings.ini file
+ this->settingsManager = new QSettings(path+"/settings.ini", QSettings::IniFormat);
+
+ // set the values to their defaults if they haven't been created yet
+ this->setDefault("highscore", "0");
+
+ // create or open the settings.ini file
+ this->themeSettingsManager = new QSettings(":/themes/default.ini", QSettings::IniFormat);
+}
+
+QString AppSettings::read(const QString &key)
+{
+ // function to read values from the settings file
+
+ // open the value-group
+ this->settingsManager->beginGroup("AppSettings");
+ // read the value
+ QString value = this->settingsManager->value(key , false).toString();
+ // close the value-group
+ this->settingsManager->endGroup();
+ // return the value
+ return(value);
+}
+
+QString AppSettings::theme(QString key)
+{
+ // function to get style settings from a theme file
+
+ // open the value-group
+ this->themeSettingsManager->beginGroup("MathTrainingStuffTheme");
+ // read the value
+ QString value = this->themeSettingsManager->value(key, false).toString();
+ // close the value-group
+ this->themeSettingsManager->endGroup();
+ // return the value
+ return(value);
+}
+
+void AppSettings::write(const QString &key, const QVariant &value)
+{
+ // function to write values to the settings file
+
+ // open the value-group
+ this->settingsManager->beginGroup("AppSettings");
+ // write the value
+ this->settingsManager->setValue(key, value);
+ // close the value-group
+ this->settingsManager->endGroup();
+}
+
+void AppSettings::setDefault(const QString &key, const QVariant &defaultValue)
+{
+ // function to create a key (/ setting) with a default value if it hasnt been ceated yet
+
+ // read the current value
+ QString value = this->read(key);
+ if(value == "false"){
+ // if it is not defined yet, the read function will return "false" (as a string)
+ // -> if that is the case -> create the key with the default value
+ this->write(key, defaultValue);
+ }
+
+}
+
+AppSettings::~AppSettings()
+{
+ // This is the Destructor of the AppSettings class
+
+ // delete the settings manager
+ delete settingsManager;
+
+ // delete the theme Manager
+ delete themeSettingsManager;
+}
diff --git a/sources/main.cpp b/sources/main.cpp
index 6333b85..48cf22d 100644
--- a/sources/main.cpp
+++ b/sources/main.cpp
@@ -1,5 +1,6 @@
#include
#include
+#include "headers/appsettings.h"
int main(int argc, char *argv[])
{
@@ -7,6 +8,8 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
+ qmlRegisterType("com.max.mathtrainingstuff", 1, 0, "AppSettings");
+
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())