rename of jlearner and additions to readme
This commit is contained in:
@@ -0,0 +1,293 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import "../../../colors"
|
||||
|
||||
Item { // Chooser
|
||||
id: learnerResult
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.margins: 15
|
||||
visible: false
|
||||
|
||||
function switch_KanaVoicing() {
|
||||
parent.switch_KanaVoicing()
|
||||
}
|
||||
|
||||
function start() {
|
||||
}
|
||||
|
||||
property real result: 0
|
||||
property string mode: ""
|
||||
property var results: createResults(10)
|
||||
|
||||
function createResults(n) {
|
||||
var arr = []
|
||||
for (var i = 0; i < n; i++) {
|
||||
arr.push({
|
||||
kana: "あ",
|
||||
correctness: false,
|
||||
answer: "a",
|
||||
correct: "a"
|
||||
})
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
|
||||
Rectangle {
|
||||
id: learnerResultUpperText
|
||||
color: Colors.primaryContainer
|
||||
width: parent.width
|
||||
height: parent.height * 0.1
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text {
|
||||
id: mainText
|
||||
text: "Ergebnisse:"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: parent.height * 0.6
|
||||
color: Colors.primary
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
height: parent.height - learnerResultUpperText.height - parent.spacing
|
||||
spacing: 10
|
||||
Rectangle {
|
||||
width: parent.width * 0.25
|
||||
height: parent.height
|
||||
color: "transparent"
|
||||
Column{
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
spacing: 10
|
||||
|
||||
Repeater{
|
||||
model: results
|
||||
|
||||
Row{
|
||||
width: parent.width
|
||||
height: parent.height/10 - parent.spacing * 0.9
|
||||
spacing: 10
|
||||
|
||||
Rectangle{
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
color: Colors.primaryContainer
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text{
|
||||
text: modelData.kana
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: -parent.height * 0.125
|
||||
anchors.horizontalCenterOffset: parent.width * 0.1
|
||||
font.pixelSize: parent.height * 0.8
|
||||
color: modelData.correctness ? "green" : "red"
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
color: Colors.primaryContainer
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Image {
|
||||
source: modelData.correctness ? "../../../colors/icons/correct.svg" : "../../../colors/icons/wrong.svg"
|
||||
anchors.centerIn: parent
|
||||
width: parent.height*0.8
|
||||
height: parent.height*0.8
|
||||
|
||||
smooth: true
|
||||
sourceSize.width: width
|
||||
sourceSize.height: height
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
width: parent.width - parent.height *2 - parent.spacing*2
|
||||
height: parent.height
|
||||
color: Colors.primaryContainer
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text{
|
||||
text: "[" + modelData.correct + "]"
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.centerIn: parent
|
||||
anchors.horizontalCenterOffset: 10
|
||||
font.pixelSize: parent.height * 0.8
|
||||
color: modelData.correctness ? "green" : "red"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
width: parent.width * 0.75
|
||||
height: parent.height
|
||||
color: "transparent"
|
||||
Column{
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
spacing: 10
|
||||
Row {
|
||||
spacing: 10
|
||||
width: parent.width
|
||||
height: parent.height * 4 / 10 - parent.spacing * 2 / 3
|
||||
|
||||
Rectangle {
|
||||
color: "transparent"
|
||||
width: (parent.width - (learnerLastResultKanaBG.width + learnerLastResultTextBG.width))/2
|
||||
height: parent.height
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: learnerLastResultKanaBG
|
||||
color: results[results.length-1].correctness ? "green" : "red"
|
||||
width: parent.height - parent.spacing
|
||||
height: parent.height
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text {
|
||||
id: learnerLastResultKana
|
||||
text: results[results.length-1].kana
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: -parent.height * 0.1
|
||||
font.pixelSize: parent.height * 0.8
|
||||
color: Colors.primary
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: learnerLastResultTextBG
|
||||
color: results[results.length-1].correctness ? "green" : "red"
|
||||
width: learnerLastResultText.width + 2 * parent.spacing
|
||||
height: parent.height
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text {
|
||||
id: learnerLastResultText
|
||||
text: "[" + results[results.length-1].correct + "]"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: learnerLastResultKana.font.pixelSize/2
|
||||
color: Colors.primary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: learnerResultTextBG
|
||||
color: Colors.primaryContainer
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width
|
||||
height: parent.height * 3 / 10 - parent.spacing * 2 / 3
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text {
|
||||
id: learnerResultText
|
||||
text: result*100 + "% Richtig"
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8)
|
||||
color: Colors.primary
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
height: parent.height * 3 / 10 - parent.spacing * 2 / 3
|
||||
spacing: 10
|
||||
|
||||
MouseArea {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
width: parent.width / 2 - parent.spacing
|
||||
height: parent.height
|
||||
|
||||
onClicked: {
|
||||
console.log("Choosing White Window")
|
||||
mode === "KanaVoicing" ? learnerResult.parent.switch_KanaVoicing() : learnerResult.parent.switch_VoicingKana()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: parent.containsMouse ? Colors.secondaryContainer_fg : Colors.secondaryContainer
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: parent.containsMouse ? Colors.secondaryContainer : Colors.secondaryContainer_fg
|
||||
|
||||
Text {
|
||||
text: "Again"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8)
|
||||
color: parent.parent.containsMouse ? Colors.secondary_fg : Colors.secondary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
width: parent.width / 2 - parent.spacing
|
||||
height: parent.height
|
||||
|
||||
onClicked: {
|
||||
console.log("Choosing Black Window")
|
||||
learnerResult.parent.switchModeChooser()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: parent.containsMouse ? Colors.secondaryContainer_fg : Colors.secondaryContainer
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: parent.containsMouse ? Colors.secondaryContainer : Colors.secondaryContainer_fg
|
||||
|
||||
Text {
|
||||
text: "Menu"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8)
|
||||
color: parent.parent.containsMouse ? Colors.secondary_fg : Colors.secondary
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
property var kana: [
|
||||
{ hira: "あ", voice: ["a"], known: true },
|
||||
{ hira: "い", voice: ["i"], known: true },
|
||||
{ hira: 'う', voice: ["u"], known: true },
|
||||
{ hira: 'え', voice: ["e"], known: true },
|
||||
{ hira: 'お', voice: ["o"], known: true },
|
||||
{ hira: 'か', voice: ["ka"], known: true },
|
||||
{ hira: 'が', voice: ["ga"], known: true },
|
||||
{ hira: 'き', voice: ["ki"], known: true },
|
||||
{ hira: 'ぎ', voice: ["gi"], known: true },
|
||||
{ hira: 'く', voice: ["ku"], known: true },
|
||||
{ hira: 'ぐ', voice: ["gu"], known: true },
|
||||
{ hira: 'け', voice: ["ke"], known: true },
|
||||
{ hira: 'げ', voice: ["ge"], known: true },
|
||||
{ hira: 'こ', voice: ["ko"], known: true },
|
||||
{ hira: 'ご', voice: ["go"], known: true },
|
||||
{ hira: 'さ', voice: ["sa"], known: true },
|
||||
{ hira: 'ざ', voice: ["za"], known: true },
|
||||
{ hira: 'し', voice: ["si", "shi"], known: true },
|
||||
{ hira: 'じ', voice: ["zi", "ji"], known: true },
|
||||
{ hira: 'す', voice: ["su"], known: true },
|
||||
{ hira: 'ず', voice: ["zu"], known: true },
|
||||
{ hira: 'せ', voice: ["se"], known: true },
|
||||
{ hira: 'ぜ', voice: ["ze"], known: true },
|
||||
{ hira: 'そ', voice: ["so"], known: true },
|
||||
{ hira: 'ぞ', voice: ["zo"], known: true },
|
||||
{ hira: 'た', voice: ["ta"], known: true },
|
||||
{ hira: 'だ', voice: ["da"], known: true },
|
||||
{ hira: 'ち', voice: ["ti", "shi"], known: true },
|
||||
{ hira: 'ぢ', voice: ["di", "ji"], known: true },
|
||||
{ hira: 'つ', voice: ["tu", "tsu"], known: true },
|
||||
{ hira: 'づ', voice: ["du", "zu"], known: true },
|
||||
{ hira: 'て', voice: ["te"], known: true },
|
||||
{ hira: 'で', voice: ["de"], known: true },
|
||||
{ hira: 'と', voice: ["to"], known: true },
|
||||
{ hira: 'ど', voice: ["do"], known: true },
|
||||
{ hira: 'な', voice: ["na"], known: true },
|
||||
{ hira: 'に', voice: ["ni"], known: true },
|
||||
{ hira: 'ぬ', voice: ["nu"], known: false },
|
||||
{ hira: 'ね', voice: ["ne"], known: false },
|
||||
{ hira: 'の', voice: ["no"], known: false },
|
||||
{ hira: 'は', voice: ["ha"], known: false },
|
||||
{ hira: 'ば', voice: ["ba"], known: false },
|
||||
{ hira: 'ぱ', voice: ["pa"], known: false },
|
||||
{ hira: 'ひ', voice: ["hi"], known: false },
|
||||
{ hira: 'び', voice: ["bi"], known: false },
|
||||
{ hira: 'ぴ', voice: ["pi"], known: false },
|
||||
{ hira: 'ふ', voice: ["hu"], known: false },
|
||||
{ hira: 'ぶ', voice: ["bu"], known: false },
|
||||
{ hira: 'ぷ', voice: ["pu"], known: false },
|
||||
{ hira: 'へ', voice: ["he"], known: false },
|
||||
{ hira: 'べ', voice: ["be"], known: false },
|
||||
{ hira: 'ぺ', voice: ["pe"], known: false },
|
||||
{ hira: 'ほ', voice: ["ho"], known: false },
|
||||
{ hira: 'ぼ', voice: ["bo"], known: false },
|
||||
{ hira: 'ぽ', voice: ["po"], known: false },
|
||||
{ hira: 'ま', voice: ["ma"], known: false },
|
||||
{ hira: 'み', voice: ["mi"], known: false },
|
||||
{ hira: 'む', voice: ["mu"], known: false },
|
||||
{ hira: 'め', voice: ["me"], known: false },
|
||||
{ hira: 'も', voice: ["mo"], known: false },
|
||||
{ hira: 'や', voice: ["ya"], known: false },
|
||||
{ hira: 'ゆ', voice: ["yu"], known: false },
|
||||
{ hira: 'よ', voice: ["yo"], known: false },
|
||||
{ hira: 'ら', voice: ["ra"], known: false },
|
||||
{ hira: 'り', voice: ["ri"], known: false },
|
||||
{ hira: 'る', voice: ["ru"], known: false },
|
||||
{ hira: 'れ', voice: ["re"], known: false },
|
||||
{ hira: 'ろ', voice: ["ro"], known: false },
|
||||
{ hira: 'わ', voice: ["wa"], known: false },
|
||||
{ hira: 'ゐ', voice: ["wi"], known: false },
|
||||
{ hira: 'ゑ', voice: ["we"], known: false },
|
||||
{ hira: 'を', voice: ["wo"], known: false },
|
||||
{ hira: 'ん', voice: ["n"], known: true },
|
||||
{ hira: 'ゔ', voice: ["vu"], known: false }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import "../../../colors"
|
||||
|
||||
Item { // Kana_Try
|
||||
id: kanaVoicing
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.margins: 15
|
||||
visible: false
|
||||
|
||||
// Component.onCompleted: {
|
||||
// randomKnownKana()
|
||||
// }
|
||||
|
||||
function start() {
|
||||
kanaVoicingAnswer.focus = true
|
||||
roundNum = 0
|
||||
randomKnownKana()
|
||||
}
|
||||
|
||||
KanaData {
|
||||
id: kanaData
|
||||
}
|
||||
|
||||
property var currentKana: []
|
||||
|
||||
property int roundNum: 0
|
||||
property int correct: 0
|
||||
property int maxRoundNum: 10
|
||||
|
||||
property var pastKana: []
|
||||
property var pastCorrectness: []
|
||||
|
||||
function endRounds() {
|
||||
kanaVoicingAnswer.focus = false
|
||||
jLearnerScope.focus = true
|
||||
console.log("Switching back")
|
||||
parent.switchResult(correct/maxRoundNum, "KanaVoicing", pastCorrectness)
|
||||
pastKana = []
|
||||
pastCorrectness = []
|
||||
correct = 0
|
||||
kanaVoicingAnswer.placeholderText = "Type Voicing..."
|
||||
kanaVoicingAnswerBackground.color = kanaVoicingAnswer.activeFocus ? Colors.tertiary_fg : Colors.primary_fg
|
||||
}
|
||||
|
||||
function randomKana() {
|
||||
if (roundNum >= maxRoundNum) {
|
||||
endRounds()
|
||||
}
|
||||
var list = kanaData.kana
|
||||
currentKana = list[Math.floor(Math.random() * list.length)]
|
||||
if (knownList.length > maxRoundNum) {
|
||||
while (pastKana.includes(currentKana)) {
|
||||
currentKana = list[Math.floor(Math.random() * list.length)]
|
||||
}
|
||||
}
|
||||
pastKana.push(currentKana)
|
||||
console.log("Round Num: " + roundNum + " - Choosing Kana: " + currentKana.hira)
|
||||
roundNum = roundNum + 1
|
||||
}
|
||||
|
||||
function randomKnownKana() {
|
||||
if (roundNum >= maxRoundNum) {
|
||||
endRounds()
|
||||
}
|
||||
var knownList = kanaData.kana.filter(k => k.known)
|
||||
currentKana = knownList[Math.floor(Math.random() * knownList.length)]
|
||||
if (knownList.length > maxRoundNum) {
|
||||
while (pastKana.includes(currentKana)) {
|
||||
currentKana = knownList[Math.floor(Math.random() * knownList.length)]
|
||||
}
|
||||
}
|
||||
pastKana.push(currentKana)
|
||||
console.log("Round Num: " + roundNum + " - Choosing Kana: " + currentKana.hira)
|
||||
roundNum = roundNum + 1
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
|
||||
Rectangle {
|
||||
id: kanaVoicingTextRectangale
|
||||
color: Colors.primaryContainer
|
||||
width: kanaVoicingText.width + 20
|
||||
height: parent.height * 0.1
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text {
|
||||
id: kanaVoicingText
|
||||
text: "Im Spiel - Runde: " + kanaVoicing.roundNum
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: parent.height * 0.6
|
||||
color: Colors.primary
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: kanaVoicingKanaRectangle
|
||||
color: Colors.primaryContainer
|
||||
height: (parent.height - kanaVoicingTextRectangale.height)*0.75
|
||||
width: height
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text {
|
||||
id: kanaVoicingKana
|
||||
text: typeof kanaVoicing.currentKana.hira === "undefined" ? "" : kanaVoicing.currentKana.hira
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8)
|
||||
color: Colors.primary
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: kanaVoicingAnswer
|
||||
|
||||
placeholderText: "Type Voicing..."
|
||||
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
width: parent.width/2
|
||||
height: (parent.height - kanaVoicingTextRectangale.height)*0.25 - parent.spacing*2
|
||||
|
||||
font.pixelSize: height * 0.8
|
||||
|
||||
color: Colors.secondary_fg
|
||||
placeholderTextColor: Colors.secondary
|
||||
|
||||
background: Rectangle {
|
||||
id: kanaVoicingAnswerBackground
|
||||
radius: 10
|
||||
color: kanaVoicingAnswer.activeFocus ? Colors.secondaryContainer : Colors.secondaryContainer_fg
|
||||
border.color: kanaVoicingAnswer.activeFocus ? Colors.secondaryContainer_fg : Colors.secondaryContainer
|
||||
border.width: 1
|
||||
}
|
||||
|
||||
Keys.onReleased: function(event) {
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
console.log("Escape pressed inside TextField")
|
||||
console.log("Pressed Escape, closing JLearner")
|
||||
jLearnerLoader.active = false
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
pastCorrectness.push({
|
||||
kana: kanaVoicing.currentKana.hira,
|
||||
correctness: true,
|
||||
answer: kanaVoicingAnswer.text.toLowerCase(),
|
||||
correct: kanaVoicing.currentKana.voice.join("|")
|
||||
})
|
||||
} else {
|
||||
console.log("Wrong: [" + currentKana.voice + "]")
|
||||
kanaVoicingAnswer.text = ""
|
||||
kanaVoicingAnswerBackground.color = "red"
|
||||
kanaVoicingAnswer.placeholderText = "[" + kanaVoicing.currentKana.voice + "]"
|
||||
pastCorrectness.push({
|
||||
kana: kanaVoicing.currentKana.hira,
|
||||
correctness: false,
|
||||
answer: kanaVoicingAnswer.text.toLowerCase(),
|
||||
correct: kanaVoicing.currentKana.voice.join("|")
|
||||
})
|
||||
}
|
||||
randomKnownKana()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import "../../../colors"
|
||||
|
||||
Item { // Chooser
|
||||
id: languageChooser
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.margins: 15
|
||||
visible: false
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
|
||||
Rectangle {
|
||||
id: modeChooserUpperText
|
||||
color: Colors.primaryContainer
|
||||
width: mainText.width + 20
|
||||
height: parent.height * 0.1
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text {
|
||||
id: mainText
|
||||
text: "Wähle ein Modus:"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: parent.height * 0.6
|
||||
color: Colors.primary
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
height: parent.height - modeChooserUpperText.height - parent.spacing
|
||||
spacing: 10
|
||||
|
||||
MouseArea {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
width: (parent.width - parent.spacing) / 2
|
||||
height: parent.height
|
||||
|
||||
onClicked: {
|
||||
console.log("Choosing White Window")
|
||||
languageChooser.parent.switch_KanaVoicing()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: parent.containsMouse ? Colors.secondaryContainer_fg : Colors.secondaryContainer
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: parent.containsMouse ? Colors.secondaryContainer : Colors.secondaryContainer_fg
|
||||
|
||||
Text {
|
||||
text: "Kana to Voicing"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8)
|
||||
color: parent.parent.containsMouse ? Colors.secondary_fg : Colors.secondary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
width: (parent.width - parent.spacing) / 2
|
||||
height: parent.height
|
||||
|
||||
onClicked: {
|
||||
console.log("Choosing Black Window")
|
||||
languageChooser.parent.switch_VoicingKana()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: parent.containsMouse ? Colors.secondaryContainer_fg : Colors.secondaryContainer
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: parent.containsMouse ? Colors.secondaryContainer : Colors.secondaryContainer_fg
|
||||
|
||||
Text {
|
||||
text: "Voicing to Kana"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: Math.min(parent.width / text.length * 1.2, parent.height * 0.8)
|
||||
color: parent.parent.containsMouse ? Colors.secondary_fg : Colors.secondary
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import "../../../colors"
|
||||
|
||||
Item { // Kana_Try
|
||||
id: voicingKana
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.margins: 15
|
||||
visible: false
|
||||
|
||||
// Component.onCompleted: {
|
||||
// randomKnownKana()
|
||||
// }
|
||||
|
||||
function start() {
|
||||
roundNum = 0
|
||||
new_round()
|
||||
}
|
||||
|
||||
KanaData {
|
||||
id: kanaData
|
||||
}
|
||||
|
||||
property int roundNum: 0
|
||||
property int correct: 0
|
||||
property int maxRoundNum: 10
|
||||
|
||||
property var pastKana: []
|
||||
property var pastCorrectness: []
|
||||
|
||||
property var kanaArray: createResults(6)
|
||||
property var targetKana: kanaArray[Math.floor(Math.random() * kanaArray.length)]
|
||||
|
||||
function createResults(n) {
|
||||
var arr = []
|
||||
for (var i = 0; i < n; i++) {
|
||||
arr.push({ hira: "あ", voice: ["a"], known: true })
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
function new_round() {
|
||||
roundNum = roundNum + 1
|
||||
kanaArray = gemerateKanaArray()
|
||||
targetKana = kanaArray[Math.floor(Math.random() * kanaArray.length)]
|
||||
console.log("Round Num: " + roundNum + " - Choosing Kana: " + targetKana.hira)
|
||||
pastKana.push(targetKana)
|
||||
}
|
||||
|
||||
function gemerateKanaArray() {
|
||||
var arr = []
|
||||
for (var i = 0; i < 6; i++) {
|
||||
arr.push(randomKnownKana(arr))
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
function randomKana(arr) {
|
||||
if (roundNum > maxRoundNum) {
|
||||
endRounds()
|
||||
}
|
||||
var list = kanaData.kana
|
||||
var newKana = list[Math.floor(Math.random() * list.length)]
|
||||
|
||||
var arrExists = Array.isArray(arr)
|
||||
|
||||
if (knownList.length > maxRoundNum + 6) {
|
||||
if (arrExists) {
|
||||
while (pastKana.includes(newKana) || arr.includes(newKana)) {
|
||||
newKana = list[Math.floor(Math.random() * list.length)]
|
||||
}
|
||||
} else{
|
||||
while (pastKana.includes(newKana)){
|
||||
newKana = list[Math.floor(Math.random() * list.length)]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (arrExists) {
|
||||
while (arr.includes(newKana)) {
|
||||
newKana = list[Math.floor(Math.random() * list.length)]
|
||||
}
|
||||
}
|
||||
}
|
||||
kanaArray.push(newKana)
|
||||
return newKana
|
||||
}
|
||||
|
||||
function randomKnownKana(arr) {
|
||||
if (roundNum > maxRoundNum) {
|
||||
endRounds()
|
||||
}
|
||||
var knownList = kanaData.kana.filter(k => k.known)
|
||||
var newKana = knownList[Math.floor(Math.random() * knownList.length)]
|
||||
|
||||
var arrExists = Array.isArray(arr)
|
||||
|
||||
if (knownList.length > maxRoundNum + 6) {
|
||||
if (arrExists) {
|
||||
while (pastKana.includes(newKana) || arr.includes(newKana)) {
|
||||
newKana = knownList[Math.floor(Math.random() * knownList.length)]
|
||||
}
|
||||
} else{
|
||||
while (pastKana.includes(newKana)){
|
||||
newKana = knownList[Math.floor(Math.random() * knownList.length)]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (arrExists) {
|
||||
while (arr.includes(newKana)) {
|
||||
newKana = knownList[Math.floor(Math.random() * knownList.length)]
|
||||
}
|
||||
}
|
||||
}
|
||||
return newKana
|
||||
}
|
||||
|
||||
function endRounds() {
|
||||
console.log("Switching back")
|
||||
roundNum = 0
|
||||
parent.switchResult(correct/maxRoundNum, "VoicingKana", pastCorrectness)
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
|
||||
Rectangle {
|
||||
id: voicingKanaTextRectangale
|
||||
color: Colors.primaryContainer
|
||||
width: mainText.width + 20
|
||||
height: parent.height * 0.1
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text {
|
||||
id: mainText
|
||||
text: "Runde: " + roundNum + " - [" + targetKana.voice.join("|") + "]:"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: parent.height * 0.6
|
||||
color: Colors.primary
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
width: parent.width
|
||||
height: parent.height - voicingKanaTextRectangale.height - voicingKanaResultRectangale.height - parent.spacing * 2
|
||||
color: "transparent"
|
||||
Grid {
|
||||
id: grid
|
||||
anchors.fill: parent
|
||||
columns: 3
|
||||
spacing: 10
|
||||
|
||||
property int rows: 2
|
||||
|
||||
// calculate cell width and height based on parent size, spacing, and number of columns/rows
|
||||
property real cellWidth: (width - (columns - 1) * spacing) / columns
|
||||
property real cellHeight: (height - (rows - 1) * spacing) / rows
|
||||
|
||||
Repeater {
|
||||
model: kanaArray
|
||||
MouseArea {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
width: grid.cellWidth
|
||||
height: grid.cellHeight
|
||||
|
||||
onClicked: {
|
||||
console.log("Choose a Kana: " + modelData.hira)
|
||||
if (modelData.hira === targetKana.hira) {
|
||||
console.log("Correct")
|
||||
correct = correct + 1
|
||||
voicingKanaResultRectangale.color = "green"
|
||||
} else {
|
||||
console.log("Wrong: [" + targetKana.hira + "]")
|
||||
voicingKanaResultRectangale.color = "red"
|
||||
}
|
||||
pastCorrectness.push({
|
||||
kana: targetKana.hira,
|
||||
correctness: modelData.hira === targetKana.hira,
|
||||
answer: modelData.hira,
|
||||
correct: targetKana.voice.join("|")
|
||||
})
|
||||
voicingKanaResult.text = "Letzte Runde: " + targetKana.hira + ": " + "[" + targetKana.voice.join("|") + "]"
|
||||
new_round()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
color: parent.containsMouse ? Colors.secondaryContainer_fg : Colors.secondaryContainer
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: parent.containsMouse ? Colors.secondaryContainer : Colors.secondaryContainer_fg
|
||||
|
||||
Text{
|
||||
text: modelData.hira
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: -parent.height * 0.1
|
||||
font.pixelSize: parent.height * 0.8
|
||||
color: parent.parent.containsMouse ? Colors.secondary_fg : Colors.secondary
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: voicingKanaResultRectangale
|
||||
color: Colors.primaryContainer
|
||||
width: voicingKanaResult.width + 20
|
||||
height: parent.height * 0.1
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
radius: 10
|
||||
border.width: 2
|
||||
border.color: Colors.primaryContainer_fg
|
||||
|
||||
Text {
|
||||
id: voicingKanaResult
|
||||
text: "Wähle das richtige Zeichen"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: parent.height * 0.6
|
||||
color: Colors.primary
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user