Warning, /education/gcompris/src/activities/erase/Erase.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - Erase.qml 0002 * 0003 * SPDX-FileCopyrightText: 2014 Bruno Coudoin <bruno.coudoin@gcompris.net> 0004 * 0005 * Authors: 0006 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version) 0007 * Bruno Coudoin <bruno.coudoin@gcompris.net> (Qt Quick port) 0008 * 0009 * SPDX-License-Identifier: GPL-3.0-or-later 0010 */ 0011 0012 import QtQuick 2.12 0013 import GCompris 1.0 0014 0015 import "../../core" 0016 import "erase.js" as Activity 0017 0018 ActivityBase { 0019 id: activity 0020 focus: true 0021 property string type: "erase" 0022 0023 onStart: {} 0024 onStop: {} 0025 0026 pageComponent: Image { 0027 id: background 0028 signal start 0029 signal stop 0030 focus: true 0031 fillMode: Image.PreserveAspectCrop 0032 source: Activity.url + Activity.getFirstImage() 0033 sourceSize.width: width 0034 sourceSize.height: height 0035 horizontalAlignment: Image.AlignHCenter 0036 verticalAlignment: Image.AlignVCenter 0037 0038 Component.onCompleted: { 0039 dialogActivityConfig.initialize() 0040 activity.start.connect(start) 0041 activity.stop.connect(stop) 0042 } 0043 QtObject { 0044 id: items 0045 property alias background: background 0046 property alias bar: bar 0047 property alias blocks: blocks 0048 property int currentLevel: activity.currentLevel 0049 property alias bonus: bonus 0050 property alias score: score 0051 property alias okButton: okButton 0052 property GCSfx audioEffects: activity.audioEffects 0053 property int nbSubLevel: 6 0054 property int currentSubLevel: 0 0055 property int mode: 1 // default is automatic 0056 } 0057 onStart: Activity.start(main, items, type) 0058 0059 onStop: { Activity.stop() } 0060 0061 function alignBackground() { 0062 if(Activity.backgroundImages[Activity.currentImage][1] === "left") 0063 background.horizontalAlignment = Image.AlignLeft 0064 else if(Activity.backgroundImages[Activity.currentImage][1] === "right") 0065 background.horizontalAlignment = Image.AlignRight 0066 else 0067 background.horizontalAlignment = Image.AlignHCenter 0068 0069 if(Activity.backgroundImages[Activity.currentImage][2] === "top") 0070 background.verticalAlignment = Image.AlignTop 0071 else if(Activity.backgroundImages[Activity.currentImage][2] === "bottom") 0072 background.verticalAlignment = Image.AlignBottom 0073 else 0074 background.verticalAlignment = Image.AlignVCenter 0075 } 0076 0077 MultiPointTouchArea { 0078 anchors.fill: parent 0079 onTouchUpdated: { 0080 for(var i in touchPoints) { 0081 var touch = touchPoints[i] 0082 0083 var newBlock = rootItem.childAt(touch.x, touch.y) 0084 if(newBlock && activity.type === "erase") 0085 newBlock.enter() 0086 0087 var previousBlock = rootItem.childAt(touch.previousX, touch.previousY) 0088 if(previousBlock !== newBlock && previousBlock != repeater) 0089 previousBlock.leave() 0090 } 0091 } 0092 } 0093 0094 Item { 0095 id: rootItem 0096 } 0097 0098 ListModel { 0099 id: blocks 0100 } 0101 Repeater { 0102 id: repeater 0103 model: blocks 0104 parent: rootItem 0105 Block { 0106 id: modelData 0107 nbx: nx 0108 nby: ny 0109 ix: a 0110 iy: b 0111 opacity: op 0112 source: img 0113 type: activity.type 0114 main: MAIN 0115 bar: BAR 0116 background: items.background 0117 } 0118 } 0119 0120 DialogHelp { 0121 id: dialogHelpLeftRight 0122 onClose: home() 0123 } 0124 0125 DialogChooseLevel { 0126 id: dialogActivityConfig 0127 currentActivity: activity.activityInfo 0128 0129 onClose: home() 0130 0131 onLoadData: { 0132 if(activityData && activityData["mode"]) { 0133 items.mode = activityData["mode"]; 0134 okButton.levelFinished = false 0135 } 0136 } 0137 onStartActivity: { 0138 background.stop() 0139 background.start() 0140 } 0141 } 0142 0143 Bar { 0144 id: bar 0145 level: items.currentLevel + 1 0146 content: BarEnumContent { value: help | home | level | activityConfig } 0147 onHelpClicked: { 0148 displayDialog(dialogHelpLeftRight) 0149 } 0150 onPreviousLevelClicked: Activity.previousLevel() 0151 onNextLevelClicked: Activity.nextLevel() 0152 onHomeClicked: home() 0153 onActivityConfigClicked: { 0154 displayDialog(dialogActivityConfig) 0155 } 0156 } 0157 0158 Bonus { 0159 id: bonus 0160 onWin: Activity.nextLevel() 0161 } 0162 0163 Score { 0164 id: score 0165 anchors { 0166 bottom: (background.width >= background.height + 40 * ApplicationInfo.ratio) ? background.bottom : bar.top 0167 bottomMargin: 10 * ApplicationInfo.ratio 0168 right: parent.right 0169 rightMargin: 10 * ApplicationInfo.ratio 0170 top: undefined 0171 left: undefined 0172 } 0173 numberOfSubLevels: items.nbSubLevel 0174 currentSubLevel: items.currentSubLevel 0175 onStop: { 0176 if(items.mode === 1) 0177 Activity.nextSubLevel() 0178 } 0179 } 0180 0181 // Next Level Button, if Manual is activated 0182 BarButton { 0183 id: okButton 0184 property bool levelFinished: false 0185 enabled: items.mode == 2 && levelFinished 0186 visible: enabled 0187 0188 source: "qrc:/gcompris/src/core/resource/bar_ok.svg" 0189 height: width 0190 width: score.width 0191 sourceSize.width: width 0192 sourceSize.height: height 0193 z: score.z 0194 anchors { 0195 bottom: score.top 0196 right: score.right 0197 bottomMargin: 20 0198 } 0199 ParticleSystemStarLoader { 0200 id: okButtonParticles 0201 clip: false 0202 } 0203 onClicked: { 0204 levelFinished = false 0205 Activity.nextSubLevel() 0206 } 0207 } 0208 } 0209 }