diff --git a/modules/japanese/JLearner.qml b/modules/japanese/JLearner.qml index 124089b..a8eef14 100644 --- a/modules/japanese/JLearner.qml +++ b/modules/japanese/JLearner.qml @@ -71,6 +71,12 @@ PanelWindow { kanaVoicing.visible = false } + function switchResult(result) { + console.log("Result: " + result) + languageChooser.visible = true + kanaVoicing.visible = false + } + ModeChooser { id: languageChooser } @@ -79,6 +85,10 @@ PanelWindow { id: kanaVoicing } + // KanaVoicing { + // id: kanaVoicing + // } + } } } \ No newline at end of file diff --git a/modules/japanese/modules/KanaVoicing.qml b/modules/japanese/modules/KanaVoicing.qml index fbfa39b..7f9c144 100644 --- a/modules/japanese/modules/KanaVoicing.qml +++ b/modules/japanese/modules/KanaVoicing.qml @@ -20,13 +20,20 @@ Item { // Kana_Try property var currentKana: [] property int roundNum: 0 - property int maxRoundNum: 9 + property int correct: 0 + property int maxRoundNum: 10 + + function endRounds() { + console.log("Switching back") + roundNum = 0 + parent.switchResult(correct/maxRoundNum) + kanaVoicingAnswer.placeholderText = "Type Voicing..." + kanaVoicingAnswerBackground.color = kanaVoicingAnswer.activeFocus ? Colors.tertiary_fg : Colors.primary_fg + } function randomKana() { if (roundNum >= maxRoundNum) { - console.log("Switching back") - roundNum = 0 - parent.switchModeChooser() + endRounds() } var list = kanaData.kana currentKana = list[Math.floor(Math.random() * list.length)] @@ -36,9 +43,7 @@ Item { // Kana_Try function randomKnownKana() { if (roundNum >= maxRoundNum) { - console.log("Switching back") - roundNum = 0 - parent.switchModeChooser() + endRounds() } var knownList = kanaData.kana.filter(k => k.known) currentKana = knownList[Math.floor(Math.random() * knownList.length)] @@ -58,7 +63,7 @@ Item { // Kana_Try Text { id: kanaVoicingText - text: "Im Spiel" + text: "Im Spiel - Runde: " + kanaVoicing.roundNum width: parent.width horizontalAlignment: Text.AlignHCenter font.pixelSize: 28 @@ -68,54 +73,77 @@ Item { // Kana_Try Row { width: parent.width - height: parent.height - kanaVoicingTextRectangale.height - parent.spacing - spacing: 15 + height: (parent.height - kanaVoicingTextRectangale.height)*0.8 - parent.spacing*2 + spacing: 0 - MouseArea { - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - width: (parent.width - parent.spacing) / 2 + Rectangle { + color: "transparent" + width: (parent.width - kanaVoicingKanaRectangle.width)/2 + height: parent.height + } + + Rectangle { + id: kanaVoicingKanaRectangle + color: "#000000" + width: parent.height height: parent.height - onClicked: { - kanaVoicing.randomKnownKana() + Text { + id: kanaVoicingKana + text: kanaVoicing.currentKana ? kanaVoicing.currentKana.hira : "" + anchors.centerIn: parent + font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8) + color: "white" } + } + } - Rectangle { - anchors.fill: parent - color: "#FFFFFF" + TextField { + id: kanaVoicingAnswer - Text { - id: kanaVoicingKana1 - text: kanaVoicing.currentKana ? kanaVoicing.currentKana.hira : "" - anchors.centerIn: parent - font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8) - color: "black" - } + placeholderText: "Type Voicing..." + + anchors.horizontalCenter: parent.horizontalCenter + + width: parent.width / 3 + height: (parent.height - kanaVoicingTextRectangale.height) * 0.2 - parent.spacing*2 + + font.pixelSize: height * 0.8 + + color: "white" + placeholderTextColor: "#888" + + background: Rectangle { + id: kanaVoicingAnswerBackground + radius: 12 + color: kanaVoicingAnswer.activeFocus ? Colors.tertiary_fg : Colors.primary_fg + border.color: kanaVoicingAnswer.activeFocus ? Colors.tertiary : Colors.primary + border.width: 1 + } + + Keys.onReleased: { + if (event.key === Qt.Key_Escape) { + console.log("Escape pressed inside TextField") + console.log("Pressed Escape, closing JLearner") + jLearnerLoader.active = false } } - MouseArea { - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - width: (parent.width - parent.spacing) / 2 - height: parent.height - - onClicked: { - kanaVoicing.randomKnownKana() - } - - Rectangle { - anchors.fill: parent - color: "#000000" - - Text { - id: kanaVoicingKana2 - text: kanaVoicing.currentKana ? kanaVoicing.currentKana.hira : "" - anchors.centerIn: parent - font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8) - color: "white" - } + onAccepted: function(event) { + console.log("Enter pressed inside TextField") + if (kanaVoicing.currentKana.voice.includes(kanaVoicingAnswer.text.toLowerCase())){ + console.log("Correct") + kanaVoicingAnswer.text = "" + kanaVoicingAnswer.placeholderText = "[" + kanaVoicing.currentKana.voice + "]" + kanaVoicingAnswerBackground.color = "green" + kanaVoicing.correct = kanaVoicing.correct + 1 + randomKnownKana() + } else { + console.log("Wrong: [" + currentKana.voice + "]") + kanaVoicingAnswer.text = "" + kanaVoicingAnswerBackground.color = "red" + kanaVoicingAnswer.placeholderText = "[" + kanaVoicing.currentKana.voice + "]" + randomKnownKana() } } } diff --git a/modules/japanese/modules/VoicingKana.qml b/modules/japanese/modules/VoicingKana.qml new file mode 100644 index 0000000..a134f6d --- /dev/null +++ b/modules/japanese/modules/VoicingKana.qml @@ -0,0 +1,123 @@ +import QtQuick +import QtQuick.Controls +import "../../../colors" + +Item { // Kana_Try + id: voicingKana + width: window.width + height: window.height - head.height + anchors.margins: 15 + visible: false + + Component.onCompleted: { + randomKnownKana() + } + + KanaData { + id: kanaData + } + + property var currentKana: [] + + property int roundNum: 0 + property int maxRoundNum: 10 + + function randomKana() { + if (roundNum >= maxRoundNum) { + console.log("Switching back") + roundNum = 0 + parent.switchModeChooser() + } + var list = kanaData.kana + currentKana = list[Math.floor(Math.random() * list.length)] + console.log("Round Num: " + roundNum + " - Choosing Kana: " + currentKana.hira) + roundNum = roundNum + 1 + } + + function randomKnownKana() { + if (roundNum >= maxRoundNum) { + console.log("Switching back") + roundNum = 0 + parent.switchModeChooser() + } + var knownList = kanaData.kana.filter(k => k.known) + currentKana = knownList[Math.floor(Math.random() * knownList.length)] + console.log("Round Num: " + roundNum + " - Choosing Kana: " + currentKana.hira) + roundNum = roundNum + 1 + } + + Column { + anchors.fill: parent + spacing: 10 + + Rectangle { + id: voicingKanaTextRectangale + color: "#FFFFFF" + width: parent.width + height: voicingKanaText.height + parent.spacing/2 + + Text { + id: voicingKanaText + text: "Im Spiel - Runde: " + voicingKana.roundNum + width: parent.width + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 28 + color: "black" + } + } + + Row { + width: parent.width + height: parent.height - voicingKanaTextRectangale.height - parent.spacing + spacing: 15 + + MouseArea { + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + width: (parent.width - parent.spacing) / 2 + height: parent.height + + onClicked: { + voicingKana.randomKnownKana() + } + + Rectangle { + anchors.fill: parent + color: "#FFFFFF" + + Text { + id: voicingKanaKana1 + text: voicingKana.currentKana ? voicingKana.currentKana.hira : "" + anchors.centerIn: parent + font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8) + color: "black" + } + } + } + + MouseArea { + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + width: (parent.width - parent.spacing) / 2 + height: parent.height + + onClicked: { + voicingKana.randomKnownKana() + } + + Rectangle { + anchors.fill: parent + color: "#000000" + + Text { + id: voicingKanaKana2 + text: voicingKana.currentKana ? voicingKana.currentKana.hira : "" + anchors.centerIn: parent + font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8) + color: "white" + } + } + } + } + } +} \ No newline at end of file diff --git a/modules/wp/WallpaperPicker.qml b/modules/wp/WallpaperPicker.qml index 567566e..a5160ce 100644 --- a/modules/wp/WallpaperPicker.qml +++ b/modules/wp/WallpaperPicker.qml @@ -75,7 +75,6 @@ PanelWindow { pickerScope.focus = true } } - }