Changeset View
Changeset View
Standalone View
Standalone View
src/activities/share/Share.qml
Show All 30 Lines | 25 | ActivityBase { | |||
---|---|---|---|---|---|
31 | pageComponent: Rectangle { | 31 | pageComponent: Rectangle { | ||
32 | id: background | 32 | id: background | ||
33 | anchors.fill: parent | 33 | anchors.fill: parent | ||
34 | color: "#abcdef" | 34 | color: "#abcdef" | ||
35 | signal start | 35 | signal start | ||
36 | signal stop | 36 | signal stop | ||
37 | 37 | | |||
38 | Component.onCompleted: { | 38 | Component.onCompleted: { | ||
39 | dialogActivityConfig.getInitialConfiguration() | 39 | dialogActivityConfig.initialize() | ||
40 | activity.start.connect(start) | 40 | activity.start.connect(start) | ||
41 | activity.stop.connect(stop) | 41 | activity.stop.connect(stop) | ||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | // Add here the QML items you need to access in javascript | 44 | // Add here the QML items you need to access in javascript | ||
45 | QtObject { | 45 | QtObject { | ||
46 | id: items | 46 | id: items | ||
47 | property Item main: activity.main | 47 | property Item main: activity.main | ||
48 | property alias background: background | 48 | property alias background: background | ||
49 | property alias bar: bar | 49 | property alias bar: bar | ||
50 | property alias bonus: bonus | 50 | property alias bonus: bonus | ||
51 | property alias instruction: instruction | 51 | property alias instruction: instruction | ||
52 | property int currentSubLevel: 0 | 52 | property int currentSubLevel: 0 | ||
53 | property int nbSubLevel | 53 | property int nbSubLevel | ||
54 | property alias listModel: listModel | 54 | property alias listModel: listModel | ||
55 | property bool acceptCandy: false | 55 | property bool acceptCandy: false | ||
56 | property alias dataset: dataset | | |||
57 | property alias girlWidget: girlWidget | 56 | property alias girlWidget: girlWidget | ||
58 | property alias boyWidget: boyWidget | 57 | property alias boyWidget: boyWidget | ||
59 | property alias candyWidget: candyWidget | 58 | property alias candyWidget: candyWidget | ||
60 | property alias basketWidget: basketWidget | 59 | property alias basketWidget: basketWidget | ||
61 | property alias leftWidget: leftWidget | 60 | property alias leftWidget: leftWidget | ||
62 | property int totalBoys | 61 | property int totalBoys | ||
63 | property int totalGirls | 62 | property int totalGirls | ||
64 | property int totalCandies | 63 | property int totalCandies | ||
65 | property int totalChildren: totalBoys + totalGirls | 64 | property int totalChildren: totalBoys + totalGirls | ||
65 | property var levels: activity.datasetLoader.data | ||||
AkshayCHD: What is the purpose of this check, as in the share.js file we are not making any checks based… | |||||
nothing specific, just to make this line the same across all activities but yes, we don't need this check here. So removing it. shubhammishra: nothing specific, just to make this line the same across all activities but yes, we don't need… | |||||
66 | property int barHeightAddon: ApplicationSettings.isBarHidden ? 1 : 3 | 66 | property int barHeightAddon: ApplicationSettings.isBarHidden ? 1 : 3 | ||
67 | property int cellSize: Math.round(Math.min(background.width / 12, background.height / (11 + barHeightAddon))) | 67 | property int cellSize: Math.round(Math.min(background.width / 12, background.height / (11 + barHeightAddon))) | ||
68 | property alias repeaterDropAreas: repeaterDropAreas | 68 | property alias repeaterDropAreas: repeaterDropAreas | ||
69 | property int maxNumberOfCandiesPerWidget: 8 | 69 | property int maxNumberOfCandiesPerWidget: 8 | ||
70 | } | 70 | } | ||
71 | 71 | | |||
72 | Loader { | | |||
73 | id: dataset | | |||
74 | asynchronous: false | | |||
75 | } | | |||
76 | | ||||
77 | onStart: { Activity.start(items) } | 72 | onStart: { Activity.start(items) } | ||
78 | onStop: { Activity.stop() } | 73 | onStop: { Activity.stop() } | ||
79 | 74 | | |||
80 | property bool vert: background.width >= background.height | 75 | property bool vert: background.width >= background.height | ||
81 | property int currentBoys: 0 | 76 | property int currentBoys: 0 | ||
82 | property int currentGirls: 0 | 77 | property int currentGirls: 0 | ||
83 | property int currentCandies: 0 | 78 | property int currentCandies: 0 | ||
84 | property int rest | 79 | property int rest | ||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 225 | GCText { | |||
242 | width: Math.max(Math.min(parent.width * 0.8, text.length * 8), parent.width * 0.3) | 237 | width: Math.max(Math.min(parent.width * 0.8, text.length * 8), parent.width * 0.3) | ||
243 | wrapMode: TextEdit.WordWrap | 238 | wrapMode: TextEdit.WordWrap | ||
244 | } | 239 | } | ||
245 | 240 | | |||
246 | //left widget, with girl/boy/candy/basket widgets in a grid | 241 | //left widget, with girl/boy/candy/basket widgets in a grid | ||
247 | Rectangle { | 242 | Rectangle { | ||
248 | id: leftWidget | 243 | id: leftWidget | ||
249 | width: background.vert ? | 244 | width: background.vert ? | ||
250 | items.cellSize * 1.74 : background.width | 245 | items.cellSize * 2.04 : background.width | ||
Increased left widget size, to fit double digit numbers of candy shubhammishra: Increased left widget size, to fit double digit numbers of candy | |||||
251 | height: background.vert ? | 246 | height: background.vert ? | ||
252 | background.height : items.cellSize * 1.74 | 247 | background.height : items.cellSize * 2.04 | ||
253 | color: "#5a9de0" | 248 | color: "#5a9de0" | ||
254 | border.color: "#3f81c4" | 249 | border.color: "#3f81c4" | ||
255 | border.width: 4 | 250 | border.width: 4 | ||
256 | z: 4 | 251 | z: 4 | ||
257 | 252 | | |||
258 | //grid with ok button and images of a boy, a girl, a candy, a basket and the button to display the instructions | 253 | //grid with ok button and images of a boy, a girl, a candy, a basket and the button to display the instructions | ||
259 | Grid { | 254 | Grid { | ||
260 | id: view | 255 | id: view | ||
Show All 21 Lines | 271 | MouseArea { | |||
282 | onClicked: background.check() | 277 | onClicked: background.check() | ||
283 | } | 278 | } | ||
284 | } | 279 | } | ||
285 | 280 | | |||
286 | ChildWidget { | 281 | ChildWidget { | ||
287 | id: girlWidget | 282 | id: girlWidget | ||
288 | name: "girl" | 283 | name: "girl" | ||
289 | total: items.totalGirls | 284 | total: items.totalGirls | ||
285 | visible: items.totalGirls !== 0 | ||||
290 | current: background.currentGirls | 286 | current: background.currentGirls | ||
291 | placedInChild: background.placedInGirls | 287 | placedInChild: background.placedInGirls | ||
292 | } | 288 | } | ||
293 | 289 | | |||
294 | ChildWidget { | 290 | ChildWidget { | ||
295 | id: boyWidget | 291 | id: boyWidget | ||
296 | name: "boy" | 292 | name: "boy" | ||
293 | visible: items.totalBoys !== 0 | ||||
297 | total: items.totalBoys | 294 | total: items.totalBoys | ||
298 | current: background.currentBoys | 295 | current: background.currentBoys | ||
299 | placedInChild: background.placedInBoys | 296 | placedInChild: background.placedInBoys | ||
300 | } | 297 | } | ||
301 | 298 | | |||
302 | BasketWidget { | 299 | BasketWidget { | ||
303 | id: basketWidget | 300 | id: basketWidget | ||
304 | } | 301 | } | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 343 | GCText { | |||
351 | height: parent.height | 348 | height: parent.height | ||
352 | fontSizeMode: Text.Fit | 349 | fontSizeMode: Text.Fit | ||
353 | wrapMode: Text.WordWrap | 350 | wrapMode: Text.WordWrap | ||
354 | color: "#404040" | 351 | color: "#404040" | ||
355 | text: qsTr("You can't put more than %1 pieces of candy in the same rectangle").arg(items.maxNumberOfCandiesPerWidget) | 352 | text: qsTr("You can't put more than %1 pieces of candy in the same rectangle").arg(items.maxNumberOfCandiesPerWidget) | ||
356 | } | 353 | } | ||
357 | } | 354 | } | ||
358 | 355 | | |||
359 | DialogActivityConfig { | 356 | DialogChooseLevel { | ||
360 | id: dialogActivityConfig | 357 | id: dialogActivityConfig | ||
361 | currentActivity: activity | 358 | currentActivity: activity.activityInfo | ||
362 | content: Component { | 359 | onSaveData: { | ||
363 | Item { | 360 | levelFolder = dialogActivityConfig.chosenLevels | ||
364 | height: column.height | 361 | currentActivity.currentLevels = dialogActivityConfig.chosenLevels | ||
365 | 362 | ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels) | |||
366 | Column { | | |||
367 | id: column | | |||
368 | spacing: 10 | | |||
369 | width: parent.width | | |||
370 | | ||||
371 | GCDialogCheckBox { | | |||
372 | id: easyModeBox | | |||
373 | width: dialogActivityConfig.width | | |||
374 | text: qsTr("Display candy counter") | | |||
375 | checked: background.easyMode | | |||
376 | onCheckedChanged: { | | |||
377 | background.easyMode = checked | | |||
378 | Activity.reloadRandom() | | |||
379 | } | | |||
380 | } | | |||
381 | } | | |||
382 | } | | |||
383 | } | 363 | } | ||
384 | | ||||
385 | onLoadData: { | 364 | onLoadData: { | ||
386 | if(dataToSave && dataToSave["mode"]) { | 365 | if(activityData && activityData["mode"]) { | ||
387 | background.easyMode = (dataToSave["mode"] === "true"); | 366 | background.easyMode = (activityData["mode"] === "true"); | ||
388 | } | 367 | } | ||
389 | } | 368 | } | ||
390 | 369 | onStartActivity: { | |||
391 | onSaveData: { | 370 | background.stop(); | ||
392 | dataToSave = { "mode": "" + background.easyMode } | 371 | background.start() | ||
393 | } | 372 | } | ||
394 | 373 | | |||
395 | onClose: home() | 374 | onClose: home() | ||
396 | } | 375 | } | ||
397 | 376 | | |||
398 | //bar buttons | 377 | //bar buttons | ||
399 | DialogHelp { | 378 | DialogHelp { | ||
400 | id: dialogHelp | 379 | id: dialogHelp | ||
401 | onClose: home() | 380 | onClose: home() | ||
402 | } | 381 | } | ||
403 | 382 | | |||
404 | Bar { | 383 | Bar { | ||
405 | id: bar | 384 | id: bar | ||
406 | content: BarEnumContent { value: help | home | level | reload | config} | 385 | content: BarEnumContent { value: help | home | level | reload | activityConfig} | ||
407 | onHelpClicked: { | 386 | onHelpClicked: { | ||
408 | displayDialog(dialogHelp) | 387 | displayDialog(dialogHelp) | ||
409 | } | 388 | } | ||
410 | onPreviousLevelClicked: Activity.previousLevel() | 389 | onPreviousLevelClicked: Activity.previousLevel() | ||
411 | onNextLevelClicked: Activity.nextLevel() | 390 | onNextLevelClicked: Activity.nextLevel() | ||
412 | onHomeClicked: activity.home() | 391 | onHomeClicked: activity.home() | ||
413 | onReloadClicked: Activity.reloadRandom() | 392 | onReloadClicked: Activity.reloadRandom() | ||
414 | onConfigClicked: { | 393 | onActivityConfigClicked: { | ||
415 | dialogActivityConfig.active = true | | |||
416 | displayDialog(dialogActivityConfig) | 394 | displayDialog(dialogActivityConfig) | ||
417 | } | 395 | } | ||
418 | } | 396 | } | ||
419 | 397 | | |||
420 | Bonus { | 398 | Bonus { | ||
421 | id: bonus | 399 | id: bonus | ||
422 | Component.onCompleted: { | 400 | Component.onCompleted: { | ||
423 | win.connect(Activity.nextSubLevel) | 401 | win.connect(Activity.nextSubLevel) | ||
Show All 19 Lines |
What is the purpose of this check, as in the share.js file we are not making any checks based on the case when the value of levels is null.