3
* Copyright (C) Siddhesh suthar <siddhesh.it@gmail.com> (Qt Quick port)
6
* Pascal Georges (pascal.georges1@free.fr) (GTK+ version)
7
* Holger Kaelberer <holger.k@elberer.de> (Qt Quick port of imageid)
8
* Siddhesh suthar <siddhesh.it@gmail.com> (Qt Quick port)
9
* Bruno Coudoin <bruno.coudoin@gcompris.net> (Integration Lang dataset)
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 3 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, see <https://www.gnu.org/licenses/>.
26
import QtGraphicalEffects 1.0
29
import "lang.js" as Activity
30
import "quiz.js" as QuizActivity
36
property alias background: background
37
property alias bonus: bonus
38
property alias score: score
39
property alias wordImage: wordImage
40
property alias imageFrame: imageFrame
41
property alias wordListModel: wordListModel
42
property alias wordListView: wordListView
43
property alias parser: parser
45
property bool horizontalLayout: background.width >= background.height
46
property bool buttonsBlocked: false
48
function init(loadedItems_, wordList_, mode_) {
50
loadedItems_.forceActiveFocus()
51
return QuizActivity.init(loadedItems_, wordList_, mode_)
54
onGoodWordChanged: Activity.playWord(goodWord.voice)
56
Behavior on opacity { PropertyAnimation { duration: 200 } }
60
source: "qrc:/gcompris/src/activities/lang/resource/imageid-bg.svg"
61
fillMode: Image.PreserveAspectCrop
62
sourceSize.width: Math.max(parent.width, parent.height)
66
property bool keyNavigation: false
68
Keys.enabled: !quiz.buttonsBlocked
70
Keys.onEscapePressed: {
73
Keys.onRightPressed: {
75
wordListView.incrementCurrentIndex()
79
wordListView.decrementCurrentIndex()
83
wordListView.incrementCurrentIndex()
87
wordListView.decrementCurrentIndex()
89
Keys.onSpacePressed: {
91
wordListView.currentItem.children[1].pressed()
93
Keys.onEnterPressed: {
95
wordListView.currentItem.children[1].pressed()
97
Keys.onReturnPressed: {
99
wordListView.currentItem.children[1].pressed()
102
if (event.key === Qt.Key_Back) {
103
event.accepted = true
111
onError: console.error("Lang: Error parsing json: " + msg);
120
columns: quiz.horizontalLayout ? 2 : 1
121
spacing: 0.5 * ApplicationInfo.ratio
123
anchors.margins: 10 * ApplicationInfo.ratio
126
width: quiz.horizontalLayout
127
? background.width * 0.40
128
: background.width - gridId.anchors.margins * 2
129
height: quiz.horizontalLayout
130
? background.height - bar.height
131
: (background.height - bar.height) * 0.4
136
horizontalCenter: parent.horizontalCenter
137
verticalCenter: parent.verticalCenter
139
source: "qrc:/gcompris/src/activities/lang/resource/imageid_frame.svg"
140
sourceSize.width: quiz.horizontalLayout ? parent.width * 0.7 : quiz.width - repeatItem.width - score.width - 50 * ApplicationInfo.ratio
142
visible: QuizActivity.mode !== 3
146
// Images are not svg
147
width: Math.min(parent.width, parent.height) * 0.9
149
anchors.centerIn: parent
151
property string nextSource
152
function changeSource(nextSource_) {
153
nextSource = nextSource_
157
SequentialAnimation {
168
value: wordImage.nextSource
179
onClicked: Activity.playWord(goodWord.voice)
188
width: quiz.horizontalLayout
189
? background.width * 0.55
190
: background.width - gridId.anchors.margins * 2
191
height: quiz.horizontalLayout
192
? background.height - bar.height
193
: (background.height - bar.height) * 0.60
194
spacing: 2 * ApplicationInfo.ratio
195
orientation: Qt.Vertical
196
verticalLayoutDirection: ListView.TopToBottom
200
highlight: Rectangle {
201
width: wordListView.width
202
height: wordListView.buttonHeight
203
color: "lightsteelblue"
205
visible: background.keyNavigation
206
y: wordListView.currentItem ? wordListView.currentItem.y : 0
214
highlightFollowsCurrentItem: false
216
keyNavigationWraps: true
218
property int buttonHeight: height / wordListModel.count * 0.9
222
id: wordListViewDelegate
224
width: wordListView.width
225
height: wordListView.buttonHeight
226
anchors.right: parent.right
227
anchors.left: parent.left
232
height: wordListView.buttonHeight
236
fillMode: Image.PreserveAspectFit
237
anchors.leftMargin: 5 * ApplicationInfo.ratio
238
visible: (QuizActivity.mode == 1) ? true : false // hide images after first mini game
243
width: parent.width * 0.6
244
height: wordListView.buttonHeight
245
textLabel: translatedTxt
246
anchors.left: wordImageQuiz.left
247
anchors.right: parent.right
248
blockAllButtonClicks: quiz.buttonsBlocked
249
onPressed: quiz.buttonsBlocked = true
250
isCorrectAnswer: translatedTxt === quiz.goodWord.translatedTxt
251
onIncorrectlyPressed: {
252
// push the error to have it asked again
253
QuizActivity.remainingWords.unshift(quiz.goodWord);
254
QuizActivity.nextSubLevelQuiz();
256
onCorrectlyPressed: {
257
QuizActivity.nextSubLevelQuiz();
266
source: "qrc:/gcompris/src/core/resource/bar_repeat.svg";
267
sourceSize.width: 80 * ApplicationInfo.ratio
273
margins: 10 * ApplicationInfo.ratio
275
onClicked: Activity.playWord(goodWord.voice)
276
Behavior on opacity { PropertyAnimation { duration: 200 } }
286
onWin: imageReview.nextMiniGame()