Changeset View
Changeset View
Standalone View
Standalone View
src/activities/piano_composition/Note.qml
Context not available. | |||||
28 | Item { | 28 | Item { | ||
---|---|---|---|---|---|
29 | id: note | 29 | id: note | ||
30 | property string noteName | 30 | property string noteName | ||
31 | property bool noteIsColored: true | | |||
32 | property string noteType | 31 | property string noteType | ||
32 | property bool noteIsColored: true | ||||
33 | property string blackType: noteName[1] === "#" ? "sharp" | 33 | property string blackType: noteName[1] === "#" ? "sharp" | ||
34 | : noteName[1] === "b" ? "flat" : ""// empty, "flat" or "sharp" | 34 | : noteName[1] === "b" ? "flat" : ""// empty, "flat" or "sharp" | ||
35 | 35 | | |||
36 | readonly property string length: noteType == "Whole" ? 1 : | 36 | readonly property string length: (noteType === "Whole" || noteName === "whole") ? 1 : | ||
37 | noteType == "Half" ? 2 : | 37 | (noteType === "Half" || noteName === "half") ? 2 : | ||
38 | noteType == "Quarter" ? 4 : | 38 | (noteType === "Quarter" || noteName === "quarter") ? 4 : 8 | ||
39 | noteType == 8 | | |||
40 | 39 | | |||
41 | readonly property int noteDuration: 2000 / length | 40 | readonly property int noteDuration: 2000 / length | ||
42 | 41 | | |||
Context not available. | |||||
93 | 92 | | |||
94 | Image { | 93 | Image { | ||
95 | id: noteImage | 94 | id: noteImage | ||
96 | source: "qrc:/gcompris/src/activities/piano_composition/resource/" + noteDetails.imageName + noteType + ".svg" | 95 | source: noteType != "Rest" ? "qrc:/gcompris/src/activities/piano_composition/resource/" + noteDetails.imageName + noteType + ".svg" | ||
96 | : "qrc:/gcompris/src/activities/piano_composition/resource/" + noteDetails.imageName + ".svg" | ||||
97 | sourceSize.width: 200 | 97 | sourceSize.width: 200 | ||
98 | width: note.width | 98 | width: note.width | ||
99 | height: note.height | 99 | height: note.height | ||
Context not available. | |||||
104 | anchors.fill: noteImage | 104 | anchors.fill: noteImage | ||
105 | source: noteImage | 105 | source: noteImage | ||
106 | 106 | | |||
107 | readonly property int noteColorNumber: blackType == "" ? whiteNoteName[noteName[0]] : blackNoteName[noteName.substring(0,2)] | 107 | readonly property int noteColorNumber: { | ||
108 | if(noteType === "Rest") | ||||
109 | return 0 | ||||
110 | else if(blackType === "") | ||||
111 | return whiteNoteName[noteName[0]] | ||||
112 | else | ||||
113 | return blackNoteName[noteName.substring(0,2)] | ||||
114 | } | ||||
108 | 115 | | |||
109 | color: noteColorMap[noteColorNumber] // make image like it lays under red glass | 116 | color: noteType != "Rest" ? noteColorMap[noteColorNumber] : "black" // make image like it lays under red glass | ||
110 | visible: noteIsColored | 117 | visible: noteIsColored | ||
111 | } | 118 | } | ||
112 | 119 | | |||
113 | Timer { | 120 | Timer { | ||
114 | id: highlightTimer | 121 | id: highlightTimer | ||
115 | interval: noteDuration | 122 | interval: noteDuration | ||
116 | onRunningChanged: { | | |||
117 | highlightRectangle.visible = running | | |||
118 | // highlightImage.visible = running | | |||
119 | } | | |||
120 | } | 123 | } | ||
121 | } | 124 | } | ||
Context not available. |