Changeset View
Changeset View
Standalone View
Standalone View
src/core/DialogChooseLevel.qml
Show All 37 Lines | 34 | Rectangle { | |||
---|---|---|---|---|---|
38 | /* Public interface: */ | 38 | /* Public interface: */ | ||
39 | 39 | | |||
40 | /** | 40 | /** | ||
41 | * type:string | 41 | * type:string | ||
42 | * The name of the activity in case of per-activity config. | 42 | * The name of the activity in case of per-activity config. | ||
43 | * | 43 | * | ||
44 | * Will be autogenerated unless set by the caller. | 44 | * Will be autogenerated unless set by the caller. | ||
45 | */ | 45 | */ | ||
46 | property string activityName | 46 | property string activityName: currentActivity.name.split('/')[0] | ||
47 | 47 | | |||
48 | /// @cond INTERNAL_DOCS | 48 | /// @cond INTERNAL_DOCS | ||
49 | 49 | | |||
50 | property bool isDialog: true | 50 | property bool isDialog: true | ||
51 | 51 | | |||
52 | /** | 52 | /** | ||
53 | * type:string | 53 | * type:string | ||
54 | * Title of the configuration dialog. | 54 | * Title of the configuration dialog. | ||
55 | */ | 55 | */ | ||
56 | readonly property string title: currentActivity ? qsTr("%1 settings").arg(currentActivity.title) : "" | 56 | readonly property string title: currentActivity ? qsTr("%1 settings").arg(currentActivity.title) : "" | ||
57 | 57 | | |||
58 | property var difficultiesModel: [] | 58 | property var difficultiesModel: [] | ||
59 | property QtObject currentActivity | 59 | property QtObject currentActivity | ||
60 | 60 | | |||
61 | property string chosenLevel | 61 | property string chosenLevel | ||
62 | 62 | | |||
63 | property var activityData | 63 | property var activityData | ||
64 | onActivityDataChanged: loadData() | 64 | onActivityDataChanged: loadData() | ||
65 | /// @endcond | 65 | /// @endcond | ||
66 | 66 | | |||
67 | /** | 67 | /** | ||
68 | * By default, we display configuration (this avoids to add code in each | ||||
69 | * activity to set it by default). | ||||
70 | */ | ||||
71 | property bool displayDatasetAtStart: !hasConfig | ||||
72 | | ||||
73 | /** | ||||
68 | * Emitted when the config dialog has been closed. | 74 | * Emitted when the config dialog has been closed. | ||
69 | */ | 75 | */ | ||
70 | signal close | 76 | signal close | ||
71 | 77 | | |||
72 | /** | 78 | /** | ||
73 | * Emitted when the config dialog has been started. | 79 | * Emitted when the config dialog has been started. | ||
74 | */ | 80 | */ | ||
75 | signal start | 81 | signal start | ||
Show All 13 Lines | |||||
89 | 95 | | |||
90 | signal startActivity | 96 | signal startActivity | ||
91 | 97 | | |||
92 | /** | 98 | /** | ||
93 | * Emitted when the config settings have been loaded. | 99 | * Emitted when the config settings have been loaded. | ||
94 | */ | 100 | */ | ||
95 | signal loadData | 101 | signal loadData | ||
96 | 102 | | |||
103 | property bool hasConfigOrDataset: hasConfig || hasDataset | ||||
104 | property bool hasConfig: activityConfigFile.exists("qrc:/gcompris/src/activities/"+activityName+"/ActivityConfig.qml") | ||||
105 | property bool hasDataset: currentActivity && currentActivity.levels.length !== 0 | ||||
106 | | ||||
97 | color: "#696da3" | 107 | color: "#696da3" | ||
98 | border.color: "black" | 108 | border.color: "black" | ||
99 | border.width: 1 | 109 | border.width: 1 | ||
100 | 110 | | |||
101 | function initialize() { | 111 | function initialize() { | ||
102 | activityName = currentActivity.name.split('/')[0] | | |||
103 | | ||||
104 | // dataset information | 112 | // dataset information | ||
105 | chosenLevel = currentActivity.currentLevel | 113 | chosenLevel = currentActivity.currentLevel | ||
106 | difficultiesModel = [] | 114 | difficultiesModel = [] | ||
107 | if(currentActivity.levels.length == 0) { | 115 | if(currentActivity.levels.length == 0) { | ||
108 | print("no levels to load for", activityName) | 116 | print("no levels to load for", activityName) | ||
109 | } | 117 | } | ||
110 | else { | 118 | else { | ||
111 | for(var level in currentActivity.levels) { | 119 | for(var level in currentActivity.levels) { | ||
112 | objectiveLoader.dataFiles.push({"level": currentActivity.levels[level], "file": "qrc:/gcompris/src/activities/"+activityName+"/resource/"+currentActivity.levels[level]+"/Data.qml"}) | 120 | objectiveLoader.dataFiles.push({"level": currentActivity.levels[level], "file": "qrc:/gcompris/src/activities/"+activityName+"/resource/"+currentActivity.levels[level]+"/Data.qml"}) | ||
113 | } | 121 | } | ||
114 | objectiveLoader.start() | 122 | objectiveLoader.start() | ||
115 | } | 123 | } | ||
124 | | ||||
125 | // Defaults to config if in an activity else to dataset if in menu | ||||
126 | if(displayDatasetAtStart) { | ||||
127 | datasetVisibleButton.clicked() | ||||
128 | } | ||||
129 | else { | ||||
130 | optionsVisibleButton.clicked() | ||||
131 | } | ||||
116 | } | 132 | } | ||
117 | 133 | | |||
118 | Loader { | 134 | Loader { | ||
119 | id: objectiveLoader | 135 | id: objectiveLoader | ||
120 | property var dataFiles: [] | 136 | property var dataFiles: [] | ||
121 | property var currentFile | 137 | property var currentFile | ||
122 | signal start | 138 | signal start | ||
123 | signal stop | 139 | signal stop | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 190 | GCText { | |||
183 | wrapMode: Text.WordWrap | 199 | wrapMode: Text.WordWrap | ||
184 | } | 200 | } | ||
185 | } | 201 | } | ||
186 | } | 202 | } | ||
187 | 203 | | |||
188 | // Header buttons | 204 | // Header buttons | ||
189 | Row { | 205 | Row { | ||
190 | id: datasetOptionsRow | 206 | id: datasetOptionsRow | ||
191 | height: datasetVisibleButton.height | 207 | height: dialogChooseLevel.height / 12 | ||
jjazeix: just for my information, what do these changes fix? | |||||
These changes fix the Binding loop error qrc:/gcompris/src/core/DialogChooseLevel.qml:211:17: QML Button: Binding loop detected for property "implicitHeight" . Since initially the height of datasetOptionsRow was depended on height of datasetVisibleButton explicitly and height of datasetVisibleButton was depended on height of datasetOptionsRow implicitly which resulted in a binding loop. AkshayCHD: These changes fix the Binding loop error qrc:/gcompris/src/core/DialogChooseLevel.qml:211:17… | |||||
192 | width: parent.width | 208 | width: parent.width | ||
193 | spacing: parent.width / 4 | 209 | spacing: parent.width / 4 | ||
194 | anchors.leftMargin: parent.width / 8 | 210 | anchors.leftMargin: parent.width / 8 | ||
195 | Button { | 211 | Button { | ||
196 | id: datasetVisibleButton | 212 | id: datasetVisibleButton | ||
197 | text: qsTr("Dataset") | 213 | text: qsTr("Dataset") | ||
198 | enabled: difficultiesRepeater.count != 0 | 214 | enabled: hasDataset | ||
215 | height: parent.height | ||||
199 | width: parent.width / 3 | 216 | width: parent.width / 3 | ||
200 | property bool selected: true | 217 | property bool selected: true | ||
201 | style: GCButtonStyle { | 218 | style: GCButtonStyle { | ||
202 | selected: datasetVisibleButton.selected | 219 | selected: datasetVisibleButton.selected | ||
203 | } | 220 | } | ||
204 | onClicked: { selected = true; } | 221 | onClicked: { selected = true; } | ||
205 | } | 222 | } | ||
206 | Button { | 223 | Button { | ||
207 | id: optionsVisibleButton | 224 | id: optionsVisibleButton | ||
225 | height: parent.height | ||||
208 | text: qsTr("Options") | 226 | text: qsTr("Options") | ||
209 | enabled: activityConfigFile.exists("qrc:/gcompris/src/activities/"+activityName+"/ActivityConfig.qml") | 227 | enabled: hasConfig | ||
210 | width: parent.width / 3 | 228 | width: parent.width / 3 | ||
211 | style: GCButtonStyle { | 229 | style: GCButtonStyle { | ||
212 | selected: !datasetVisibleButton.selected | 230 | selected: !datasetVisibleButton.selected | ||
213 | } | 231 | } | ||
214 | onClicked: { datasetVisibleButton.selected = false; } //showOptions() | 232 | onClicked: { datasetVisibleButton.selected = false; } //showOptions() | ||
215 | } | 233 | } | ||
216 | } | 234 | } | ||
217 | 235 | | |||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 314 | GCButtonScroll { | |||
302 | onDown: flick.flick(0, -1400) | 320 | onDown: flick.flick(0, -1400) | ||
303 | upVisible: flick.visibleArea.yPosition <= 0 ? false : true | 321 | upVisible: flick.visibleArea.yPosition <= 0 ? false : true | ||
304 | downVisible: flick.visibleArea.yPosition + flick.visibleArea.heightRatio >= 1 ? false : true | 322 | downVisible: flick.visibleArea.yPosition + flick.visibleArea.heightRatio >= 1 ? false : true | ||
305 | } | 323 | } | ||
306 | } | 324 | } | ||
307 | // Footer buttons | 325 | // Footer buttons | ||
308 | Row { | 326 | Row { | ||
309 | id: saveAndPlayRow | 327 | id: saveAndPlayRow | ||
310 | height: cancelButton.height | 328 | height: dialogChooseLevel.height / 12 | ||
311 | width: parent.width | 329 | width: parent.width | ||
312 | spacing: parent.width / 16 | 330 | spacing: parent.width / 16 | ||
313 | Button { | 331 | Button { | ||
314 | id: cancelButton | 332 | id: cancelButton | ||
333 | height: parent.height | ||||
315 | text: qsTr("Cancel") | 334 | text: qsTr("Cancel") | ||
316 | width: parent.width / 4 | 335 | width: parent.width / 4 | ||
317 | property bool selected: true | 336 | property bool selected: true | ||
318 | style: GCButtonStyle {} | 337 | style: GCButtonStyle {} | ||
319 | onClicked: dialogChooseLevel.close() | 338 | onClicked: dialogChooseLevel.close() | ||
320 | } | 339 | } | ||
321 | Button { | 340 | Button { | ||
322 | id: saveButton | 341 | id: saveButton | ||
342 | height: parent.height | ||||
323 | text: qsTr("Save") | 343 | text: qsTr("Save") | ||
324 | width: parent.width / 4 | 344 | width: parent.width / 4 | ||
325 | property bool selected: true | 345 | property bool selected: true | ||
326 | style: GCButtonStyle { } | 346 | style: GCButtonStyle { } | ||
327 | onClicked: { | 347 | onClicked: { | ||
328 | saveData(); | 348 | saveData(); | ||
329 | } | 349 | } | ||
330 | } | 350 | } | ||
331 | Button { | 351 | Button { | ||
332 | id: saveAndStartButton | 352 | id: saveAndStartButton | ||
353 | height: parent.height | ||||
333 | text: qsTr("Save and start") | 354 | text: qsTr("Save and start") | ||
334 | width: parent.width / 3 | 355 | width: parent.width / 3 | ||
335 | style: GCButtonStyle { } | 356 | style: GCButtonStyle { } | ||
336 | onClicked: { | 357 | onClicked: { | ||
337 | saveData(); | 358 | saveData(); | ||
338 | startActivity(); | 359 | startActivity(); | ||
339 | } | 360 | } | ||
340 | } | 361 | } | ||
Show All 18 Lines |
just for my information, what do these changes fix?