Warning, /education/gcompris/src/activities/tens_complement_use/ContainerBox.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - ContainerBox.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 "../../core" 0009 import "tens_complement_use.js" as Activity 0010 0011 Item { 0012 id: cardContainer 0013 readonly property string correctAnswerImage: "qrc:/gcompris/src/core/resource/apply.svg" 0014 readonly property string wrongAnswerImage: "qrc:/gcompris/src/core/resource/cancel.svg" 0015 0016 // add 1 for numbers and 0.5 for sign symbols 0017 function numberOfItemsInModel(modelToCheck) { 0018 var numberOfItems = 0; 0019 if(modelToCheck) { 0020 for (var i = 0; i < modelToCheck.count; i++) { 0021 if (modelToCheck.get(i).isSignSymbol) { 0022 numberOfItems += 0.5; 0023 } else { 0024 numberOfItems += 1; 0025 } 0026 } 0027 return numberOfItems; 0028 } else { 0029 return 1; 0030 } 0031 } 0032 0033 Rectangle { 0034 id: containerBg 0035 color: "#33FFFFFF" 0036 radius: 15 0037 anchors { 0038 left: parent.left 0039 right: parent.right 0040 top: parent.top 0041 bottom: parent.bottom 0042 margins: background.layoutMargins 0043 } 0044 } 0045 0046 Rectangle { 0047 id: questionContainer 0048 height: containerBg.height * 0.5 0049 width: containerBg.width * 0.6 0050 color: "#C8D6EF" 0051 anchors { 0052 top: containerBg.top 0053 horizontalCenter: containerBg.horizontalCenter 0054 } 0055 radius: 15 0056 property int cardWidth: questionContainer.width / numberOfItemsInModel(addition) 0057 0058 0059 ListView { 0060 height: parent.height 0061 width: parent.width 0062 interactive: false 0063 anchors.centerIn: parent 0064 orientation: ListView.Horizontal 0065 model: addition 0066 delegate: NumberQuestionCard { 0067 height: questionContainer.height 0068 width: isSignSymbol ? questionContainer.cardWidth * 0.5 : questionContainer.cardWidth 0069 } 0070 } 0071 } 0072 0073 Rectangle { 0074 id: answerContainer 0075 height: containerBg.height * 0.5 0076 width: containerBg.width 0077 color: "#EBEBEB" 0078 anchors { 0079 top: questionContainer.bottom 0080 left: containerBg.left 0081 } 0082 radius: 15 0083 property int cardWidth: questionContainer.width / numberOfItemsInModel(secondRow) 0084 0085 ListView { 0086 height: parent.height 0087 width: parent.width 0088 interactive: false 0089 anchors.centerIn: parent 0090 orientation: ListView.Horizontal 0091 model: secondRow 0092 delegate: NumberQuestionCard { 0093 height: answerContainer.height 0094 width: isSignSymbol ? questionContainer.cardWidth * 0.5 : questionContainer.cardWidth 0095 onClicked: { 0096 if(value != "?") { 0097 Activity.reappearNumberCard(value); 0098 value = "?"; 0099 tickVisibility = false; 0100 } 0101 value = Activity.getEnteredCard(); 0102 Activity.showOkButton(); 0103 } 0104 } 0105 } 0106 } 0107 0108 Image { 0109 visible: tickVisibility 0110 sourceSize.height: answerContainer.height 0111 source: isGood === true ? correctAnswerImage : wrongAnswerImage 0112 anchors { 0113 left: questionContainer.right 0114 bottom: answerContainer.top 0115 } 0116 } 0117 }