Warning, /education/gcompris/src/activities/photo_hunter/Observe.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - Observe.qml
0002  *
0003  * SPDX-FileCopyrightText: 2016 Stefan Toncu <stefan.toncu29@gmail.com>
0004  *
0005  * Authors:
0006  *   <Marc Le Douarain> (GTK+ version)
0007  *   Stefan Toncu <stefan.toncu29@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 
0014 import "../../core"
0015 import "photo_hunter.js" as Activity
0016 
0017 Image {
0018     id: card
0019 
0020     width: background.vert ? Math.min((parent.height - 30 * ApplicationInfo.ratio - slider.height) * 0.5, parent.width - 20 * ApplicationInfo.ratio) :
0021                             Math.min((parent.width - 30 * ApplicationInfo.ratio) * 0.5, parent.height - 20 * ApplicationInfo.ratio - slider.height)
0022     height: width
0023     sourceSize.width: width
0024     sourceSize.height: width
0025 
0026     property GCSfx audioEffects: activity.audioEffects
0027     property alias repeater: repeater
0028     property alias circleRepeater: circleRepeater
0029     property int good: 0
0030     property bool show: false
0031     property double minimumSize: 20 * ApplicationInfo.ratio
0032 
0033     Behavior on anchors.horizontalCenterOffset {
0034         enabled: !background.vert
0035         NumberAnimation {
0036             duration: 1000
0037             easing.type: Easing.InOutQuad
0038         }
0039     }
0040 
0041     Behavior on anchors.verticalCenterOffset {
0042         enabled: background.vert
0043         NumberAnimation {
0044             duration: 1000
0045             easing.type: Easing.InOutQuad
0046         }
0047     }
0048 
0049 
0050     Image {
0051         id: wrong
0052         source: "qrc:/gcompris/src/activities/tic_tac_toe/resource/cross.svg"
0053         width: 70
0054         height: 70
0055         opacity: 0
0056     }
0057 
0058     NumberAnimation {
0059         id: wrongAnim
0060         target: wrong
0061         property: "opacity"
0062         from: 0
0063         to: 1
0064         duration: 400
0065     }
0066 
0067     NumberAnimation {
0068         id: wrongAnim2
0069         target: wrong
0070         property: "opacity"
0071         from: 1
0072         to: 0
0073         duration: 400
0074     }
0075 
0076     MouseArea {
0077         id: big
0078         anchors.fill: parent
0079         enabled: !background.startedHelp
0080         onClicked: {
0081             audioEffects.play('qrc:/gcompris/src/core/resource/sounds/brick.wav')
0082             wrongAnim.start()
0083             wrong.x = mouseX - wrong.width/2
0084             wrong.y = mouseY - wrong.height/2
0085             wrongAnim2.start()
0086         }
0087     }
0088 
0089     Repeater {
0090         id: repeater
0091 
0092         model: items.model
0093 
0094         Image {
0095             id: photo
0096             property alias particleLoader: particleLoader
0097             property alias differenceAnimation: differenceAnimation
0098 
0099             width: card.width * Activity.dataset[items.currentLevel].coordinates[index].w
0100             height: card.height * Activity.dataset[items.currentLevel].coordinates[index].h
0101 
0102             sourceSize.width: width
0103             fillMode: Image.PreserveAspectFit
0104 
0105             source: Activity.url + "photo" + (items.currentLevel + 1) + "_" + (index + 1) + ".svg"
0106             opacity: card.show ? 1 : 0
0107 
0108             x: modelData[0] * card.width
0109             y: modelData[1] * card.height
0110 
0111             NumberAnimation {
0112                 id: differenceAnimation
0113                 target: photo
0114                 property: "opacity"
0115                 from: 0
0116                 to: 1
0117                 duration: 500
0118             }
0119 
0120             // Create a particle only for the strawberry
0121             Loader {
0122                 id: particleLoader
0123                 anchors.fill: parent
0124                 active: true
0125                 sourceComponent: particle
0126             }
0127 
0128             Component {
0129                 id: particle
0130                 ParticleSystemStarLoader {
0131                     id: particles
0132                     clip: false
0133                 }
0134             }
0135 
0136             MouseArea {
0137                 id: mouseArea
0138                 anchors.centerIn: parent
0139                 width: Math.max(parent.width, card.minimumSize)
0140                 height: Math.max(parent.height, card.minimumSize)
0141                 enabled: !background.startedHelp
0142                 onClicked: {
0143                     Activity.photoClicked(card,index)
0144                     audioEffects.play('qrc:/gcompris/src/core/resource/sounds/bleep.wav')
0145                 }
0146             }
0147         }
0148     }
0149 
0150     Repeater {
0151         id: circleRepeater
0152 
0153         model: card.repeater.model
0154 
0155         Rectangle {
0156             id: circle
0157             color: "transparent"
0158             radius: width * 0.5
0159             border.color: card.show ? "#BF3535E8" : "#BFE83535" // blue : red
0160             border.width: 2 * ApplicationInfo.ratio
0161             opacity: 0
0162             x: itemAt.x + (itemAt.width - width) * 0.5
0163             y: itemAt.y + (itemAt.height - height) * 0.5
0164             width: Math.max(itemAt.width, itemAt.height, card.minimumSize) * 1.5
0165             height: width
0166 
0167             property alias scaleAnim: scaleAnim
0168             property var itemAt: card.repeater.itemAt(index) ? card.repeater.itemAt(index) : card
0169 
0170             NumberAnimation {
0171                 id: scaleAnim
0172                 target: circle
0173                 property: "scale"
0174                 from: 0
0175                 to: circle.scale
0176                 duration: 700
0177             }
0178         }
0179     }
0180 }