Warning, /education/gcompris/src/activities/tens_complement_use/Tens_complement_use.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - tens_complement_use.qml 0002 * 0003 * SPDX-FileCopyrightText: 2022 Samarth Raj <mailforsamarth@gmail.com> 0004 * SPDX-FileCopyrightText: 2022 Timothée Giet <animtim@gmail.com> 0005 * SPDX-License-Identifier: GPL-3.0-or-later 0006 */ 0007 import QtQuick 2.12 0008 import QtQml.Models 2.12 0009 import QtQuick.Controls 2.12 0010 import GCompris 1.0 0011 import "../../core" 0012 import "tens_complement_use.js" as Activity 0013 import "qrc:/gcompris/src/core/core.js" as Core 0014 0015 ActivityBase { 0016 id: activity 0017 0018 onStart: focus = true 0019 onStop: {} 0020 0021 pageComponent: Image { 0022 id: background 0023 source: "qrc:/gcompris/src/activities/chess/resource/background-wood.svg" 0024 anchors.fill: parent 0025 fillMode: Image.PreserveAspectCrop 0026 sourceSize.height: height 0027 signal start 0028 signal stop 0029 0030 property int layoutMargins: 10 * ApplicationInfo.ratio 0031 0032 Component.onCompleted: { 0033 activity.start.connect(start) 0034 activity.stop.connect(stop) 0035 } 0036 0037 // Add here the QML items you need to access in javascript 0038 QtObject { 0039 id: items 0040 property Item main: activity.main 0041 property alias background: background 0042 property GCSfx audioEffects: activity.audioEffects 0043 property int currentLevel: activity.currentLevel 0044 property alias bonus: bonus 0045 property alias cardListModel: cardListModel 0046 property alias holderListModel: holderListModel 0047 property int selectedIndex: -1 0048 property alias score: score 0049 property alias okButton: okButton 0050 readonly property var levels: activity.datasetLoader.data 0051 property double cardSize: Core.fitItems(numberContainerArea.width, numberContainerArea.height, 6) 0052 property bool isHorizontal: background.width >= background.height 0053 property bool buttonsBlocked: false 0054 } 0055 0056 onStart: { Activity.start(items) } 0057 onStop: { Activity.stop() } 0058 0059 Item { 0060 id: layoutArea 0061 anchors.top: parent.top 0062 anchors.bottom: bar.top 0063 anchors.bottomMargin: bar.height * 0.2 0064 anchors.left: parent.left 0065 anchors.right: parent.right 0066 } 0067 0068 ListModel { 0069 id: cardListModel 0070 } 0071 0072 Item { 0073 id: numberContainerArea 0074 height: width * 0.67 0075 width: (layoutArea.width - background.layoutMargins * 3) * 0.32 0076 anchors.left: layoutArea.left 0077 anchors.verticalCenter: answerHolderArea.verticalCenter 0078 anchors.leftMargin: background.layoutMargins 0079 } 0080 0081 Rectangle { 0082 id: numberContainer 0083 width: items.cardSize * 3 0084 height: items.cardSize * Math.ceil(cardListModel.count / 3) 0085 anchors.verticalCenter: numberContainerArea.verticalCenter 0086 anchors.left: numberContainerArea.left 0087 color: "#80FFFFFF" 0088 radius: 15 0089 0090 GridView { 0091 id: container 0092 height: parent.height 0093 width: parent.width 0094 interactive: false 0095 anchors.centerIn: parent 0096 cellHeight: items.cardSize 0097 cellWidth: items.cardSize 0098 model: cardListModel 0099 delegate: NumberQuestionCard { 0100 height: items.cardSize 0101 width: items.cardSize 0102 selected: index == items.selectedIndex 0103 onClicked: { 0104 items.selectedIndex = index; 0105 } 0106 } 0107 } 0108 } 0109 0110 ListModel { 0111 id: holderListModel 0112 } 0113 0114 Item { 0115 id: answerHolderArea 0116 anchors { 0117 left: numberContainer.right 0118 top: layoutArea.top 0119 bottom: score.top 0120 right: score.left 0121 } 0122 0123 ListView { 0124 height: Math.min((items.cardSize * holderListModel.count + background.layoutMargins) * 2 , answerHolderArea.height) 0125 width: parent.width 0126 interactive: false 0127 anchors.centerIn: parent 0128 model: holderListModel 0129 delegate: ContainerBox { 0130 height: Math.min((items.cardSize + background.layoutMargins) * 2, answerHolderArea.height / 2) 0131 width: Math.min(height * 5, ListView.view.width) 0132 } 0133 } 0134 } 0135 0136 BarButton { 0137 id: okButton 0138 visible: false 0139 z: 10 0140 source: "qrc:/gcompris/src/core/resource/bar_ok.svg" 0141 anchors { 0142 bottom: score.top 0143 bottomMargin: background.layoutMargins 0144 horizontalCenter: score.horizontalCenter 0145 } 0146 sourceSize.width: 60 * ApplicationInfo.ratio 0147 enabled: !bonus.isPlaying 0148 onClicked: Activity.checkAnswer() 0149 } 0150 0151 Score { 0152 id: score 0153 anchors { 0154 right: layoutArea.right 0155 bottom: layoutArea.bottom 0156 rightMargin: background.layoutMargins 0157 bottomMargin: background.layoutMargins 0158 } 0159 onStop: Activity.nextSubLevel() 0160 } 0161 0162 states: [ 0163 State { 0164 name: "horizontalLayout" 0165 when: items.isHorizontal 0166 AnchorChanges { 0167 target: numberContainerArea 0168 anchors { 0169 left: parent.left 0170 verticalCenter: answerHolderArea.verticalCenter 0171 horizontalCenter: undefined 0172 bottom: undefined 0173 } 0174 } 0175 PropertyChanges { 0176 target: numberContainerArea 0177 anchors { 0178 leftMargin: background.layoutMargins 0179 bottomMargin: 0 0180 } 0181 height: width * 0.67 0182 width: (layoutArea.width - background.layoutMargins * 3) * 0.32 0183 } 0184 AnchorChanges { 0185 target: numberContainer 0186 anchors { 0187 verticalCenter: numberContainerArea.verticalCenter 0188 left: numberContainerArea.left 0189 horizontalCenter: undefined 0190 } 0191 } 0192 AnchorChanges { 0193 target: answerHolderArea 0194 anchors { 0195 left: numberContainer.right 0196 top: parent.top 0197 bottom: score.top 0198 right: score.left 0199 } 0200 } 0201 }, 0202 State { 0203 name: "verticalLayout" 0204 when: !items.isHorizontal 0205 AnchorChanges { 0206 target: numberContainerArea 0207 anchors { 0208 left: undefined 0209 verticalCenter: undefined 0210 horizontalCenter: layoutArea.horizontalCenter 0211 bottom: score.top 0212 } 0213 } 0214 PropertyChanges { 0215 target: numberContainerArea 0216 anchors { 0217 leftMargin: 0 0218 bottomMargin: background.layoutMargins 0219 } 0220 width: Math.min(layoutArea.width - score.width * 2 - background.layoutMargins * 4, 0221 layoutArea.height * 0.35) 0222 height: width * 0.67 0223 } 0224 AnchorChanges { 0225 target: numberContainer 0226 anchors { 0227 verticalCenter: numberContainerArea.verticalCenter 0228 left: undefined 0229 horizontalCenter: numberContainerArea.horizontalCenter 0230 } 0231 } 0232 AnchorChanges { 0233 target: answerHolderArea 0234 anchors { 0235 left: layoutArea.left 0236 top: parent.top 0237 bottom: numberContainerArea.top 0238 right: layoutArea.right 0239 } 0240 } 0241 } 0242 ] 0243 0244 MouseArea { 0245 id: clickMask 0246 anchors.fill: layoutArea 0247 enabled: items.buttonsBlocked 0248 } 0249 0250 DialogChooseLevel { 0251 id: dialogActivityConfig 0252 currentActivity: activity.activityInfo 0253 0254 onSaveData: { 0255 levelFolder = dialogActivityConfig.chosenLevels 0256 currentActivity.currentLevels = dialogActivityConfig.chosenLevels 0257 ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels) 0258 // restart activity on saving 0259 background.start() 0260 } 0261 onClose: { 0262 home() 0263 } 0264 onStartActivity: { 0265 background.start() 0266 } 0267 } 0268 0269 DialogHelp { 0270 id: dialogHelp 0271 onClose: home() 0272 } 0273 0274 Bar { 0275 id: bar 0276 level: items.currentLevel + 1 0277 content: BarEnumContent { value: help | home | level | activityConfig } 0278 onHelpClicked: { 0279 displayDialog(dialogHelp) 0280 } 0281 onPreviousLevelClicked: Activity.previousLevel() 0282 onNextLevelClicked: Activity.nextLevel() 0283 onActivityConfigClicked: { 0284 displayDialog(dialogActivityConfig) 0285 } 0286 onHomeClicked: activity.home() 0287 } 0288 0289 Bonus { 0290 id: bonus 0291 Component.onCompleted: win.connect(Activity.nextLevel) 0292 } 0293 } 0294 0295 }