Warning, /education/gcompris/src/activities/piano_composition/OptionsRow.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - OptionsRow.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 Grid { 0019 id: optionsRow 0020 columns: 2 0021 0022 //: Whole note, Half note, Quarter note and Eighth note are the different length notes in the musical notation. 0023 readonly property var noteLengthName: [[qsTr("Whole note"), "Whole"], [qsTr("Half note"), "Half"], [qsTr("Quarter note"), "Quarter"], [qsTr("Eighth note"), "Eighth"]] 0024 0025 //: Whole rest, Half rest, Quarter rest and Eighth rest are the different length rests (silences) in the musical notation. 0026 readonly property var restAddedMessage: [qsTr("Whole rest added"), qsTr("Half rest added"), qsTr("Quarter rest added"), qsTr("Eighth rest added")] 0027 readonly property var translatedRestNames: [qsTr("Whole rest"), qsTr("Half rest"), qsTr("Quarter rest"), qsTr("Eighth rest")] 0028 readonly property var lyricsOrPianoModes: [[qsTr("Piano"), "piano"], [qsTr("Lyrics"), "lyrics"]] 0029 0030 property real iconsWidth: score.height * 1.2 0031 property alias noteOptionsIndex: noteOptions.currentIndex 0032 property alias lyricsOrPianoModeIndex: lyricsOrPianoModeOption.currentIndex 0033 property alias keyOption: keyOption 0034 property alias bpmMeter: bpmMeter 0035 property alias restOptionIndex: restOptions.currentIndex 0036 0037 property bool restOptionsVisible: false 0038 property bool noteOptionsVisible: false 0039 property bool playButtonVisible: false 0040 property bool clearButtonVisible: false 0041 property bool undoButtonVisible: false 0042 property bool openButtonVisible: false 0043 property bool saveButtonVisible: false 0044 property bool changeAccidentalStyleButtonVisible: false 0045 property bool lyricsOrPianoModeOptionVisible: false 0046 property bool bpmVisible: false 0047 0048 signal undoButtonClicked 0049 signal clearButtonClicked 0050 signal openButtonClicked 0051 signal saveButtonClicked 0052 signal playButtonClicked 0053 signal bpmIncreased 0054 signal bpmDecreased 0055 signal bpmChanged 0056 signal emitOptionMessage(string message) 0057 0058 onPlayButtonClicked: { 0059 if(!multipleStaff.isMusicPlaying) { 0060 emitOptionMessage(qsTr("Play melody")) 0061 multipleStaff.play() 0062 } else { 0063 multipleStaff.stopPlaying() 0064 } 0065 } 0066 0067 0068 BpmMeter { 0069 id: bpmMeter 0070 } 0071 0072 BarButton { 0073 id: playButton 0074 source: multipleStaff.isMusicPlaying ? 0075 "qrc:/gcompris/src/activities/piano_composition/resource/stop.svg" : 0076 "qrc:/gcompris/src/activities/piano_composition/resource/play.svg" 0077 sourceSize.width: optionsRow.iconsWidth 0078 visible: playButtonVisible 0079 onClicked: { 0080 optionsRow.playButtonClicked() 0081 } 0082 } 0083 0084 BarButton { 0085 id: clearButton 0086 source: "qrc:/gcompris/src/activities/piano_composition/resource/erase.svg" 0087 sourceSize.width: optionsRow.iconsWidth 0088 visible: clearButtonVisible 0089 onClicked: clearButtonClicked() 0090 } 0091 0092 BarButton { 0093 id: undoButton 0094 source: "qrc:/gcompris/src/activities/piano_composition/resource/undo.svg" 0095 sourceSize.width: optionsRow.iconsWidth 0096 visible: undoButtonVisible 0097 onClicked: { 0098 emitOptionMessage(qsTr("Undo")) 0099 undoButtonClicked() 0100 } 0101 } 0102 0103 KeyOption { 0104 id: keyOption 0105 } 0106 0107 Item { 0108 id: rests 0109 width: optionsRow.iconsWidth * 2 0110 height: optionsRow.iconsWidth 0111 visible: restOptionsVisible 0112 Rectangle { 0113 color: "yellow" 0114 opacity: 0.1 0115 border.width: 2 0116 border.color: "black" 0117 anchors.fill: parent 0118 radius: 10 0119 } 0120 0121 SwitchableOptions { 0122 id: restOptions 0123 0124 readonly property string restTypeImage: (optionsRow.noteLengthName[currentIndex][1]).toLowerCase() 0125 0126 source: "qrc:/gcompris/src/activities/piano_composition/resource/%1Rest.svg".arg(restTypeImage) 0127 nbOptions: optionsRow.noteLengthName.length 0128 onClicked: { 0129 background.restType = optionsRow.noteLengthName[currentIndex][1] 0130 emitOptionMessage(optionsRow.translatedRestNames[currentIndex]) 0131 } 0132 width: optionsRow.iconsWidth * 0.9 0133 sourceSize.width: width 0134 visible: restOptionsVisible 0135 anchors.topMargin: -3 0136 anchors.left: parent.left 0137 anchors.leftMargin: 5 0138 } 0139 0140 BarButton { 0141 id: addRestButton 0142 width: restOptions.width 0143 sourceSize.width: width 0144 source: "qrc:/gcompris/src/activities/piano_composition/resource/add.svg" 0145 anchors.right: parent.right 0146 anchors.verticalCenter: parent.verticalCenter 0147 visible: restOptions.visible 0148 onClicked: { 0149 emitOptionMessage(optionsRow.restAddedMessage[restOptionIndex]) 0150 parent.scale = 1 0151 pianoLayout.addMusicElementAndPushToStack(restType.toLowerCase(), "Rest") 0152 } 0153 } 0154 } 0155 0156 BarButton { 0157 id: changeAccidentalStyleButton 0158 source: changeAccidentalStyleButtonVisible ? (piano.useSharpNotation ? "qrc:/gcompris/src/activities/piano_composition/resource/blacksharp.svg" 0159 : "qrc:/gcompris/src/activities/piano_composition/resource/blackflat.svg") 0160 : "" 0161 sourceSize.width: optionsRow.iconsWidth 0162 visible: changeAccidentalStyleButtonVisible 0163 onClicked: { 0164 piano.useSharpNotation = !piano.useSharpNotation 0165 //: Sharp notes and Flat notes represents the accidental style of the notes in the music. 0166 emitOptionMessage(piano.useSharpNotation ? qsTr("Sharp notes") : qsTr("Flat notes")) 0167 } 0168 } 0169 0170 SwitchableOptions { 0171 id: noteOptions 0172 source: "qrc:/gcompris/src/activities/piano_composition/resource/genericNote%1.svg".arg(optionsRow.noteLengthName[currentIndex][1]) 0173 nbOptions: optionsRow.noteLengthName.length 0174 sourceSize.width: optionsRow.iconsWidth 0175 sourceSize.height: optionsRow.iconsWidth 0176 currentIndex: 2 0177 onClicked: { 0178 background.currentType = optionsRow.noteLengthName[currentIndex][1] 0179 emitOptionMessage(optionsRow.noteLengthName[currentIndex][0]) 0180 } 0181 visible: noteOptionsVisible 0182 } 0183 0184 BarButton { 0185 id: openButton 0186 source: "qrc:/gcompris/src/activities/piano_composition/resource/open.svg" 0187 sourceSize.width: optionsRow.iconsWidth 0188 visible: openButtonVisible 0189 onClicked: openButtonClicked() 0190 } 0191 0192 BarButton { 0193 id: saveButton 0194 source: "qrc:/gcompris/src/activities/piano_composition/resource/save.svg" 0195 sourceSize.width: optionsRow.iconsWidth 0196 visible: saveButtonVisible 0197 onClicked: saveButtonClicked() 0198 } 0199 0200 SwitchableOptions { 0201 id: lyricsOrPianoModeOption 0202 nbOptions: optionsRow.lyricsOrPianoModes.length 0203 source: "qrc:/gcompris/src/activities/piano_composition/resource/%1.svg".arg(optionsRow.lyricsOrPianoModes[currentIndex][1]) 0204 visible: lyricsOrPianoModeOptionVisible 0205 onClicked: emitOptionMessage(optionsRow.lyricsOrPianoModes[currentIndex][0]) 0206 } 0207 0208 }