diff --git a/android-sources/res/drawable-hdpi/icon.png b/android-sources/res/drawable-hdpi/icon.png new file mode 100644 index 0000000..fc3e526 Binary files /dev/null and b/android-sources/res/drawable-hdpi/icon.png differ diff --git a/android-sources/res/drawable-ldpi/icon.png b/android-sources/res/drawable-ldpi/icon.png new file mode 100644 index 0000000..fc3e526 Binary files /dev/null and b/android-sources/res/drawable-ldpi/icon.png differ diff --git a/android-sources/res/drawable-mdpi/icon.png b/android-sources/res/drawable-mdpi/icon.png new file mode 100644 index 0000000..fc3e526 Binary files /dev/null and b/android-sources/res/drawable-mdpi/icon.png differ diff --git a/qml/StartPage.qml b/qml/StartPage.qml new file mode 100644 index 0000000..b6a28e0 --- /dev/null +++ b/qml/StartPage.qml @@ -0,0 +1,43 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.4 +import "./" +import "./components" + +Page { + id: root + + background: Rectangle { + color: settings.theme("PageBackgroundColor") + } + + signal pageOpened() + GameButton { + id: calenderButton + text: "calender" + height: parent.width * 0.2 + 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() + } + } + + GameButton { + id: calculatorButton + text: "calculator" + height: parent.width * 0.2 + anchors { + left: parent.left + top: parent.top + leftMargin: parent.width * 0.5 - width * 0.5 + topMargin: parent.height * 0.7 - height * 0.5 + } + onClicked: { + game.calculator() + } + } +} diff --git a/qml/calculator/Calculator.qml b/qml/calculator/Calculator.qml new file mode 100644 index 0000000..81e1019 --- /dev/null +++ b/qml/calculator/Calculator.qml @@ -0,0 +1,152 @@ +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/qml/calculator/CalculatorGameOverPage.qml b/qml/calculator/CalculatorGameOverPage.qml new file mode 100644 index 0000000..87d803a --- /dev/null +++ b/qml/calculator/CalculatorGameOverPage.qml @@ -0,0 +1,99 @@ +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import "./" +import "../components" + +Page { + id: root + + signal pageOpened() + + background: Rectangle { + color: settings.theme("PageBackgroundColor") + } + + 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) + } + + GameButton { + id: checkButton + height: parent.width * 0.2 + text: "check" + 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 + color: settings.theme("PageTextColor") + 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 + color: settings.theme("PageTextColor") + 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 + + GameButton { + id: homeButton + height: root.width * 0.2 + text: "home" + onClicked: { + game.start() + } + } + + GameButton { + id: startButtons + height: root.width * 0.2 + text: "start" + onClicked: { + calculator.start() + } + } + } +} diff --git a/qml/calculator/CalculatorRunningPage.qml b/qml/calculator/CalculatorRunningPage.qml new file mode 100644 index 0000000..08a2f80 --- /dev/null +++ b/qml/calculator/CalculatorRunningPage.qml @@ -0,0 +1,116 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.4 +import "./" + +Page { + id: root + + signal pageOpened() + + background: Rectangle { + color: settings.theme("PageBackgroundColor") + } + + Label { + id: num + anchors.centerIn: parent + font.pixelSize: parent.height * 0.6 + text: calculator.nextNum + color: settings.theme("PageTextColor") + } + + Label { + id: gameProcess + text: calculator.actualNumCount + " of " + calculator.numCount + font.pixelSize: parent.width * 0.05 + color: settings.theme("PageTextColor") + 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/qml/calculator/CalculatorStartPage.qml b/qml/calculator/CalculatorStartPage.qml new file mode 100644 index 0000000..74b4f7e --- /dev/null +++ b/qml/calculator/CalculatorStartPage.qml @@ -0,0 +1,143 @@ +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.3 +import "./" +import "../components" + +Page { + id: root + + signal pageOpened() + + background: Rectangle { + color: settings.theme("PageBackgroundColor") + } + + 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" + color: settings.theme("PageTextColor") + 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:" + color: settings.theme("PageTextColor") + 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 + color: settings.theme("PageTextColor") + 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 + color: settings.theme("PageTextColor") + 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 + color: settings.theme("PageTextColor") + 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/qml/calender/Calender.qml b/qml/calender/Calender.qml new file mode 100644 index 0000000..8dc9dd9 --- /dev/null +++ b/qml/calender/Calender.qml @@ -0,0 +1,197 @@ +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/qml/calender/CalenderGameOverPage.qml b/qml/calender/CalenderGameOverPage.qml new file mode 100644 index 0000000..cc90446 --- /dev/null +++ b/qml/calender/CalenderGameOverPage.qml @@ -0,0 +1,57 @@ +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import "./" + +Page { + id: root + + signal pageOpened() + + background: Rectangle { + color: settings.theme("PageBackgroundColor") + } + + Label { + id: percent + text: "You had " + calender.dateCount/calender.correct*100 + "% right!" + font.pixelSize: parent.width * 0.05 + color: settings.theme("PageTextColor") + 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/qml/calender/CalenderRunningPage.qml b/qml/calender/CalenderRunningPage.qml new file mode 100644 index 0000000..75039b0 --- /dev/null +++ b/qml/calender/CalenderRunningPage.qml @@ -0,0 +1,144 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.4 +import "./" + +Page { + id: root + + signal pageOpened() + + background: Rectangle { + color: settings.theme("PageBackgroundColor") + } + + Label { + id: date + anchors.centerIn: parent + font.pixelSize: parent.height * 0.2 + text: calender.nextDate + visible: calender.runningPageState ? true:false + color: settings.theme("PageTextColor") + } + + Label { + id: gameProcess + text: calender.actualDateCount + " of " + calender.dateCount + font.pixelSize: parent.width * 0.05 + color: settings.theme("PageTextColor") + 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/qml/calender/CalenderStartPage.qml b/qml/calender/CalenderStartPage.qml new file mode 100644 index 0000000..8abd8ac --- /dev/null +++ b/qml/calender/CalenderStartPage.qml @@ -0,0 +1,142 @@ +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.3 +import "./" + +Page { + id: root + + signal pageOpened() + + background: Rectangle { + color: settings.theme("PageBackgroundColor") + } + + 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" + color: settings.theme("PageTextColor") + 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 + color: settings.theme("PageTextColor") + 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 + color: settings.theme("PageTextColor") + Layout.leftMargin: parent.width * 0.05 + } + + TextField { + id: dateCount + text: calender.dateCount + placeholderText: "dates" + validator: IntValidator {bottom: 1; top: 100000;} + color: settings.theme("PageTextColor") + 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 + color: settings.theme("PageTextColor") + 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 + color: settings.theme("PageTextColor") + 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/qml/main.qml b/qml/main.qml new file mode 100644 index 0000000..1eb02b5 --- /dev/null +++ b/qml/main.qml @@ -0,0 +1,114 @@ +import QtQuick 2.9 +import QtQuick.Window 2.3 +import QtQuick.Controls 2.4 +import "./calender" +import "./calculator" +import com.max.mathtrainingstuff 1.0 + + +Window { + visible: true + width: 540 * 0.6 + height: 960 * 0.6 + title: qsTr("Training") + + color: settings.theme("PageBackgroundColor") + + Item { + id: game + anchors.fill: parent + + AppSettings { + id: settings + } + + 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/qml/qml.qrc b/qml/qml.qrc new file mode 100644 index 0000000..a9a893e --- /dev/null +++ b/qml/qml.qrc @@ -0,0 +1,15 @@ + + + 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 + components/GameButton.qml + + diff --git a/shared/icons/math.png b/shared/icons/math.png new file mode 100644 index 0000000..fc3e526 Binary files /dev/null and b/shared/icons/math.png differ