Changeset View
Changeset View
Standalone View
Standalone View
src/activities/piano_composition/MelodyList.qml
Context not available. | |||||
18 | 18 | | |||
---|---|---|---|---|---|
19 | import QtQuick 2.6 | 19 | import QtQuick 2.6 | ||
20 | import GCompris 1.0 | 20 | import GCompris 1.0 | ||
21 | import QtQuick.Controls 1.5 | ||||
21 | 22 | | |||
22 | import "../../core" | 23 | import "../../core" | ||
23 | import "piano_composition.js" as Activity | 24 | import "piano_composition.js" as Activity | ||
Context not available. | |||||
31 | z: 1000 | 32 | z: 1000 | ||
32 | anchors.fill: parent | 33 | anchors.fill: parent | ||
33 | visible: false | 34 | visible: false | ||
35 | | ||||
34 | signal close | 36 | signal close | ||
37 | | ||||
35 | property alias melodiesModel: melodiesModel | 38 | property alias melodiesModel: melodiesModel | ||
36 | property bool horizontalLayout: dialogBackground.width > dialogBackground.height ? true : false | 39 | property bool horizontalLayout: dialogBackground.width > dialogBackground.height | ||
40 | property int selectedMelodyIndex: -1 | ||||
37 | 41 | | |||
38 | ListModel { | 42 | ListModel { | ||
39 | id: melodiesModel | 43 | id: melodiesModel | ||
Context not available. | |||||
68 | wrapMode: Text.WordWrap | 72 | wrapMode: Text.WordWrap | ||
69 | } | 73 | } | ||
70 | } | 74 | } | ||
75 | | ||||
71 | Rectangle { | 76 | Rectangle { | ||
72 | color: "#e6e6e6" | 77 | color: "#e6e6e6" | ||
73 | radius: 6.0 | 78 | radius: 6.0 | ||
Context not available. | |||||
79 | 84 | | |||
80 | Flickable { | 85 | Flickable { | ||
81 | anchors.fill: parent | 86 | anchors.fill: parent | ||
82 | contentWidth: melodiesGrid.width | 87 | anchors.topMargin: 10 | ||
88 | anchors.leftMargin: 20 | ||||
89 | contentWidth: parent.width | ||||
83 | contentHeight: melodiesGrid.height | 90 | contentHeight: melodiesGrid.height | ||
84 | flickableDirection: Flickable.VerticalFlick | 91 | flickableDirection: Flickable.VerticalFlick | ||
85 | clip: true | 92 | clip: true | ||
86 | 93 | | |||
87 | Grid { | 94 | Flow { | ||
88 | id: melodiesGrid | 95 | id: melodiesGrid | ||
89 | rows: 10 | 96 | width: parent.width | ||
90 | columns: horizontalLayout ? 4 : 3 | | |||
91 | spacing: 40 | 97 | spacing: 40 | ||
98 | anchors.horizontalCenter: parent.horizontalCenter | ||||
92 | 99 | | |||
93 | Repeater { | 100 | Repeater { | ||
94 | id: melodiesRepeater | 101 | id: melodiesRepeater | ||
Context not available. | |||||
96 | 103 | | |||
97 | Item { | 104 | Item { | ||
98 | id: melodiesItem | 105 | id: melodiesItem | ||
99 | width: dialogBackground.width > dialogBackground.height ? dialogBackground.width * 0.2 : dialogBackground.width * 0.25 | 106 | width: dialogBackground.horizontalLayout ? dialogBackground.width / 5 : dialogBackground.width / 4 | ||
100 | height: dialogBackground.height * 0.2 | 107 | height: dialogBackground.height / 5 | ||
101 | 108 | | |||
102 | Rectangle { | 109 | Button { | ||
103 | anchors.fill: parent | 110 | text: title | ||
104 | color: "orange" | 111 | onClicked: { | ||
105 | radius: 10 | 112 | dialogBackground.selectedMelodyIndex = index | ||
106 | 113 | items.multipleStaff.loadFromData(melody) | |||
107 | Rectangle { | 114 | } | ||
108 | width: parent.width - anchors.margins | 115 | width: parent.width | ||
109 | height: parent.height - anchors.margins | 116 | height: parent.height * 0.8 | ||
110 | anchors.verticalCenter: parent.verticalCenter | 117 | style: GCButtonStyle { | ||
111 | anchors.horizontalCenter: parent.horizontalCenter | 118 | theme: "dark" | ||
112 | anchors.margins: parent.height/4 | 119 | } | ||
113 | radius: 10 | 120 | | ||
114 | color: "#E8E8E8" //paper white | 121 | Image { | ||
115 | 122 | source: "qrc:/gcompris/src/core/resource/apply.svg" | |||
116 | GCText { | 123 | sourceSize.width: height | ||
117 | anchors.fill: parent | 124 | sourceSize.height: height | ||
118 | text: title | 125 | width: height | ||
119 | fontSizeMode: Text.Fit | 126 | height: parent.height / 4 | ||
120 | wrapMode: Text.WordWrap | 127 | anchors.bottom: parent.bottom | ||
121 | } | 128 | anchors.right: parent.right | ||
122 | 129 | anchors.margins: 2 | |||
123 | MouseArea { | 130 | visible: dialogBackground.selectedMelodyIndex === index | ||
124 | anchors.fill: parent | | |||
125 | onClicked: { | | |||
126 | items.staff2.loadFromData(melody) | | |||
127 | } | | |||
128 | } | | |||
129 | } | 131 | } | ||
130 | } | 132 | } | ||
131 | } | 133 | } | ||
Context not available. | |||||
136 | Item { width: 1; height: 10 } | 138 | Item { width: 1; height: 10 } | ||
137 | } | 139 | } | ||
138 | } | 140 | } | ||
141 | | ||||
139 | GCButtonCancel { | 142 | GCButtonCancel { | ||
140 | onClose: parent.close() | 143 | onClose: { | ||
144 | dialogBackground.selectedMelodyIndex = -1 | ||||
145 | parent.close() | ||||
146 | } | ||||
141 | } | 147 | } | ||
142 | } | 148 | } | ||
Context not available. |