Warning, /education/gcompris/src/activities/louis-braille/LouisBraille.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - louis-braille.qml 0002 * 0003 * SPDX-FileCopyrightText: 2014 Arkit Vora <arkitvora123@gmail.com> 0004 * 0005 * Authors: 0006 * <Srishti Sethi> (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" 0015 import "louis-braille.js" as Activity 0016 import "louis_braille_data.js" as Dataset 0017 import "qrc:/gcompris/src/core/core.js" as Core 0018 0019 ActivityBase { 0020 id: activity 0021 onStart: focus = true 0022 onStop: {} 0023 0024 0025 pageComponent: Rectangle { 0026 id: background 0027 anchors.fill: parent 0028 color: "#85D8F6" 0029 signal start 0030 signal stop 0031 0032 property double baseMargins: 10 * ApplicationInfo.ratio 0033 0034 Component.onCompleted: { 0035 activity.start.connect(start) 0036 activity.stop.connect(stop) 0037 } 0038 0039 // Add here the QML items you need to access in javascript 0040 QtObject { 0041 id: items 0042 property Item main: activity.main 0043 property alias background: background 0044 property alias bonus: bonus 0045 property int count: 0 0046 property var dataset: Dataset.dataset 0047 } 0048 0049 onStart: { Activity.start(items) } 0050 onStop: { 0051 listScreen.stopTimer() 0052 Activity.stop() 0053 } 0054 0055 Item { 0056 id: charList 0057 anchors.top: parent.top 0058 anchors.topMargin: background.baseMargins 0059 anchors.horizontalCenter: parent.horizontalCenter 0060 height: childrenRect.height 0061 width: Math.min(parent.width - 2 * background.baseMargins, 520 * ApplicationInfo.ratio) 0062 0063 Row { 0064 id: row 0065 spacing: background.baseMargins 0066 anchors.horizontalCenter: parent.horizontalCenter 0067 width: parent.width 0068 0069 Repeater { 0070 id: cardRepeater 0071 model: ["L","O","U","I","S"," ","B","R","A","I","L","L","E"] 0072 0073 // workaround for https://bugreports.qt.io/browse/QTBUG-72643 (qml binding with global variable in Repeater do not work) 0074 property alias rowSpacing: row.spacing 0075 property alias rowWidth: row.width 0076 Item { 0077 id: inner 0078 height: childrenRect.height 0079 width: (cardRepeater.rowWidth - 12 * cardRepeater.rowSpacing)/ 13 0080 0081 Rectangle { 0082 id: rect1 0083 width: inner.width 0084 height: ins.height 0085 border.width: ApplicationInfo.ratio 0086 opacity: index == 5 ? 0 :1 0087 border.color: "#373737" 0088 color: "#F0F0F0" 0089 0090 BrailleChar { 0091 id: ins 0092 width: parent.width * 0.9 0093 anchors.centerIn: parent 0094 clickable: false 0095 brailleChar: modelData 0096 thinBorder: rect1.border.width 0097 } 0098 } 0099 0100 GCText { 0101 text: modelData 0102 font.weight: Font.DemiBold 0103 color: "#373737" 0104 fontSize: regularSize 0105 anchors { 0106 top: rect1.bottom 0107 topMargin: 4 * ApplicationInfo.ratio 0108 horizontalCenter: rect1.horizontalCenter 0109 } 0110 } 0111 } 0112 } 0113 } 0114 } 0115 0116 Keys.onRightPressed: background.next() 0117 Keys.onLeftPressed: background.previous() 0118 0119 function previous() { 0120 if(items.count == 0) 0121 items.count = items.dataset.length - 1 0122 else 0123 items.count-- 0124 } 0125 0126 function next() { 0127 if(items.count == items.dataset.length - 1) { 0128 listScreen.shuffle() 0129 items.count = 0 0130 listScreen.visible = true 0131 } else { 0132 items.count++ 0133 } 0134 } 0135 0136 Item { 0137 id: layoutArea 0138 anchors.top: charList.bottom 0139 anchors.left: background.left 0140 anchors.right: background.right 0141 anchors.margins: background.baseMargins 0142 height: background.height - charList.height - bar.height * 1.2 - 3 * background.baseMargins 0143 } 0144 0145 // The image description 0146 Rectangle { 0147 id: info_rect 0148 border.color: "#373737" 0149 border.width: ApplicationInfo.ratio 0150 color: "#F0F0F0" 0151 width: layoutArea.width 0152 height: layoutArea.height * 0.3 0153 radius: 5 * ApplicationInfo.ratio 0154 anchors.top: layoutArea.top 0155 anchors.horizontalCenter: layoutArea.horizontalCenter 0156 0157 GCText { 0158 id: info 0159 color: "#373737" 0160 anchors.centerIn: parent 0161 horizontalAlignment: Text.AlignHCenter 0162 width: parent.width - 2 * background.baseMargins 0163 height: parent.height - 2 * background.baseMargins 0164 wrapMode: Text.WordWrap 0165 fontSize: regularSize 0166 text: items.dataset[items.count].text 0167 fontSizeMode: Text.Fit 0168 } 0169 } 0170 0171 // Image and date 0172 Image { 0173 id: img 0174 anchors.top: info_rect.bottom 0175 anchors.topMargin: background.baseMargins 0176 anchors.horizontalCenter: layoutArea.horizontalCenter 0177 sourceSize.height: width 0178 sourceSize.width: width 0179 height: width 0180 width: Math.min(layoutArea.width - previous.width * 2 - 60 * ApplicationInfo.ratio, 0181 layoutArea.height - (info_rect.height + year_rect.height + 2 * background.baseMargins)) 0182 source: items.dataset[items.count].img 0183 fillMode: Image.PreserveAspectFit 0184 0185 MouseArea { 0186 anchors.fill: parent 0187 onClicked: background.next() 0188 } 0189 } 0190 0191 Image { 0192 id: previous 0193 anchors.right: img.left 0194 anchors.rightMargin: 20 * ApplicationInfo.ratio 0195 anchors.verticalCenter: img.verticalCenter 0196 source: "qrc:/gcompris/src/core/resource/bar_previous.svg" 0197 height: 80 * ApplicationInfo.ratio 0198 width: height * 0.5 0199 sourceSize.height: height 0200 fillMode: Image.PreserveAspectFit 0201 Behavior on scale { PropertyAnimation { duration: 100} } 0202 MouseArea { 0203 anchors.fill: parent 0204 hoverEnabled: true 0205 onEntered: previous.scale = 1.1 0206 onExited: previous.scale = 1 0207 onClicked: background.previous() 0208 } 0209 } 0210 0211 Image { 0212 id: next 0213 anchors.left: img.right 0214 anchors.leftMargin: 20 * ApplicationInfo.ratio 0215 anchors.verticalCenter: img.verticalCenter 0216 source: "qrc:/gcompris/src/core/resource/bar_next.svg" 0217 height: 80 * ApplicationInfo.ratio 0218 width: height * 0.5 0219 sourceSize.height: height 0220 fillMode: Image.PreserveAspectFit 0221 Behavior on scale { PropertyAnimation { duration: 100} } 0222 0223 MouseArea { 0224 anchors.fill: parent 0225 hoverEnabled: true 0226 onEntered: next.scale = 1.1 0227 onExited: next.scale = 1 0228 onClicked: background.next() 0229 } 0230 } 0231 0232 Rectangle { 0233 id: year_rect 0234 border.color: "#373737" 0235 border.width: ApplicationInfo.ratio 0236 radius: 5 * ApplicationInfo.ratio 0237 color: "#F0F0F0" 0238 width: year.width + 2 * background.baseMargins 0239 height: year.height + background.baseMargins 0240 anchors { 0241 top: img.bottom 0242 horizontalCenter: img.horizontalCenter 0243 topMargin: background.baseMargins 0244 } 0245 GCText { 0246 id: year 0247 color: "#373737" 0248 fontSize: regularSize 0249 anchors.centerIn: year_rect 0250 text: items.dataset[items.count].year 0251 } 0252 } 0253 0254 Keys.onUpPressed: listScreen.up() 0255 Keys.onDownPressed: listScreen.down() 0256 Keys.onEnterPressed: listScreen.space() 0257 Keys.onReturnPressed: listScreen.space() 0258 Keys.onSpacePressed: listScreen.space() 0259 0260 ReorderList { 0261 id: listScreen 0262 visible: false 0263 0264 signal shuffle 0265 0266 onShuffle: { 0267 bonusRunning = false 0268 containerModel.clear() 0269 var dataitems = Object.create(items.dataset) 0270 dataitems = Core.shuffle(dataitems) 0271 for(var i = 0 ; i < dataitems.length ; i++) { 0272 containerModel.append(dataitems[i]); 0273 } 0274 } 0275 } 0276 0277 DialogHelp { 0278 id: dialogHelp 0279 onClose: home() 0280 } 0281 0282 Bar { 0283 id: bar 0284 content: BarEnumContent { value: help | home | reload } 0285 onHelpClicked: { 0286 displayDialog(dialogHelp) 0287 } 0288 onPreviousLevelClicked: Activity.previousLevel() 0289 onNextLevelClicked: Activity.nextLevel() 0290 onHomeClicked: activity.home() 0291 onReloadClicked: { 0292 items.count = 0 0293 listScreen.visible = false 0294 } 0295 } 0296 0297 Bonus { 0298 id: bonus 0299 Component.onCompleted: win.connect(listScreen.shuffle) 0300 } 0301 } 0302 0303 }