Warning, /education/gcompris/src/activities/erase/Block.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - Block.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 import QtQuick 2.12 0012 import "erase.js" as Activity 0013 import "../../core" 0014 import GCompris 1.0 0015 0016 Image { 0017 id: block 0018 property Item main 0019 property Item bar 0020 property Item background 0021 property double ix 0022 property double iy 0023 property int nbx 0024 property int nby 0025 0026 x: ix * main.width / nbx 0027 y: iy * (main.height - bar.height) / (nby + getMultipleOfRatioToAdjustHeight() * ApplicationInfo.ratio) 0028 width: main.width / nbx 0029 height: (main.height - bar.height) / (nby + getMultipleOfRatioToAdjustHeight() * ApplicationInfo.ratio) 0030 sourceSize.width: width 0031 sourceSize.height: height 0032 0033 signal enter 0034 signal leave 0035 property string type 0036 property int counter: 0 0037 0038 function getMultipleOfRatioToAdjustHeight() { 0039 return (background.width >= background.height + 40 * ApplicationInfo.ratio) ? 0.125 : 0.625 0040 } 0041 0042 onEnter: { 0043 if(opacity == 1.0) { 0044 playSound() 0045 block.opacity = 0 0046 } 0047 } 0048 0049 onLeave: { 0050 if(opacity != 0) { 0051 block.opacity = 1.0 0052 } 0053 } 0054 0055 Behavior on opacity { PropertyAnimation { duration: 200 } } 0056 0057 onOpacityChanged: { 0058 if (opacity == 0) { 0059 mouseArea.enabled = false 0060 mouseArea.hoverEnabled = false 0061 Activity.blockKilled() 0062 } 0063 } 0064 0065 MouseArea { 0066 id: mouseArea 0067 anchors.fill: parent 0068 enabled: block.type !== "erase" || !ApplicationInfo.isMobile 0069 hoverEnabled: block.type === "erase" && !ApplicationInfo.isMobile 0070 onClicked: { 0071 if(block.type === "click") { 0072 enabled = false 0073 block.enter() 0074 } 0075 } 0076 onDoubleClicked: { 0077 if(block.type === "double_click") { 0078 enabled = false 0079 block.enter() 0080 } 0081 } 0082 onEntered: { 0083 if(block.type === "erase") { 0084 block.enter() 0085 } 0086 } 0087 onExited: { 0088 if(block.type === "erase") { 0089 block.leave() 0090 } 0091 } 0092 } 0093 0094 function playSound() 0095 { 0096 activity.audioEffects.play( 0097 ix % 2 ? "qrc:/gcompris/src/activities/erase/resource/eraser1.wav" : 0098 "qrc:/gcompris/src/activities/erase/resource/eraser2.wav") 0099 } 0100 0101 }