1
/* GCompris - OptionsRow.qml
3
* Copyright (C) 2018 Aman Kumar Gupta <gupta2140@gmail.com>
6
* Beth Hadley <bethmhadley@gmail.com> (GTK+ version)
7
* Johnny Jazeix <jazeix@gmail.com> (Qt Quick port)
8
* Aman Kumar Gupta <gupta2140@gmail.com> (Qt Quick port)
9
* Timothée Giet <animtim@gmail.com> (refactoring)
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 3 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, see <https://www.gnu.org/licenses/>.
33
//: Whole note, Half note, Quarter note and Eighth note are the different length notes in the musical notation.
34
readonly property var noteLengthName: [[qsTr("Whole note"), "Whole"], [qsTr("Half note"), "Half"], [qsTr("Quarter note"), "Quarter"], [qsTr("Eighth note"), "Eighth"]]
36
//: Whole rest, Half rest, Quarter rest and Eighth rest are the different length rests (silences) in the musical notation.
37
readonly property var restAddedMessage: [qsTr("Added whole rest"), qsTr("Added half rest"), qsTr("Added quarter rest"), qsTr("Added eighth rest")]
38
readonly property var translatedRestNames: [qsTr("Whole rest"), qsTr("Half rest"), qsTr("Quarter rest"), qsTr("Eighth rest")]
39
readonly property var lyricsOrPianoModes: [[qsTr("Piano"), "piano"], [qsTr("Lyrics"), "lyrics"]]
41
property real iconsWidth: score.height * 1.2
42
property alias noteOptionsIndex: noteOptions.currentIndex
43
property alias lyricsOrPianoModeIndex: lyricsOrPianoModeOption.currentIndex
44
property alias keyOption: keyOption
45
property alias bpmMeter: bpmMeter
46
property alias restOptionIndex: restOptions.currentIndex
48
property bool restOptionsVisible: false
49
property bool noteOptionsVisible: false
50
property bool playButtonVisible: false
51
property bool clearButtonVisible: false
52
property bool undoButtonVisible: false
53
property bool openButtonVisible: false
54
property bool saveButtonVisible: false
55
property bool changeAccidentalStyleButtonVisible: false
56
property bool lyricsOrPianoModeOptionVisible: false
57
property bool bpmVisible: false
59
signal undoButtonClicked
60
signal clearButtonClicked
61
signal openButtonClicked
62
signal saveButtonClicked
63
signal playButtonClicked
67
signal emitOptionMessage(string message)
76
source: "qrc:/gcompris/src/activities/piano_composition/resource/play.svg"
77
sourceSize.width: optionsRow.iconsWidth
78
visible: playButtonVisible
80
optionsRow.playButtonClicked()
81
emitOptionMessage(qsTr("Play melody"))
88
source: "qrc:/gcompris/src/activities/piano_composition/resource/erase.svg"
89
sourceSize.width: optionsRow.iconsWidth
90
visible: clearButtonVisible
91
onClicked: clearButtonClicked()
96
source: "qrc:/gcompris/src/activities/piano_composition/resource/undo.svg"
97
sourceSize.width: optionsRow.iconsWidth
98
visible: undoButtonVisible
100
emitOptionMessage(qsTr("Undo"))
111
width: optionsRow.iconsWidth * 2
112
height: optionsRow.iconsWidth
113
visible: restOptionsVisible
118
border.color: "black"
126
readonly property string restTypeImage: (optionsRow.noteLengthName[currentIndex][1]).toLowerCase()
128
source: "qrc:/gcompris/src/activities/piano_composition/resource/%1Rest.svg".arg(restTypeImage)
129
nbOptions: optionsRow.noteLengthName.length
131
background.restType = optionsRow.noteLengthName[currentIndex][1]
132
emitOptionMessage(optionsRow.translatedRestNames[currentIndex])
134
width: optionsRow.iconsWidth * 0.9
135
sourceSize.width: width
136
visible: restOptionsVisible
137
anchors.topMargin: -3
138
anchors.left: parent.left
139
anchors.leftMargin: 5
144
width: restOptions.width
145
sourceSize.width: width
146
source: "qrc:/gcompris/src/activities/piano_composition/resource/add.svg"
147
anchors.right: parent.right
148
anchors.verticalCenter: parent.verticalCenter
149
visible: restOptions.visible
151
emitOptionMessage(optionsRow.restAddedMessage[restOptionIndex])
153
pianoLayout.addMusicElementAndPushToStack(restType.toLowerCase(), "Rest")
159
id: changeAccidentalStyleButton
160
source: changeAccidentalStyleButtonVisible ? (piano.useSharpNotation ? "qrc:/gcompris/src/activities/piano_composition/resource/blacksharp.svg"
161
: "qrc:/gcompris/src/activities/piano_composition/resource/blackflat.svg")
163
sourceSize.width: optionsRow.iconsWidth
164
visible: changeAccidentalStyleButtonVisible
166
piano.useSharpNotation = !piano.useSharpNotation
167
//: Sharp notes and Flat notes represents the accidental style of the notes in the music.
168
emitOptionMessage(piano.useSharpNotation ? qsTr("Sharp notes") : qsTr("Flat notes"))
174
source: "qrc:/gcompris/src/activities/piano_composition/resource/genericNote%1.svg".arg(optionsRow.noteLengthName[currentIndex][1])
175
nbOptions: optionsRow.noteLengthName.length
176
sourceSize.width: optionsRow.iconsWidth
177
sourceSize.height: optionsRow.iconsWidth
180
background.currentType = optionsRow.noteLengthName[currentIndex][1]
181
emitOptionMessage(optionsRow.noteLengthName[currentIndex][0])
183
visible: noteOptionsVisible
188
source: "qrc:/gcompris/src/activities/piano_composition/resource/open.svg"
189
sourceSize.width: optionsRow.iconsWidth
190
visible: openButtonVisible
191
onClicked: openButtonClicked()
196
source: "qrc:/gcompris/src/activities/piano_composition/resource/save.svg"
197
sourceSize.width: optionsRow.iconsWidth
198
visible: saveButtonVisible
199
onClicked: saveButtonClicked()
203
id: lyricsOrPianoModeOption
204
nbOptions: optionsRow.lyricsOrPianoModes.length
205
source: "qrc:/gcompris/src/activities/piano_composition/resource/%1.svg".arg(optionsRow.lyricsOrPianoModes[currentIndex][1])
206
visible: lyricsOrPianoModeOptionVisible
207
onClicked: emitOptionMessage(optionsRow.lyricsOrPianoModes[currentIndex][0])