Changeset View
Changeset View
Standalone View
Standalone View
src/activities/redraw/Redraw.qml
Show All 27 Lines | |||||
28 | 28 | | |||
29 | ActivityBase { | 29 | ActivityBase { | ||
30 | id: activity | 30 | id: activity | ||
31 | 31 | | |||
32 | onStart: focus = true | 32 | onStart: focus = true | ||
33 | onStop: {} | 33 | onStop: {} | ||
34 | 34 | | |||
35 | property bool symmetry: false | 35 | property bool symmetry: false | ||
36 | property alias currentActivity: activity.activityInfo | ||||
36 | 37 | | |||
37 | pageComponent: Image { | 38 | pageComponent: Image { | ||
38 | id: background | 39 | id: background | ||
39 | anchors.fill: parent | 40 | anchors.fill: parent | ||
40 | source: Activity.url + "background.svg" | 41 | source: Activity.url + "background.svg" | ||
41 | fillMode: Image.PreserveAspectCrop | 42 | fillMode: Image.PreserveAspectCrop | ||
42 | sourceSize.width: Math.max(parent.width, parent.height) | 43 | sourceSize.width: Math.max(parent.width, parent.height) | ||
43 | 44 | | |||
44 | property bool landscape: width >= height | 45 | property bool landscape: width >= height | ||
45 | 46 | | |||
46 | signal start | 47 | signal start | ||
47 | signal stop | 48 | signal stop | ||
48 | 49 | | |||
49 | Component.onCompleted: { | 50 | Component.onCompleted: { | ||
51 | dialogActivityConfig.initialize() | ||||
50 | activity.start.connect(start) | 52 | activity.start.connect(start) | ||
51 | activity.stop.connect(stop) | 53 | activity.stop.connect(stop) | ||
52 | } | 54 | } | ||
53 | 55 | | |||
54 | // Add here the QML items you need to access in javascript | 56 | // Add here the QML items you need to access in javascript | ||
55 | QtObject { | 57 | QtObject { | ||
56 | id: items | 58 | id: items | ||
57 | property Item main: activity.main | 59 | property Item main: activity.main | ||
58 | property alias background: background | 60 | property alias background: background | ||
59 | property alias bar: bar | 61 | property alias bar: bar | ||
60 | property alias bonus: bonus | 62 | property alias bonus: bonus | ||
61 | property int colorSelector: 0 | 63 | property int colorSelector: 0 | ||
62 | property alias userModel: userModel | 64 | property alias userModel: userModel | ||
63 | property int numberOfColumn | 65 | property int numberOfColumn | ||
64 | property int numberOfColor | 66 | property int numberOfColor | ||
65 | property int numberOfLine: targetModelData.length / numberOfColumn | 67 | property int numberOfLine: targetModelData.length / numberOfColumn | ||
66 | property alias targetModel: targetModel | 68 | property alias targetModel: targetModel | ||
67 | property var targetModelData | 69 | property var targetModelData | ||
70 | property var levels: activity.datasetLoader.data.length !== 0 ? activity.datasetLoader.data : null | ||||
68 | } | 71 | } | ||
69 | 72 | | |||
70 | onStart: { Activity.start(items) } | 73 | onStart: { Activity.start(items) } | ||
71 | onStop: { Activity.stop() } | 74 | onStop: { Activity.stop() } | ||
72 | 75 | | |||
73 | Keys.onPressed: { | 76 | Keys.onPressed: { | ||
74 | if(event.key >= Qt.Key_0 && event.key < Qt.Key_0 + items.numberOfColor) | 77 | if(event.key >= Qt.Key_0 && event.key < Qt.Key_0 + items.numberOfColor) | ||
75 | items.colorSelector = event.key - Qt.Key_0 | 78 | items.colorSelector = event.key - Qt.Key_0 | ||
▲ Show 20 Lines • Show All 335 Lines • ▼ Show 20 Line(s) | 411 | for(var i in touchPoints) { | |||
411 | if(block) { | 414 | if(block) { | ||
412 | block.playEffect(items.colorSelector) | 415 | block.playEffect(items.colorSelector) | ||
413 | block.paint(items.colorSelector) | 416 | block.paint(items.colorSelector) | ||
414 | } | 417 | } | ||
415 | } | 418 | } | ||
416 | } | 419 | } | ||
417 | } | 420 | } | ||
418 | 421 | | |||
422 | | ||||
423 | DialogChooseLevel { | ||||
424 | id: dialogActivityConfig | ||||
425 | currentActivity: activity.activityInfo | ||||
426 | onSaveData: { | ||||
427 | levelFolder = dialogActivityConfig.chosenLevels | ||||
428 | currentActivity.currentLevels = dialogActivityConfig.chosenLevels | ||||
429 | ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels) | ||||
430 | activity.focus = true | ||||
431 | background.stop() | ||||
432 | background.start() | ||||
433 | } | ||||
434 | onLoadData: { | ||||
435 | if(activityData) { | ||||
436 | Activity.initLevel() | ||||
437 | } | ||||
438 | } | ||||
439 | onClose: { | ||||
440 | home() | ||||
441 | } | ||||
442 | onStartActivity: { | ||||
443 | background.start() | ||||
444 | } | ||||
445 | } | ||||
446 | | ||||
419 | DialogHelp { | 447 | DialogHelp { | ||
420 | id: dialogHelp | 448 | id: dialogHelp | ||
421 | onClose: home() | 449 | onClose: home() | ||
422 | } | 450 | } | ||
423 | 451 | | |||
424 | Bar { | 452 | Bar { | ||
425 | id: bar | 453 | id: bar | ||
426 | content: BarEnumContent { value: help | home | level } | 454 | content: BarEnumContent { value: help | home | level | activityConfig} | ||
427 | onHelpClicked: { | 455 | onHelpClicked: { | ||
428 | displayDialog(dialogHelp) | 456 | displayDialog(dialogHelp) | ||
429 | } | 457 | } | ||
430 | onPreviousLevelClicked: Activity.previousLevel() | 458 | onPreviousLevelClicked: Activity.previousLevel() | ||
431 | onNextLevelClicked: Activity.nextLevel() | 459 | onNextLevelClicked: Activity.nextLevel() | ||
432 | onHomeClicked: activity.home() | 460 | onHomeClicked: activity.home() | ||
461 | onActivityConfigClicked: { | ||||
462 | displayDialog(dialogActivityConfig) | ||||
463 | } | ||||
433 | } | 464 | } | ||
434 | 465 | | |||
435 | Bonus { | 466 | Bonus { | ||
436 | id: bonus | 467 | id: bonus | ||
437 | Component.onCompleted: win.connect(Activity.nextLevel) | 468 | Component.onCompleted: win.connect(Activity.nextLevel) | ||
438 | } | 469 | } | ||
439 | } | 470 | } | ||
440 | } | 471 | } |