Warning, /education/gcompris/src/activities/colors/ColorItem.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - ColorItem.qml
0002 *
0003 * SPDX-FileCopyrightText: 2014 Bruno Coudoin <bruno.coudoin@gcompris.net>
0004 *
0005 * Authors:
0006 * Pascal Georges <pascal.georges1@free.fr> (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 "findit.js" as Activity
0013 import "../../core"
0014 import GCompris 1.0
0015
0016 Image {
0017 id: item
0018 property GCAudio audioVoices
0019 property Item bar
0020 property string audioSrc
0021 property string question
0022 property bool playAudioOnError: false
0023
0024 function select() {
0025 if(items.objectSelected)
0026 return
0027 items.objectSelected = true
0028 if(Activity.hasWon) {
0029 return
0030 }
0031
0032 if(question === Activity.getCurrentTextQuestion()) {
0033 particles.burst(40)
0034 animWin.start()
0035 score.currentSubLevel += 1
0036 score.playWinAnimation()
0037 activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/completetask.wav")
0038 } else {
0039 if(audioSrc && item.playAudioOnError) {
0040 item.audioVoices.play(audioSrc)
0041 }
0042 crossAnim.start()
0043 activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/crash.wav")
0044 }
0045 }
0046
0047 MouseArea {
0048 id: mouseArea
0049 anchors.fill: parent
0050 enabled: !items.objectSelected
0051 onClicked: select()
0052 }
0053
0054 SequentialAnimation {
0055 id: anim
0056 running: true
0057 loops: Animation.Infinite
0058 NumberAnimation {
0059 target: item
0060 property: "rotation"
0061 from: -10; to: 10
0062 duration: 400 + Math.floor(Math.random() * 400)
0063 easing.type: Easing.InOutQuad
0064 }
0065 NumberAnimation {
0066 target: item
0067 property: "rotation"
0068 from: 10; to: -10
0069 duration: 400 + Math.floor(Math.random() * 400)
0070 easing.type: Easing.InOutQuad
0071 }
0072 }
0073
0074 SequentialAnimation {
0075 id: animWin
0076 running: false
0077 NumberAnimation {
0078 target: item
0079 property: "rotation"
0080 from: 0; to: 360
0081 duration: 600
0082 easing.type: Easing.InOutQuad
0083 }
0084 ScriptAction { script: Activity.nextQuestion() }
0085 onRunningChanged: {
0086 if (running == false) {
0087 items.objectSelected = false
0088 }
0089 }
0090 }
0091
0092 ParticleSystemStarLoader {
0093 id: particles
0094 clip: false
0095 }
0096
0097 Image {
0098 id: cross
0099 source: Activity.url + "checkError.svg"
0100 sourceSize.width: 128 * ApplicationInfo.ratio
0101 anchors.centerIn: parent
0102 width: 0
0103 height: width
0104 opacity: 1
0105
0106 property int size: Math.min(parent.width, parent.height)
0107 }
0108
0109 SequentialAnimation {
0110 id: crossAnim
0111 PropertyAnimation {
0112 target: cross
0113 property: "width"
0114 duration: 300
0115 from: 0
0116 to: cross.size
0117 easing.type: Easing.InOutQuad
0118 }
0119 PauseAnimation { duration: 800 }
0120 PropertyAnimation {
0121 target: cross
0122 property: "width"
0123 duration: 300
0124 from: cross.size
0125 to: 0
0126 easing.type: Easing.InOutQuad
0127 }
0128 onRunningChanged: {
0129 if (running == false) {
0130 items.objectSelected = false
0131 }
0132 }
0133 }
0134
0135 }