Warning, /education/kwordquiz/src/qml/FlashCardPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 import QtQuick 2.15 0005 import QtQuick.Layouts 1.15 0006 import QtQuick.Controls 2.15 as QQC2 0007 import org.kde.kirigami 2.20 as Kirigami 0008 import org.kde.kwordquiz 1.0 0009 0010 BasePage { 0011 id: root 0012 0013 QQC2.Action { 0014 id: checkAction 0015 0016 text: i18nc("@action:button", "Check") 0017 onTriggered: root.showAnswer = true; 0018 } 0019 0020 Timer { 0021 id: timer 0022 interval: Prefs.flipDelay * 1000 0023 onTriggered: checkAction.trigger() 0024 running: Prefs.autoFlip 0025 } 0026 0027 listView.delegate: Rectangle { 0028 id: wordDelegate 0029 0030 required property string question 0031 required property string questionSound 0032 required property string questionImage 0033 required property string answer 0034 required property string answerSound 0035 required property string answerImage 0036 0037 width: ListView.view.width 0038 height: ListView.view.height 0039 0040 color: Kirigami.Theme.backgroundColor 0041 0042 visible: !root.finished 0043 0044 ColumnLayout { 0045 anchors.centerIn: parent 0046 width: parent.width - Kirigami.Units.gridUnit * 4 0047 0048 Image { 0049 Layout.fillWidth: true 0050 Layout.maximumHeight: Kirigami.Units.gridUnit * 8 0051 0052 fillMode: Image.PreserveAspectFit 0053 smooth: true 0054 source: 'file:' + wordDelegate.questionImage 0055 } 0056 0057 Loader { 0058 active: wordDelegate.questionSound 0059 0060 Layout.fillWidth: true 0061 Layout.maximumWidth: Kirigami.Units.gridUnit * 10 0062 Layout.alignment: Qt.AlignHCenter 0063 0064 sourceComponent: SoundPlayer { 0065 source: 'file:' + wordDelegate.questionSound 0066 } 0067 } 0068 0069 Kirigami.Heading { 0070 text: wordDelegate.question.replace(/\[(.*?)\]/, '$1') 0071 wrapMode: Text.Wrap 0072 horizontalAlignment: Text.AlignHCenter 0073 font.pixelSize: 30 0074 0075 Layout.fillWidth: true 0076 } 0077 0078 QQC2.Button { 0079 action: checkAction 0080 visible: !root.showAnswer && !root.finished 0081 0082 Layout.alignment: Qt.AlignHCenter 0083 } 0084 0085 Kirigami.Separator { 0086 visible: root.showAnswer 0087 0088 Layout.fillWidth: true 0089 } 0090 0091 Image { 0092 Layout.fillWidth: true 0093 Layout.maximumHeight: Kirigami.Units.gridUnit * 8 0094 0095 fillMode: Image.PreserveAspectFit 0096 visible: root.showAnswer 0097 smooth: true 0098 source: 'file:' + wordDelegate.answerImage 0099 } 0100 0101 Loader { 0102 active: wordDelegate.answerSound && root.showAnswer 0103 0104 Layout.fillWidth: true 0105 Layout.maximumWidth: Kirigami.Units.gridUnit * 10 0106 Layout.alignment: Qt.AlignHCenter 0107 0108 sourceComponent: SoundPlayer { 0109 source: 'file:' + wordDelegate.answerSound 0110 } 0111 } 0112 0113 Kirigami.Heading { 0114 text: wordDelegate.answer.replace(/\[(.*?)\]/, '$1') 0115 wrapMode: Text.Wrap 0116 horizontalAlignment: Text.AlignHCenter 0117 font.pixelSize: 30 0118 visible: root.showAnswer 0119 0120 Layout.fillWidth: true 0121 } 0122 0123 RowLayout { 0124 Layout.alignment: Qt.AlignHCenter 0125 0126 QQC2.Button { 0127 icon.name: "know" 0128 text: i18nc("@action:button", "Correct") 0129 visible: root.showAnswer 0130 onClicked: { 0131 root.showAnswer = false; 0132 randomSortModel.unMarkAsError(listView.currentIndex); 0133 if (listView.currentIndex + 1 === listView.count) { 0134 root.finished = true; 0135 } else { 0136 listView.incrementCurrentIndex(); 0137 } 0138 0139 if (Prefs.autoFlip) { 0140 timer.restart(); 0141 } 0142 } 0143 } 0144 0145 QQC2.Button { 0146 text: i18nc("@action:button", "Not Correct") 0147 icon.name: "dontknow" 0148 visible: root.showAnswer 0149 onClicked: { 0150 root.showAnswer = false; 0151 root.errors++; 0152 randomSortModel.markAsError(listView.currentIndex); 0153 if (listView.currentIndex + 1 === listView.count) { 0154 root.finished = true; 0155 } else { 0156 listView.incrementCurrentIndex(); 0157 } 0158 0159 if (Prefs.autoFlip) { 0160 timer.restart(); 0161 } 0162 } 0163 } 0164 } 0165 } 0166 } 0167 }