Warning, /education/gcompris/src/activities/magic-hat-minus/StarsBar.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - MagicHat.qml 0002 * 0003 * SPDX-FileCopyrightText: 2014 Thibaut ROMAIN <thibrom@gmail.com> 0004 * 0005 * Authors: 0006 * <Bruno Coudoin> (GTK+ version) 0007 * Thibaut ROMAIN <thibrom@gmail.com> (Qt Quick port) 0008 * 0009 * SPDX-License-Identifier: GPL-3.0-or-later 0010 */ 0011 import QtQuick 2.12 0012 import "magic-hat.js" as Activity 0013 import "../../core" 0014 0015 Item { 0016 id: item 0017 height: starsSize 0018 property int barGroupIndex 0019 property int barIndex 0020 property int nbStarsOn: 0 0021 property bool authorizeClick: false 0022 property int coefficient: 1 0023 property bool coefficientVisible: false 0024 property int starsSize 0025 property string backgroundColor 0026 property string starsColor: "1" 0027 property Item theHat 0028 property alias repeaterStars: repeaterStars 0029 0030 Row { 0031 id: rowlayout 0032 height: item.height 0033 spacing: 5 0034 GCText { 0035 id: text 0036 visible: item.coefficientVisible 0037 //: text displaying coefficient with which the set of stars is to be multiplied along with multiplication symbol. 0038 text: qsTr("%1x").arg(item.coefficient) 0039 fontSizeMode: Text.HorizontalFit 0040 width: rowlayout.width / 10 0041 color: "white" 0042 anchors.rightMargin: 20 0043 fontSize: tinySize 0044 } 0045 Repeater { 0046 id: repeaterStars 0047 model: item.opacity == 1 ? 10 : 0 0048 Item { 0049 id: star 0050 width: item.starsSize 0051 height: item.starsSize 0052 property alias starFixed: starFixed 0053 property alias starToMove: starToMove 0054 Star { 0055 id: starFixed 0056 barGroupIndex: item.barGroupIndex 0057 barIndex: item.barIndex 0058 backgroundColor: item.backgroundColor 0059 wantedColor: coefficientVisible ? "1" : starsColor 0060 selected: index < nbStarsOn ? true : false 0061 width: item.starsSize 0062 height: item.starsSize 0063 displayBounds: true 0064 isClickable: item.authorizeClick 0065 } 0066 Star { 0067 id: starToMove 0068 barGroupIndex: item.barGroupIndex 0069 backgroundColor: item.backgroundColor 0070 wantedColor: coefficientVisible ? "1" : starsColor 0071 selected: index < nbStarsOn ? true : false 0072 width: item.starsSize 0073 height: item.starsSize 0074 displayBounds: false 0075 isClickable: false 0076 enabled: selected ? true : false 0077 initialParent: star 0078 theHat: item.theHat.target 0079 } 0080 } 0081 } 0082 } 0083 0084 function moveStars() { 0085 activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/smudge.wav") 0086 for(var i=0; i<nbStarsOn; i++) { 0087 repeaterStars.itemAt(i).starToMove.state = "MoveUnderHat" 0088 } 0089 } 0090 0091 function moveBackMinusStars(newRootItem, nbStars) { 0092 for(var i=0; i<nbStars; i++) { 0093 repeaterStars.itemAt(i).starToMove.newTarget = 0094 newRootItem.repeaterStars.itemAt(i) 0095 repeaterStars.itemAt(i).starToMove.state = "MoveToTarget" 0096 } 0097 } 0098 0099 function initStars() { 0100 for(var i=0; i<repeaterStars.count; i++) { 0101 repeaterStars.itemAt(i).starToMove.state = "Init" 0102 } 0103 } 0104 0105 function resetStars() { 0106 for(var i=0; i<repeaterStars.count; i++) { 0107 repeaterStars.itemAt(i).starFixed.selected = i < nbStarsOn ? true : false 0108 } 0109 } 0110 }