Changeset View
Changeset View
Standalone View
Standalone View
src/activities/algorithm/Algorithm.qml
Context not available. | |||||
52 | property alias choiceTray: choiceTray | 52 | property alias choiceTray: choiceTray | ||
---|---|---|---|---|---|
53 | property alias question: question | 53 | property alias question: question | ||
54 | property alias answer: answer | 54 | property alias answer: answer | ||
55 | property alias choice: choice | | |||
56 | property GCSfx audioEffects: activity.audioEffects | 55 | property GCSfx audioEffects: activity.audioEffects | ||
57 | property alias background: background | 56 | property alias background: background | ||
58 | property alias bar: bar | 57 | property alias bar: bar | ||
Context not available. | |||||
64 | onStart: { Activity.start(items) } | 63 | onStart: { Activity.start(items) } | ||
65 | onStop: { Activity.stop() } | 64 | onStop: { Activity.stop() } | ||
66 | 65 | | |||
66 | property bool keyNavigationVisible: false | ||||
67 | | ||||
68 | Keys.onPressed: { | ||||
69 | keyNavigationVisible = true | ||||
70 | if(event.key === Qt.Key_Left) | ||||
71 | choiceGridView.moveCurrentIndexLeft() | ||||
72 | if(event.key === Qt.Key_Right) | ||||
73 | choiceGridView.moveCurrentIndexRight() | ||||
74 | if(event.key === Qt.Key_Space || event.key === Qt.Key_Enter || event.key === Qt.Key_Return) | ||||
75 | choiceGridView.currentItem.clicked() | ||||
76 | } | ||||
77 | | ||||
67 | Column { | 78 | Column { | ||
68 | id: column | 79 | id: column | ||
69 | spacing: 10 | 80 | spacing: 10 | ||
70 | x: parent.width * 0.1 | 81 | y: parent.height * 0.05 | ||
71 | y: parent.height * 0.1 | 82 | width: itemWidth * Activity.images.length | ||
72 | width: parent.width * 0.8 | 83 | anchors.horizontalCenter: parent.horizontalCenter | ||
73 | 84 | | |||
74 | property int itemWidth: width / Activity.images.length - 10 | 85 | property int itemWidth: Math.min(background.width * 0.75 / Activity.images.length, background.height * 0.19) | ||
75 | property int itemHeight: itemWidth | | |||
76 | 86 | | |||
77 | Rectangle { | 87 | Rectangle { | ||
78 | id: questionTray | 88 | id: questionTray | ||
79 | height: column.itemHeight + 10 | 89 | height: column.itemWidth | ||
80 | width: parent.width + 10 | 90 | width: parent.width | ||
81 | color: "#55333333" | 91 | color: "#55333333" | ||
82 | border.color: "black" | | |||
83 | border.width: 0 | | |||
84 | radius: 5 | 92 | radius: 5 | ||
85 | 93 | | |||
86 | Row { | 94 | Row { | ||
87 | anchors.topMargin: 4 | 95 | anchors.topMargin: 4 | ||
88 | anchors.bottomMargin: 4 | 96 | anchors.bottomMargin: 4 | ||
89 | anchors.leftMargin: 10 | 97 | anchors.leftMargin: 5 | ||
90 | anchors.rightMargin: 10 | | |||
91 | anchors.fill: parent | 98 | anchors.fill: parent | ||
92 | spacing: 10 | 99 | spacing: 5.7 * ApplicationInfo.ratio | ||
93 | Repeater { | 100 | Repeater { | ||
94 | id: question | 101 | id: question | ||
95 | Image { | 102 | Image { | ||
96 | source: Activity.url + modelData + '.svg' | 103 | source: Activity.url + modelData + '.svg' | ||
97 | sourceSize.height: questionTray.height | 104 | sourceSize.height: height | ||
98 | width: column.itemWidth | 105 | sourceSize.width: width | ||
99 | height: column.itemHeight | 106 | width: column.itemWidth - 6 * ApplicationInfo.ratio | ||
107 | height: width | ||||
108 | fillMode: Image.PreserveAspectFit | ||||
100 | } | 109 | } | ||
101 | } | 110 | } | ||
102 | } | 111 | } | ||
Context not available. | |||||
104 | 113 | | |||
105 | Rectangle { | 114 | Rectangle { | ||
106 | id: answerTray | 115 | id: answerTray | ||
107 | height: column.itemHeight + 10 | 116 | height: column.itemWidth | ||
108 | width: parent.width + 10 | 117 | width: parent.width | ||
109 | color: "#55333333" | 118 | color: "#55333333" | ||
110 | border.color: "black" | | |||
111 | border.width: 0 | | |||
112 | radius: 5 | 119 | radius: 5 | ||
113 | Row { | 120 | Row { | ||
114 | anchors.topMargin: 4 | 121 | anchors.topMargin: 4 | ||
115 | anchors.bottomMargin: 4 | 122 | anchors.bottomMargin: 4 | ||
116 | anchors.leftMargin: 10 | 123 | anchors.leftMargin: 5 | ||
117 | anchors.rightMargin: 10 | | |||
118 | anchors.fill: parent | 124 | anchors.fill: parent | ||
119 | spacing: 10 | 125 | spacing: 5.7 * ApplicationInfo.ratio | ||
120 | Repeater { | 126 | Repeater { | ||
121 | id: answer | 127 | id: answer | ||
122 | Image { | 128 | Image { | ||
123 | source: "qrc:/gcompris/src/activities/algorithm/resource/" + | 129 | source: "qrc:/gcompris/src/activities/algorithm/resource/" + | ||
124 | modelData + '.svg' | 130 | modelData + '.svg' | ||
125 | sourceSize.height: answerTray.height | 131 | sourceSize.height: height | ||
126 | width: column.itemWidth | 132 | sourceSize.width: width | ||
127 | height: column.itemHeight | 133 | width: column.itemWidth - 6 * ApplicationInfo.ratio | ||
134 | height: width | ||||
135 | fillMode: Image.PreserveAspectFit | ||||
128 | } | 136 | } | ||
129 | } | 137 | } | ||
130 | } | 138 | } | ||
Context not available. | |||||
132 | 140 | | |||
133 | // A spacer | 141 | // A spacer | ||
134 | Item { | 142 | Item { | ||
135 | height: column.itemHeight / 2 | 143 | height: column.itemWidth / 2 | ||
136 | width: parent.width | 144 | width: parent.width | ||
137 | } | 145 | } | ||
138 | 146 | | |||
139 | Rectangle { | 147 | Rectangle { | ||
140 | id: choiceTray | 148 | id: choiceTray | ||
141 | height: column.itemHeight + 10 | 149 | height: column.itemWidth | ||
142 | width: parent.width + 10 | 150 | width: parent.width | ||
143 | color: "#55333333" | 151 | color: "#55333333" | ||
144 | border.color: "black" | | |||
145 | border.width: 0 | | |||
146 | radius: 5 | 152 | radius: 5 | ||
147 | Row { | 153 | | ||
148 | anchors.topMargin: 4 | 154 | GridView { | ||
149 | anchors.bottomMargin: 4 | 155 | id: choiceGridView | ||
150 | anchors.leftMargin: 10 | | |||
151 | anchors.rightMargin: 10 | | |||
152 | anchors.fill: parent | 156 | anchors.fill: parent | ||
153 | spacing: 10 | 157 | model: Activity.images | ||
154 | Repeater { | 158 | cellWidth: column.itemWidth | ||
155 | id: choice | 159 | cellHeight: cellWidth | ||
156 | model: Activity.images | 160 | interactive: false | ||
161 | keyNavigationWraps: true | ||||
162 | highlightFollowsCurrentItem: true | ||||
163 | highlight: Rectangle { | ||||
164 | width: parent.cellWidth | ||||
165 | height: parent.cellHeight | ||||
166 | color: "#AAFFFFFF" | ||||
167 | border.width: 2 | ||||
168 | border.color: "white" | ||||
169 | visible: background.keyNavigationVisible | ||||
170 | Behavior on x { SpringAnimation { spring: 2; damping: 0.2 } } | ||||
171 | Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } | ||||
172 | } | ||||
173 | | ||||
174 | delegate: Item { | ||||
175 | id: cellItem | ||||
176 | width: choiceGridView.cellWidth | ||||
177 | height: width | ||||
178 | | ||||
179 | signal clicked | ||||
180 | onClicked: { | ||||
181 | if(Activity.clickHandler(modelData)) { | ||||
182 | particle.burst(20) | ||||
183 | } | ||||
184 | } | ||||
185 | | ||||
157 | Image { | 186 | Image { | ||
158 | id: img | 187 | id: img | ||
159 | source: Activity.url + modelData + '.svg' | 188 | source: Activity.url + modelData + '.svg' | ||
160 | sourceSize.height: parent.height | 189 | width: column.itemWidth - 6 * ApplicationInfo.ratio | ||
161 | width: column.itemWidth | 190 | height: width | ||
162 | height: column.itemHeight | 191 | sourceSize.width: width | ||
192 | sourceSize.height: height | ||||
193 | anchors.centerIn: parent | ||||
194 | fillMode: Image.PreserveAspectFit | ||||
163 | state: "notclicked" | 195 | state: "notclicked" | ||
164 | signal clicked | 196 | | ||
165 | MouseArea { | 197 | MouseArea { | ||
166 | id: mouseArea | 198 | id: mouseArea | ||
167 | hoverEnabled: true | 199 | hoverEnabled: true | ||
168 | anchors.fill: parent | 200 | anchors.fill: parent | ||
169 | onClicked: { | 201 | onClicked: cellItem.clicked() | ||
170 | if(Activity.clickHandler(modelData)) { | | |||
171 | particle.burst(20) | | |||
172 | } | | |||
173 | } | | |||
174 | } | 202 | } | ||
175 | states: [ | 203 | states: [ | ||
176 | State { | 204 | State { | ||
Context not available. | |||||
233 | 261 | | |||
234 | Score { | 262 | Score { | ||
235 | anchors { | 263 | anchors { | ||
236 | bottom: parent.bottom | 264 | bottom: bar.top | ||
237 | bottomMargin: 10 * ApplicationInfo.ratio | 265 | bottomMargin: 10 * ApplicationInfo.ratio | ||
238 | right: parent.right | 266 | right: parent.right | ||
239 | rightMargin: 10 * ApplicationInfo.ratio | 267 | rightMargin: 5 * ApplicationInfo.ratio | ||
240 | top: undefined | 268 | top: undefined | ||
241 | left: undefined | 269 | left: undefined | ||
242 | } | 270 | } | ||
Context not available. |