Warning, /education/gcompris/src/activities/lang/SpellIt.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - SpellIt.qml 0002 * 0003 * Copyright (C) Siddhesh suthar <siddhesh.it@gmail.com> (Qt Quick port) 0004 * 0005 * Authors: 0006 * Pascal Georges (pascal.georges1@free.fr) (GTK+ version) 0007 * Holger Kaelberer <holger.k@elberer.de> (Qt Quick port of imageid) 0008 * Siddhesh suthar <siddhesh.it@gmail.com> (Qt Quick port) 0009 * Bruno Coudoin <bruno.coudoin@gcompris.net> (Integration Lang dataset) 0010 * 0011 * SPDX-License-Identifier: GPL-3.0-or-later 0012 */ 0013 import QtQuick 2.12 0014 import GCompris 1.0 0015 import QtGraphicalEffects 1.0 0016 0017 import "../../core" 0018 import "lang.js" as Activity 0019 import "spell_it.js" as SpellActivity 0020 0021 Item { 0022 id: spellIt 0023 opacity: 0 0024 0025 property alias background: background 0026 property alias wordImage: wordImage 0027 property alias imageFrame: imageFrame 0028 property alias hintTextbg: hintTextbg 0029 property alias hintText: hintText 0030 property alias parser: parser 0031 property alias answerbg: answerbg 0032 property alias answer: answer 0033 property alias ok: ok 0034 property alias okMouseArea: okMouseArea 0035 property alias bonus: bonus 0036 property alias keyboard: keyboard 0037 property alias score: score 0038 property var goodWord 0039 property int goodWordIndex 0040 property int maximumLengthAnswer 0041 0042 function init(loadedItems_, wordList_, mode_) { 0043 opacity = 1 0044 return SpellActivity.init(loadedItems_, wordList_, mode_); 0045 } 0046 0047 function restoreFocus() { 0048 if(!ApplicationInfo.isMobile) 0049 answer.forceActiveFocus(); 0050 } 0051 0052 onGoodWordChanged: Activity.playWord(goodWord.voice) 0053 0054 Behavior on opacity { PropertyAnimation { duration: 200 } } 0055 0056 Keys.onEscapePressed: { 0057 imageReview.start() 0058 } 0059 Keys.onTabPressed: { 0060 repeatItem.clicked() 0061 } 0062 0063 Item { 0064 id: background 0065 anchors.fill: parent 0066 0067 property bool horizontalLayout: background.width >= background.height 0068 0069 JsonParser { 0070 id: parser 0071 onError: console.error("Lang: Error parsing json: " + msg); 0072 } 0073 0074 Rectangle { 0075 id: hintTextbg 0076 width: imageFrame.width 0077 height: 42 * ApplicationInfo.ratio 0078 color: "#AAFFFFFF" 0079 radius: 16 0080 anchors { 0081 horizontalCenter: parent.horizontalCenter 0082 top: parent.top 0083 topMargin: 4 * ApplicationInfo.ratio 0084 } 0085 0086 0087 GCText { 0088 id: hintText 0089 text: "" 0090 fontSizeMode: Text.Fit 0091 fontSize: mediumSize 0092 font.weight: Font.DemiBold 0093 width: parent.width - 8 0094 height: parent.height - 8 0095 horizontalAlignment: Text.AlignHCenter 0096 verticalAlignment: Text.AlignVCenter 0097 color: "#373737" 0098 anchors.centerIn: parent 0099 0100 property string nextHint 0101 function changeHint(nextHint_) { 0102 nextHint = nextHint_ 0103 animHint.start() 0104 } 0105 0106 SequentialAnimation { 0107 id: animHint 0108 PropertyAnimation { 0109 target: hintText 0110 property: "opacity" 0111 to: 0 0112 duration: 100 0113 } 0114 PropertyAction { 0115 target: hintText 0116 property: "text" 0117 value: ""+ hintText.nextHint 0118 } 0119 PropertyAnimation { 0120 target: hintText 0121 property: "opacity" 0122 to: 1 0123 duration: 100 0124 } 0125 } 0126 0127 } 0128 } 0129 0130 Item { 0131 id: imageFrame 0132 width: (parent.width - 72 * ApplicationInfo.ratio) * 0.8 0133 height: bar.y - hintTextbg.height - answerbg.height - 4 * anchors.margins 0134 // height: (parent.height - hintTextbg.height - answerbg.height - bar.height * 1.1) * 0.8 0135 anchors { 0136 horizontalCenter: parent.horizontalCenter 0137 top: hintTextbg.bottom 0138 margins: 10 * ApplicationInfo.ratio 0139 } 0140 z: 11 0141 0142 Rectangle { 0143 id: imageBg 0144 color: "#E0E0F7" 0145 anchors.centerIn: parent 0146 width: Math.min(parent.width, parent.height) 0147 height: width 0148 radius: width * 0.1 0149 border.color: "#373737" 0150 border.width: ApplicationInfo.ratio 0151 } 0152 0153 Image { 0154 id: wordImage 0155 // Images are not svg 0156 width: Math.min(parent.width, parent.height) * 0.9 0157 height: width 0158 anchors.centerIn: parent 0159 property string nextSource 0160 function changeSource(nextSource_) { 0161 nextSource = nextSource_ 0162 animImage.start() 0163 } 0164 0165 SequentialAnimation { 0166 id: animImage 0167 PropertyAnimation { 0168 target: wordImage 0169 property: "opacity" 0170 to: 0 0171 duration: 100 0172 } 0173 PropertyAction { 0174 target: wordImage 0175 property: "source" 0176 value: wordImage.nextSource 0177 } 0178 PropertyAnimation { 0179 target: wordImage 0180 property: "opacity" 0181 to: 1 0182 duration: 100 0183 } 0184 } 0185 0186 MouseArea { 0187 anchors.fill: parent 0188 onClicked: { 0189 Activity.playWord(goodWord.voice) 0190 } 0191 } 0192 } 0193 } 0194 0195 Rectangle { 0196 id: answerbg 0197 width: imageFrame.width + 8 0198 height: 96 * ApplicationInfo.ratio 0199 color: "#AAFFFFFF" 0200 radius: 16 0201 anchors { 0202 horizontalCenter: parent.horizontalCenter 0203 top: imageFrame.bottom 0204 margins: 10 * ApplicationInfo.ratio 0205 } 0206 z: 20 0207 0208 TextInput { 0209 id: answer 0210 width: parent.width - 4 0211 height: parent.height - 4 0212 color: "#373737" 0213 cursorVisible: true 0214 focus: false 0215 activeFocusOnPress: !ApplicationInfo.isMobile 0216 visible: true 0217 horizontalAlignment: TextInput.AlignHCenter 0218 verticalAlignment: TextInput.AlignVCenter 0219 font.pointSize: hintText.pointSize 0220 font.weight: Font.DemiBold 0221 font.family: GCSingletonFontLoader.fontLoader.name 0222 font.capitalization: ApplicationSettings.fontCapitalization 0223 font.letterSpacing: ApplicationSettings.fontLetterSpacing 0224 maximumLength: maximumLengthAnswer 0225 wrapMode: TextInput.Wrap 0226 onAccepted: { 0227 okMouseArea.clicked(toString(okMouseArea)) 0228 } 0229 } 0230 } 0231 0232 Image { 0233 id: ok 0234 source:"qrc:/gcompris/src/core/resource/bar_ok.svg" 0235 sourceSize.width: Math.min(answerbg.x, 100 * ApplicationInfo.ratio) - 2 * anchors.leftMargin 0236 fillMode: Image.PreserveAspectFit 0237 anchors { 0238 verticalCenter: answerbg.verticalCenter 0239 left: answerbg.right 0240 leftMargin: 10 * ApplicationInfo.ratio 0241 0242 } 0243 MouseArea { 0244 id: okMouseArea 0245 anchors.fill: parent 0246 hoverEnabled: true 0247 onEntered: ok.scale = 1.1 0248 onClicked: { 0249 SpellActivity.checkAnswer(answer.text) 0250 } 0251 onExited: ok.scale = 1 0252 } 0253 } 0254 0255 Bonus { 0256 id: bonus 0257 onWin: imageReview.nextMiniGame() 0258 } 0259 0260 } 0261 0262 BarButton { 0263 id: repeatItem 0264 source: "qrc:/gcompris/src/core/resource/bar_repeat.svg"; 0265 sourceSize.width: Math.min(hintTextbg.x, 84 * ApplicationInfo.ratio) - 2 * anchors.margins 0266 z: 12 0267 anchors { 0268 top: parent.top 0269 left: parent.left 0270 margins: 10 * ApplicationInfo.ratio 0271 } 0272 onClicked: Activity.playWord(goodWord.voice) 0273 Behavior on opacity { PropertyAnimation { duration: 200 } } 0274 } 0275 0276 Score { 0277 id: score 0278 } 0279 0280 VirtualKeyboard { 0281 id: keyboard 0282 parent: keyboardArea 0283 anchors.bottom: undefined 0284 anchors.horizontalCenter: undefined 0285 width: parent.width 0286 visible: ApplicationSettings.isVirtualKeyboard 0287 0288 onKeypress: SpellActivity.processKeyPress(text) 0289 onError: console.log("VirtualKeyboard error: " + msg); 0290 } 0291 0292 }