Changeset View
Changeset View
Standalone View
Standalone View
src/activities/calendar/Calendar.qml
Show All 21 Lines | |||||
22 | import QtQuick 2.6 | 22 | import QtQuick 2.6 | ||
23 | import GCompris 1.0 | 23 | import GCompris 1.0 | ||
24 | import QtQuick.Controls 1.5 | 24 | import QtQuick.Controls 1.5 | ||
25 | import QtQuick.Controls.Private 1.0 | 25 | import QtQuick.Controls.Private 1.0 | ||
26 | import QtQuick.Controls.Styles 1.4 | 26 | import QtQuick.Controls.Styles 1.4 | ||
27 | import "../../core" | 27 | import "../../core" | ||
28 | import "calendar.js" as Activity | 28 | import "calendar.js" as Activity | ||
29 | import "calendar_dataset.js" as Dataset | 29 | import "calendar_dataset.js" as Dataset | ||
30 | import "tutorial_instructions.js" as Instructions | ||||
30 | 31 | | |||
31 | ActivityBase { | 32 | ActivityBase { | ||
32 | id: activity | 33 | id: activity | ||
33 | property var dataset: Dataset | 34 | property var dataset: Dataset | ||
34 | onStart: focus = true | 35 | onStart: focus = true | ||
35 | onStop: {} | 36 | onStop: {} | ||
36 | 37 | | |||
38 | property var tutorialInstructions: Instructions.get() | ||||
39 | property bool showTutorial: true | ||||
40 | | ||||
37 | pageComponent: Image { | 41 | pageComponent: Image { | ||
38 | id: background | 42 | id: background | ||
39 | signal start | 43 | signal start | ||
40 | signal stop | 44 | signal stop | ||
41 | fillMode: Image.PreserveAspectCrop | 45 | fillMode: Image.PreserveAspectCrop | ||
42 | source: "qrc:/gcompris/src/activities/fifteen/resource/background.svg" | 46 | source: "qrc:/gcompris/src/activities/fifteen/resource/background.svg" | ||
43 | sourceSize.width: Math.max(parent.width, parent.height) | 47 | sourceSize.width: Math.max(parent.width, parent.height) | ||
44 | 48 | | |||
45 | Component.onCompleted: { | 49 | Component.onCompleted: { | ||
50 | dialogActivityConfig.initialize() | ||||
46 | activity.start.connect(start) | 51 | activity.start.connect(start) | ||
47 | activity.stop.connect(stop) | 52 | activity.stop.connect(stop) | ||
48 | } | 53 | } | ||
49 | 54 | | |||
50 | // Add here the QML items you need to access in javascript | 55 | // Add here the QML items you need to access in javascript | ||
51 | QtObject { | 56 | QtObject { | ||
52 | id: items | 57 | id: items | ||
53 | property Item main: activity.main | 58 | property Item main: activity.main | ||
54 | property alias background: background | 59 | property alias background: background | ||
55 | property alias bar: bar | 60 | property alias bar: bar | ||
56 | property alias bonus: bonus | 61 | property alias bonus: bonus | ||
57 | property alias calendar: calendar | 62 | property alias calendar: calendar | ||
58 | property alias okButton: okButton | 63 | property alias okButton: okButton | ||
59 | property alias questionItem: questionItem | 64 | property alias questionItem: questionItem | ||
65 | property var levels: activity.datasetLoader.item.data | ||||
60 | property alias score: score | 66 | property alias score: score | ||
61 | property alias answerChoices: answerChoices | 67 | property alias answerChoices: answerChoices | ||
62 | property alias questionDelay: questionDelay | 68 | property alias questionDelay: questionDelay | ||
63 | property alias okButtonParticles: okButtonParticles | 69 | property alias okButtonParticles: okButtonParticles | ||
64 | property bool horizontalLayout: background.width >= background.height * 1.5 | 70 | property bool horizontalLayout: background.width >= background.height * 1.5 | ||
65 | property alias daysOfTheWeekModel: daysOfTheWeekModel | 71 | property alias daysOfTheWeekModel: daysOfTheWeekModel | ||
72 | property bool showTutorial: activity.showTutorial | ||||
66 | } | 73 | } | ||
67 | 74 | | |||
68 | onStart: { Activity.start(items, dataset) } | 75 | onStart: { Activity.start(items) } | ||
69 | onStop: { Activity.stop() } | 76 | onStop: { Activity.stop() } | ||
70 | Keys.onPressed: (answerChoices.visible) ? answerChoices.handleKeys(event) : handleKeys(event); | 77 | Keys.onPressed: (answerChoices.visible) ? answerChoices.handleKeys(event) : handleKeys(event); | ||
71 | 78 | | |||
72 | // Question time delay | 79 | // Question time delay | ||
73 | Timer { | 80 | Timer { | ||
74 | id: questionDelay | 81 | id: questionDelay | ||
75 | repeat: false | 82 | repeat: false | ||
76 | interval: 1600 | 83 | interval: 1600 | ||
▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Line(s) | 332 | highlight: Rectangle { | |||
340 | } | 347 | } | ||
341 | } | 348 | } | ||
342 | highlightFollowsCurrentItem: false | 349 | highlightFollowsCurrentItem: false | ||
343 | focus: answerChoices.visible | 350 | focus: answerChoices.visible | ||
344 | } | 351 | } | ||
345 | 352 | | |||
346 | Rectangle { | 353 | Rectangle { | ||
347 | id: questionItemBackground | 354 | id: questionItemBackground | ||
355 | visible: !showTutorial | ||||
348 | color: "#373737" | 356 | color: "#373737" | ||
349 | border.width: 2 | 357 | border.width: 2 | ||
350 | border.color: "#f2f2f2" | 358 | border.color: "#f2f2f2" | ||
351 | radius: 10 | 359 | radius: 10 | ||
352 | opacity: 0.85 | 360 | opacity: 0.85 | ||
353 | z: 10 | 361 | z: 10 | ||
354 | anchors { | 362 | anchors { | ||
355 | horizontalCenter: parent.horizontalCenter | 363 | horizontalCenter: parent.horizontalCenter | ||
356 | bottomMargin: 10 | 364 | bottomMargin: 10 | ||
357 | } | 365 | } | ||
358 | width: parent.width - 20 | 366 | width: parent.width - 20 | ||
359 | height: parent.height * 0.1 | 367 | height: parent.height * 0.1 | ||
360 | } | 368 | } | ||
361 | 369 | | |||
362 | // Displays the question. | 370 | // Displays the question. | ||
363 | GCText { | 371 | GCText { | ||
364 | id: questionItem | 372 | id: questionItem | ||
373 | visible: !showTutorial | ||||
365 | anchors.fill: questionItemBackground | 374 | anchors.fill: questionItemBackground | ||
366 | anchors.bottom: questionItemBackground.bottom | 375 | anchors.bottom: questionItemBackground.bottom | ||
367 | fontSizeMode: Text.Fit | 376 | fontSizeMode: Text.Fit | ||
368 | wrapMode: Text.Wrap | 377 | wrapMode: Text.Wrap | ||
369 | z: 10 | 378 | z: 10 | ||
370 | color: "white" | 379 | color: "white" | ||
371 | verticalAlignment: Text.AlignVCenter | 380 | verticalAlignment: Text.AlignVCenter | ||
372 | horizontalAlignment: Text.AlignHCenter | 381 | horizontalAlignment: Text.AlignHCenter | ||
373 | } | 382 | } | ||
374 | 383 | | |||
384 | //Tutorial section starts | ||||
385 | Loader { | ||||
386 | active: showTutorial | ||||
387 | anchors.fill: parent | ||||
388 | z: 1 | ||||
389 | sourceComponent: tutorialComponent | ||||
390 | Component { | ||||
391 | id: tutorialComponent | ||||
392 | Image { | ||||
393 | id: tutorialImage | ||||
394 | source: "../digital_electricity/resource/texture01.png" | ||||
395 | anchors.fill: parent | ||||
396 | fillMode: Image.Tile | ||||
397 | Tutorial { | ||||
398 | id: tutorialSection | ||||
399 | tutorialDetails: tutorialInstructions | ||||
400 | useImage: false | ||||
401 | onSkipPressed: { | ||||
402 | showTutorial = false | ||||
403 | Activity.initLevel() | ||||
404 | } | ||||
405 | } | ||||
406 | } | ||||
407 | } | ||||
408 | } | ||||
409 | // Tutorial section ends | ||||
410 | | ||||
375 | // Answer Submission button. | 411 | // Answer Submission button. | ||
376 | BarButton { | 412 | BarButton { | ||
377 | id: okButton | 413 | id: okButton | ||
378 | source: "qrc:/gcompris/src/core/resource/bar_ok.svg" | 414 | source: "qrc:/gcompris/src/core/resource/bar_ok.svg" | ||
415 | visible: !showTutorial | ||||
379 | height: bar.height * 0.8 | 416 | height: bar.height * 0.8 | ||
380 | width: okButton.height | 417 | width: okButton.height | ||
381 | sourceSize.width: okButton.width | 418 | sourceSize.width: okButton.width | ||
382 | sourceSize.height: okButton.height | 419 | sourceSize.height: okButton.height | ||
383 | z: 10 | | |||
384 | anchors.top: calendarBox.bottom | 420 | anchors.top: calendarBox.bottom | ||
385 | anchors.right: calendarBox.right | 421 | anchors.right: calendarBox.right | ||
386 | anchors.margins: items.horizontalLayout ? 30 : 6 | 422 | anchors.margins: items.horizontalLayout ? 30 : 6 | ||
387 | ParticleSystemStarLoader { | 423 | ParticleSystemStarLoader { | ||
388 | id: okButtonParticles | 424 | id: okButtonParticles | ||
389 | clip: false | 425 | clip: false | ||
390 | } | 426 | } | ||
391 | MouseArea { | 427 | MouseArea { | ||
392 | id: okButtonMouseArea | 428 | id: okButtonMouseArea | ||
393 | anchors.fill: parent | 429 | anchors.fill: parent | ||
394 | onClicked: { | 430 | onClicked: { | ||
395 | Activity.checkAnswer() | 431 | Activity.checkAnswer() | ||
396 | } | 432 | } | ||
397 | } | 433 | } | ||
398 | } | 434 | } | ||
399 | 435 | | |||
436 | DialogChooseLevel { | ||||
437 | id: dialogActivityConfig | ||||
438 | currentActivity: activity.activityInfo | ||||
439 | | ||||
440 | onSaveData: { | ||||
441 | levelFolder = dialogActivityConfig.chosenLevel | ||||
442 | currentActivity.currentLevel = dialogActivityConfig.chosenLevel | ||||
443 | ApplicationSettings.setCurrentLevel(currentActivity.name, dialogActivityConfig.chosenLevel) | ||||
444 | background.start() | ||||
445 | home() | ||||
446 | } | ||||
447 | onClose: { | ||||
448 | home() | ||||
449 | } | ||||
450 | onStartActivity: { | ||||
451 | background.start() | ||||
452 | } | ||||
453 | } | ||||
454 | | ||||
400 | DialogHelp { | 455 | DialogHelp { | ||
401 | id: dialogHelp | 456 | id: dialogHelp | ||
402 | onClose: home() | 457 | onClose: home() | ||
403 | } | 458 | } | ||
404 | 459 | | |||
405 | Bar { | 460 | Bar { | ||
406 | id: bar | 461 | id: bar | ||
407 | content: BarEnumContent { value: help | home | level } | 462 | content: BarEnumContent { value: help | home | level | activityConfig } | ||
408 | onHelpClicked: { | 463 | onHelpClicked: { | ||
409 | displayDialog(dialogHelp) | 464 | displayDialog(dialogHelp) | ||
410 | } | 465 | } | ||
466 | onActivityConfigClicked: { | ||||
467 | displayDialog(dialogActivityConfig) | ||||
468 | } | ||||
411 | onPreviousLevelClicked: Activity.previousLevel() | 469 | onPreviousLevelClicked: Activity.previousLevel() | ||
412 | onNextLevelClicked: Activity.nextLevel() | 470 | onNextLevelClicked: Activity.nextLevel() | ||
413 | onHomeClicked: activity.home() | 471 | onHomeClicked: activity.home() | ||
414 | } | 472 | } | ||
415 | 473 | | |||
416 | Bonus { | 474 | Bonus { | ||
417 | id: bonus | 475 | id: bonus | ||
418 | Component.onCompleted: win.connect(Activity.nextLevel) | 476 | Component.onCompleted: win.connect(Activity.nextLevel) | ||
419 | } | 477 | } | ||
420 | 478 | | |||
421 | Score { | 479 | Score { | ||
422 | id: score | 480 | id: score | ||
481 | visible: !showTutorial | ||||
423 | height: okButton.height | 482 | height: okButton.height | ||
424 | width: height | 483 | width: height | ||
425 | anchors.top: calendarBox.bottom | 484 | anchors.top: calendarBox.bottom | ||
426 | anchors.bottom: undefined | 485 | anchors.bottom: undefined | ||
427 | anchors.left: undefined | 486 | anchors.left: undefined | ||
428 | anchors.right: answerChoices.visible ? calendarBox.right : okButton.left | 487 | anchors.right: answerChoices.visible ? calendarBox.right : okButton.left | ||
429 | anchors.margins: items.horizontalLayout ? 30 : 8 | 488 | anchors.margins: items.horizontalLayout ? 30 : 8 | ||
430 | } | 489 | } | ||
431 | } | 490 | } | ||
432 | } | 491 | } | ||
433 | 492 | | |||
434 | 493 | |