Warning, /education/gcompris/src/activities/braille_alphabets/BrailleAlphabets.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - BrailleAlphabets.qml 0002 * 0003 * SPDX-FileCopyrightText: 2014 Arkit Vora <arkitvora123@gmail.com> 0004 * 0005 * Authors: 0006 * Srishti Sethi <srishakatux@gmail.com> (GTK+ version) 0007 * Arkit Vora <arkitvora123@gmail.com> (Qt Quick port) 0008 * 0009 * SPDX-License-Identifier: GPL-3.0-or-later 0010 */ 0011 import QtQuick 2.12 0012 import GCompris 1.0 0013 import "../../core" 0014 import "braille_alphabets.js" as Activity 0015 import "questions.js" as Dataset 0016 0017 ActivityBase { 0018 id: activity 0019 0020 onStart: focus = true 0021 onStop: {} 0022 0023 property var dataset: Dataset 0024 0025 pageComponent: Image { 0026 id: background 0027 anchors.fill: parent 0028 fillMode: Image.PreserveAspectCrop 0029 source: Activity.url + "background.svg" 0030 sourceSize.width: width 0031 sourceSize.height: height 0032 signal start 0033 signal stop 0034 Component.onCompleted: { 0035 activity.start.connect(start) 0036 activity.stop.connect(stop) 0037 } 0038 0039 Keys.onPressed: { 0040 if(items.buttonsBlocked) { 0041 return 0042 } 0043 if(first_screen.visible) { 0044 // If return, we hide the screen 0045 first_screen.visible = false; 0046 return; 0047 } 0048 var keyValue; 0049 switch(event.key) 0050 { 0051 case Qt.Key_1: 0052 keyValue = 1; 0053 break; 0054 case Qt.Key_2: 0055 keyValue = 2; 0056 break; 0057 case Qt.Key_3: 0058 keyValue = 3; 0059 break; 0060 case Qt.Key_4: 0061 keyValue = 4; 0062 break; 0063 case Qt.Key_5: 0064 keyValue = 5; 0065 break; 0066 case Qt.Key_6: 0067 keyValue = 6; 0068 break; 0069 } 0070 if(keyValue) 0071 playableChar.switchState(keyValue); 0072 if(event.key === Qt.Key_Space) 0073 braille_map.clicked(); 0074 } 0075 0076 // Add here the QML items you need to access in javascript 0077 QtObject { 0078 id: items 0079 property Item main: activity.main 0080 property alias background: background 0081 property GCSfx audioEffects: activity.audioEffects 0082 property int currentLevel: activity.currentLevel 0083 property alias bonus: bonus 0084 property alias containerModel: containerModel 0085 property alias questionItem: questionItem 0086 property string instructions 0087 property alias playableChar: playableChar 0088 property alias score: score 0089 property bool brailleCodeSeen 0090 property int baseMargins: 10 * ApplicationInfo.ratio 0091 property bool buttonsBlocked: false 0092 } 0093 0094 onStart: { 0095 first_screen.visible = true 0096 Activity.start(items, dataset) 0097 } 0098 onStop: { Activity.stop() } 0099 0100 0101 ListModel { 0102 id: containerModel 0103 } 0104 0105 Item { 0106 id: layoutArea 0107 anchors.fill: background 0108 anchors.bottomMargin: bar.height * 1.3 0109 } 0110 0111 Rectangle { 0112 id: charList 0113 anchors.top: layoutArea.top 0114 anchors.left: layoutArea.left 0115 anchors.right: layoutArea.right 0116 anchors.margins: items.baseMargins 0117 radius: items.baseMargins 0118 height: Math.min(120 * ApplicationInfo.ratio, layoutArea.height * 0.3) 0119 visible: items.brailleCodeSeen 0120 color: "#a5cbd9" 0121 0122 Row { 0123 id: row 0124 spacing: items.baseMargins 0125 anchors.centerIn: charList 0126 0127 Repeater { 0128 id: cardRepeater 0129 model: containerModel 0130 0131 // workaround for https://bugreports.qt.io/browse/QTBUG-72643 (qml binding with global variable in Repeater do not work) 0132 property alias rowSpacing: row.spacing 0133 Item { 0134 id: inner 0135 height: charList.height - 2 * items.baseMargins 0136 width: (charList.width - containerModel.count * cardRepeater.rowSpacing)/ containerModel.count 0137 0138 BrailleChar { 0139 id: ins 0140 width: Math.min(parent.height * 0.5, parent.width) 0141 anchors.top: parent.top 0142 anchors.horizontalCenter: parent.horizontalCenter 0143 clickable: false 0144 brailleChar: letter 0145 } 0146 Item { 0147 anchors.top: ins.bottom 0148 anchors.left: parent.left 0149 anchors.right: parent.right 0150 anchors.bottom: parent.bottom 0151 GCText { 0152 text: letter 0153 font.weight: Font.DemiBold 0154 color: "#2a2a2a" 0155 width: parent.width 0156 height: parent.height 0157 fontSizeMode: Text.Fit 0158 horizontalAlignment: Text.AlignHCenter 0159 verticalAlignment: Text.AlignVCenter 0160 } 0161 } 0162 } 0163 } 0164 } 0165 } 0166 0167 Rectangle { 0168 id: playableCharBg 0169 anchors { 0170 top: charList.bottom 0171 left: layoutArea.left 0172 margins: items.baseMargins 0173 } 0174 color: "#d3e6ed" 0175 border.color: "#a5cbd9" 0176 border.width: 3 * ApplicationInfo.ratio 0177 radius: items.baseMargins 0178 width: playableChar.width * 1.5 + 2 * items.baseMargins 0179 height: (playableChar.height + playableCharDisplayArea.height) + 3 * items.baseMargins 0180 0181 BrailleChar { 0182 id: playableChar 0183 clickable: true 0184 anchors { 0185 horizontalCenter: parent.horizontalCenter 0186 top: parent.top 0187 topMargin: items.baseMargins 0188 } 0189 width: Math.min(layoutArea.width * 0.18, layoutArea.height * 0.2) 0190 isLetter: true 0191 onBrailleCharChanged: { 0192 if(brailleChar === Activity.getCurrentLetter()) { 0193 particles.burst(40); 0194 Activity.goodAnswer(); 0195 } 0196 } 0197 } 0198 Item { 0199 id: playableCharDisplayArea 0200 height: playableChar.height * 0.3 0201 width: parent.width 0202 anchors.top: playableChar.bottom 0203 anchors.topMargin: items.baseMargins 0204 GCText { 0205 id: playableCharDisplay 0206 font.weight: Font.DemiBold 0207 color: "#2a2a2a" 0208 text: playableChar.brailleChar 0209 width: parent.width 0210 height: parent.height 0211 fontSizeMode: Text.Fit 0212 horizontalAlignment: Text.AlignHCenter 0213 verticalAlignment: Text.AlignVCenter 0214 } 0215 } 0216 } 0217 0218 Rectangle { 0219 id: instructionsArea 0220 anchors { 0221 top: charList.bottom 0222 left: playableCharBg.right 0223 right: layoutArea.right 0224 bottom: braille_map.top 0225 margins: items.baseMargins 0226 } 0227 color: "#aae4f9" 0228 radius: 5 * ApplicationInfo.ratio 0229 0230 GCText { 0231 id: questionItem 0232 anchors.centerIn: parent 0233 fontSize: largeSize 0234 fontSizeMode: Text.Fit 0235 horizontalAlignment: Text.AlignHCenter 0236 font.weight: Font.DemiBold 0237 color: "#2a2a2a" 0238 width: parent.width * 0.94 0239 height: parent.height * 0.94 0240 wrapMode: Text.WordWrap 0241 } 0242 } 0243 0244 ParticleSystemStarLoader { 0245 id: particles 0246 clip: false 0247 } 0248 0249 FirstScreen { 0250 id: first_screen 0251 } 0252 0253 Score { 0254 id: score 0255 anchors { 0256 verticalCenter: braille_map.verticalCenter 0257 right: braille_map.left 0258 rightMargin: items.baseMargins 0259 left: undefined 0260 top: undefined 0261 bottom: undefined 0262 } 0263 visible: !first_screen.visible 0264 onStop: Activity.nextQuestion(); 0265 } 0266 0267 DialogHelp { 0268 id: dialogHelp 0269 onClose: home() 0270 } 0271 0272 BrailleMap { 0273 id: dialogMap 0274 // Make it non visible or we get some rendering artefacts before 0275 // until it is created 0276 visible: false 0277 onClose: home() 0278 } 0279 0280 Bar { 0281 id: bar 0282 level: items.currentLevel + 1 0283 content: BarEnumContent { value: first_screen.visible ? help | home : help | home | level } 0284 onHelpClicked: { 0285 displayDialog(dialogHelp) 0286 } 0287 onPreviousLevelClicked: Activity.previousLevel() 0288 onNextLevelClicked: Activity.nextLevel() 0289 onHomeClicked: activity.home() 0290 } 0291 0292 BarButton { 0293 id: braille_map 0294 source: Activity.url + "braille_button.svg" 0295 anchors { 0296 right: layoutArea.right 0297 bottom: layoutArea.bottom 0298 margins: items.baseMargins 0299 } 0300 sourceSize.width: 60 * ApplicationInfo.ratio 0301 visible: !first_screen.visible 0302 onClicked: { 0303 dialogMap.visible = true 0304 displayDialog(dialogMap) 0305 } 0306 } 0307 0308 Bonus { 0309 id: bonus 0310 Component.onCompleted: win.connect(Activity.nextLevel) 0311 } 0312 } 0313 0314 } 0315