Warning, /education/gcompris/src/activities/ordering_numbers/Ordering.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - Ordering.qml
0002  *
0003  * SPDX-FileCopyrightText: 2021 Harsh Kumar <hadron43@yahoo.com>
0004  *
0005  * Authors:
0006  *   Harsh Kumar <hadron43@yahoo.com>
0007  *   Emmanuel Charruau <echarruau@gmail.com>
0008  *   Timothée Giet <animtim@gmail.com>
0009  *
0010  *   SPDX-License-Identifier: GPL-3.0-or-later
0011  */
0012 import QtQuick 2.12
0013 import GCompris 1.0
0014 
0015 import "../../core"
0016 import "ordering.js" as Activity
0017 
0018 ActivityBase {
0019     id: activity
0020 
0021     // Mode : numbers | alphabets | sentences | chronology
0022     property string mode
0023 
0024     onStart: focus = true
0025     onStop: {}
0026 
0027     pageComponent: Image {
0028         id: background
0029         anchors.fill: parent
0030         fillMode: Image.PreserveAspectCrop
0031         sourceSize.width: width
0032         sourceSize.height: height
0033         source: "qrc:/gcompris/src/activities/braille_fun/resource/hillside.svg"
0034         signal start
0035         signal stop
0036 
0037         Component.onCompleted: {
0038             dialogActivityConfig.initialize()
0039             activity.start.connect(start)
0040             activity.stop.connect(stop)
0041         }
0042 
0043         // Add here the QML items you need to access in javascript
0044         QtObject {
0045             id: items
0046             property Item main: activity.main
0047             readonly property string resourceUrl: activity.resourceUrl
0048             readonly property var levels: activity.datasetLoader.data
0049             property alias background: background
0050             property alias originListModel: originListModel
0051             property alias targetListModel: targetListModel
0052             property int currentLevel: activity.currentLevel
0053             property alias bonus: bonus
0054             property alias instruction: instruction
0055             property alias targetPlaceholder: targetPlaceholder
0056         }
0057 
0058         onStart: { Activity.start(items, mode) }
0059         onStop: { Activity.stop() }
0060 
0061         GCText {
0062             id: instruction
0063             z: 5
0064             wrapMode: TextEdit.WordWrap
0065             fontSize: tinySize
0066             horizontalAlignment: Text.Center
0067             width: parent.width * 0.9
0068             color: 'white'
0069             anchors.centerIn: instructionArea
0070         }
0071 
0072         Rectangle {
0073             id: instructionArea
0074             opacity: 1
0075             radius: 10
0076             color: "#373737"
0077             width: instruction.contentWidth * 1.1
0078             height: instruction.contentHeight * 1.1
0079             anchors.horizontalCenter: parent.horizontalCenter
0080             anchors.top: parent.top
0081             anchors.topMargin: 5 * ApplicationInfo.ratio
0082         }
0083 
0084         Item {
0085             id: layoutArea
0086             anchors.top: instructionArea.bottom
0087             anchors.topMargin: 10 * ApplicationInfo.ratio
0088             anchors.bottom: bar.top
0089             anchors.bottomMargin: bar.height * 0.2
0090             anchors.left: parent.left
0091             anchors.right: parent.right
0092         }
0093 
0094         ListModel {
0095             id: originListModel
0096         }
0097 
0098         ListModel {
0099             id: targetListModel
0100         }
0101 
0102         OrderingPlaceholder {
0103             id: targetPlaceholder
0104 
0105             anchors.top: layoutArea.top
0106             height: (layoutArea.height - 10 * ApplicationInfo.ratio) / 2
0107             mode: activity.mode
0108             placeholderName: "target"
0109             highestParent: background
0110 
0111             placeholderListModel: targetListModel
0112 
0113             elementKey: "targetKey"
0114             targetPlaceholderKey: "originKey"
0115         }
0116 
0117         OrderingPlaceholder {
0118             id: originPlaceholder
0119 
0120             anchors.top: targetPlaceholder.bottom
0121             anchors.topMargin: 5 * ApplicationInfo.ratio
0122             height: targetPlaceholder.height
0123             mode: activity.mode
0124             placeholderName: "origin"
0125             highestParent: background
0126 
0127             placeholderListModel: originListModel
0128 
0129             elementKey: "originKey"
0130             targetPlaceholderKey: "targetKey"
0131         }
0132 
0133         DialogChooseLevel {
0134             id: dialogActivityConfig
0135             currentActivity: activity.activityInfo
0136 
0137             onSaveData: {
0138                 levelFolder = dialogActivityConfig.chosenLevels
0139                 currentActivity.currentLevels = dialogActivityConfig.chosenLevels
0140                 ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels)
0141                 // restart activity on saving
0142                 background.start()
0143             }
0144             onClose: {
0145                 home()
0146             }
0147             onStartActivity: {
0148                 background.start()
0149             }
0150         }
0151 
0152         DialogHelp {
0153             id: dialogHelp
0154             onClose: home()
0155         }
0156 
0157         BarButton {
0158             id: ok
0159             source: "qrc:/gcompris/src/core/resource/bar_ok.svg";
0160             sourceSize.width: 70 * ApplicationInfo.ratio
0161             enabled: !bonus.isPlaying && (originListModel.count === 0)
0162             visible: originListModel.count === 0
0163             anchors.horizontalCenter: originPlaceholder.horizontalCenter
0164             anchors.verticalCenter: originPlaceholder.verticalCenter
0165             onClicked: Activity.checkOrder()
0166         }
0167 
0168         Bar {
0169             id: bar
0170             level: items.currentLevel + 1
0171             content: BarEnumContent { value: help | home | level | activityConfig }
0172             onHelpClicked: {
0173                 displayDialog(dialogHelp)
0174             }
0175             onPreviousLevelClicked: Activity.previousLevel()
0176             onNextLevelClicked: Activity.nextLevel()
0177             onHomeClicked: activity.home()
0178             onActivityConfigClicked: {
0179                 displayDialog(dialogActivityConfig)
0180             }
0181         }
0182 
0183         Bonus {
0184             id: bonus
0185             Component.onCompleted: win.connect(Activity.nextLevel)
0186         }
0187     }
0188 
0189 }