Warning, /education/gcompris/src/activities/piano_composition/BpmMeter.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - BpmMeter.qml 0002 * 0003 * SPDX-FileCopyrightText: 2018 Aman Kumar Gupta <gupta2140@gmail.com> 0004 * 0005 * Authors: 0006 * Beth Hadley <bethmhadley@gmail.com> (GTK+ version) 0007 * Johnny Jazeix <jazeix@gmail.com> (Qt Quick port) 0008 * Aman Kumar Gupta <gupta2140@gmail.com> (Qt Quick port) 0009 * Timothée Giet <animtim@gmail.com> (refactoring) 0010 * 0011 * SPDX-License-Identifier: GPL-3.0-or-later 0012 */ 0013 import QtQuick 2.12 0014 import GCompris 1.0 0015 0016 import "../../core" 0017 0018 Item { 0019 id: bpmMeter 0020 width: optionsRow.iconsWidth * 2 0021 height: optionsRow.iconsWidth 0022 visible: bpmVisible 0023 0024 signal stop 0025 0026 Component.onCompleted: { 0027 activity.stop.connect(stop); 0028 } 0029 0030 onStop: { 0031 decreaseBpm.stop(); 0032 increaseBpm.stop(); 0033 } 0034 0035 Rectangle { 0036 id: bpmBg 0037 color: "yellow" 0038 opacity: 0.1 0039 border.width: 2 0040 border.color: "black" 0041 width: optionsRow.iconsWidth 0042 height: optionsRow.iconsWidth 0043 anchors.left: parent.left 0044 radius: 10 0045 } 0046 GCText { 0047 //: BPM is the abbreviation for Beats Per Minute. 0048 text: qsTr("%1 BPM").arg(multipleStaff.bpmValue + "<br>") 0049 width: 0.9 * bpmBg.width 0050 height: 0.9 * bpmBg.height 0051 horizontalAlignment: Text.AlignHCenter 0052 verticalAlignment: Text.AlignVCenter 0053 anchors.centerIn: bpmBg 0054 fontSizeMode: Text.Fit 0055 } 0056 Image { 0057 id: bpmDown 0058 source: "qrc:/gcompris/src/core/resource/bar_down.svg" 0059 width: iconsWidth 0060 height: iconsWidth * 0.5 0061 sourceSize.width: width 0062 fillMode: Image.PreserveAspectFit 0063 anchors.bottom: parent.bottom 0064 anchors.left: bpmBg.right 0065 Timer { 0066 id: decreaseBpm 0067 interval: 500 0068 repeat: true 0069 onTriggered: { 0070 bpmDecreased() 0071 interval = 1 0072 } 0073 onRunningChanged: { 0074 if(!running) 0075 interval = 500 0076 } 0077 } 0078 MouseArea { 0079 id: mouseDown 0080 anchors.fill: parent 0081 hoverEnabled: true 0082 onPressed: { 0083 bpmDown.scale = 0.85 0084 bpmDecreased() 0085 decreaseBpm.start() 0086 } 0087 onReleased: { 0088 decreaseBpm.stop() 0089 bpmDown.scale = 1 0090 bpmChanged() 0091 } 0092 } 0093 states: [ 0094 State { 0095 name: "notclicked" 0096 PropertyChanges { 0097 target: bpmDown 0098 scale: 1.0 0099 } 0100 }, 0101 State { 0102 name: "clicked" 0103 when: mouseDown.pressed 0104 PropertyChanges { 0105 target: bpmDown 0106 scale: 0.9 0107 } 0108 }, 0109 State { 0110 name: "hover" 0111 when: mouseDown.containsMouse 0112 PropertyChanges { 0113 target: bpmDown 0114 scale: 1.1 0115 } 0116 } 0117 ] 0118 Behavior on scale { NumberAnimation { duration: 70 } } 0119 Behavior on opacity { PropertyAnimation { duration: 200 } } 0120 } 0121 Image { 0122 id: bpmUp 0123 source: "qrc:/gcompris/src/core/resource/bar_up.svg" 0124 width: iconsWidth 0125 height: bpmDown.height 0126 sourceSize.width: width 0127 fillMode: Image.PreserveAspectFit 0128 anchors.top: parent.top 0129 anchors.left: bpmBg.right 0130 Timer { 0131 id: increaseBpm 0132 interval: 500 0133 repeat: true 0134 onTriggered: { 0135 bpmIncreased() 0136 interval = 1 0137 } 0138 onRunningChanged: { 0139 if(!running) 0140 interval = 500 0141 } 0142 } 0143 MouseArea { 0144 id: mouseUp 0145 anchors.fill: parent 0146 hoverEnabled: true 0147 onPressed: { 0148 bpmUp.scale = 0.85 0149 bpmIncreased() 0150 increaseBpm.start() 0151 } 0152 onReleased: { 0153 increaseBpm.stop() 0154 bpmUp.scale = 1 0155 bpmChanged() 0156 } 0157 } 0158 states: [ 0159 State { 0160 name: "notclicked" 0161 PropertyChanges { 0162 target: bpmUp 0163 scale: 1.0 0164 } 0165 }, 0166 State { 0167 name: "clicked" 0168 when: mouseUp.pressed 0169 PropertyChanges { 0170 target: bpmUp 0171 scale: 0.9 0172 } 0173 }, 0174 State { 0175 name: "hover" 0176 when: mouseUp.containsMouse 0177 PropertyChanges { 0178 target: bpmUp 0179 scale: 1.1 0180 } 0181 } 0182 ] 0183 Behavior on scale { NumberAnimation { duration: 70 } } 0184 Behavior on opacity { PropertyAnimation { duration: 200 } } 0185 } 0186 }