Warning, /education/gcompris/src/activities/piano_composition/MelodyList.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - MelodyList.qml
0002 *
0003 * SPDX-FileCopyrightText: 2017 Divyam Madaan <divyam3897@gmail.com>
0004 * SPDX-FileCopyrightText: 2018 Aman Kumar Gupta <gupta2140@gmail.com>
0005 *
0006 * Authors:
0007 * Beth Hadley <bethmhadley@gmail.com> (GTK+ version)
0008 * Divyam Madaan <divyam3897@gmail.com> (Qt Quick port)
0009 * Aman Kumar Gupta <gupta2140@gmail.com> (Qt Quick port)
0010 *
0011 * SPDX-License-Identifier: GPL-3.0-or-later
0012 */
0013
0014 import QtQuick 2.12
0015 import GCompris 1.0
0016
0017 import "../../core"
0018 import "piano_composition.js" as Activity
0019
0020 Rectangle {
0021 id: dialogBackground
0022 color: "#696da3"
0023 z: 10000
0024 anchors.fill: parent
0025 visible: false
0026 focus: visible
0027
0028 Keys.onPressed: {
0029 if(event.key === Qt.Key_Down) {
0030 scrollItem.down();
0031 } else if(event.key === Qt.Key_Up) {
0032 scrollItem.up();
0033 }
0034 }
0035
0036 Keys.onEscapePressed: closeButton.close()
0037
0038 Keys.onReleased: {
0039 if(event.key === Qt.Key_Back) {
0040 event.accepted = true;
0041 closeButton.close();
0042 }
0043 }
0044
0045 signal close
0046
0047 property alias melodiesModel: melodiesModel
0048 property bool horizontalLayout: dialogBackground.width >= dialogBackground.height
0049 property int selectedMelodyIndex: -1
0050
0051 ListModel {
0052 id: melodiesModel
0053 }
0054
0055 Column {
0056 spacing: 10
0057 anchors.top: parent.top
0058 anchors.topMargin: 15
0059 anchors.horizontalCenter: parent.horizontalCenter
0060 width: dialogBackground.width - 30
0061 Rectangle {
0062 id: titleRectangle
0063 color: "#e6e6e6"
0064 radius: 10 * ApplicationInfo.ratio
0065 width: parent.width
0066 height: title.height + 10 * 2
0067
0068 GCText {
0069 id: title
0070 text: qsTr("Melodies")
0071 width: titleRectangle.width - 120 * ApplicationInfo.ratio //minus twice the cancel button size
0072 anchors.horizontalCenter: titleRectangle.horizontalCenter
0073 anchors.verticalCenter: titleRectangle.verticalCenter
0074 horizontalAlignment: Text.AlignHCenter
0075 verticalAlignment: Text.AlignVCenter
0076 fontSize: 20
0077 font.weight: Font.DemiBold
0078 wrapMode: Text.WordWrap
0079 }
0080 // The close button
0081 GCButtonCancel {
0082 id: closeButton
0083 apply: true
0084 anchors.verticalCenter: titleRectangle.verticalCenter
0085 anchors.margins: 2 * ApplicationInfo.ratio
0086 onClose: {
0087 dialogBackground.selectedMelodyIndex = -1
0088 dialogBackground.close()
0089 }
0090 }
0091 }
0092
0093 Rectangle {
0094 color: "#bdbed0"
0095 radius: 10 * ApplicationInfo.ratio
0096 width: dialogBackground.width - 30
0097 height: dialogBackground.height - (2 * parent.anchors.topMargin) - titleRectangle.height - parent.spacing
0098 border.color: "white"
0099 border.width: 3 * ApplicationInfo.ratio
0100
0101 Flickable {
0102 id: flickableList
0103 flickDeceleration: 1500
0104 anchors.fill: parent
0105 anchors.margins: 10 * ApplicationInfo.ratio
0106 contentWidth: width
0107 contentHeight: melodiesGrid.height
0108 flickableDirection: Flickable.VerticalFlick
0109 clip: true
0110
0111 Flow {
0112 id: melodiesGrid
0113 width: parent.width
0114 spacing: 40
0115 anchors.horizontalCenter: parent.horizontalCenter
0116
0117 Repeater {
0118 id: melodiesRepeater
0119 model: melodiesModel
0120
0121 Item {
0122 id: melodiesItem
0123 width: dialogBackground.horizontalLayout ? dialogBackground.width / 5 : dialogBackground.width / 4
0124 height: dialogBackground.height / 5
0125
0126 GCButton {
0127 text: title
0128 onClicked: {
0129 dialogBackground.selectedMelodyIndex = index
0130 items.multipleStaff.stopAudios()
0131 items.multipleStaff.nbStaves = 2
0132 items.multipleStaff.bpmValue = defaultBPM ? defaultBPM : 60
0133 items.multipleStaff.loadFromData(melody)
0134 lyricsArea.setLyrics(title, _origin, lyrics)
0135 }
0136 width: parent.width
0137 height: parent.height * 0.8
0138 theme: "dark"
0139
0140 Image {
0141 source: "qrc:/gcompris/src/core/resource/apply.svg"
0142 sourceSize.width: height
0143 sourceSize.height: height
0144 width: height
0145 height: parent.height / 4
0146 anchors.bottom: parent.bottom
0147 anchors.right: parent.right
0148 anchors.margins: 2
0149 visible: dialogBackground.selectedMelodyIndex === index
0150 }
0151 }
0152 }
0153 }
0154 }
0155 }
0156 // The scroll buttons
0157 GCButtonScroll {
0158 id: scrollItem
0159 anchors.right: parent.right
0160 anchors.rightMargin: 5 * ApplicationInfo.ratio
0161 anchors.bottom: flickableList.bottom
0162 anchors.bottomMargin: 5 * ApplicationInfo.ratio
0163 onUp: flickableList.flick(0, 1400)
0164 onDown: flickableList.flick(0, -1400)
0165 upVisible: flickableList.atYBeginning ? false : true
0166 downVisible: flickableList.atYEnd ? false : true
0167 }
0168 }
0169 }
0170 }