Warning, /education/gcompris/src/activities/tens_complement_find/AnswerContainer.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - AnswerContainer.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_find.js" as Activity 0010 0011 Item { 0012 id: answerContainer 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: answerRectangle 0035 color: "#EBEBEB" 0036 radius: 15 0037 anchors { 0038 left: parent.left 0039 right: parent.right 0040 top: parent.top 0041 bottom: parent.bottom 0042 leftMargin: background.layoutMargins 0043 topMargin: background.layoutMargins 0044 bottomMargin: background.layoutMargins 0045 rightMargin: background.layoutMargins + validationImage.height 0046 0047 } 0048 property int cardWidth: answerRectangle.width / numberOfItemsInModel(addition) 0049 0050 0051 ListView { 0052 id: additionList 0053 height: parent.height 0054 width: parent.width 0055 interactive: false 0056 anchors.centerIn: parent 0057 orientation: ListView.Horizontal 0058 model: addition 0059 delegate: NumberQuestionCard { 0060 height: additionList.height 0061 width: isSignSymbol ? answerRectangle.cardWidth * 0.5 : answerRectangle.cardWidth 0062 onClicked: { 0063 if(value != "?") { 0064 Activity.reappearNumberCard(value); 0065 value = "?"; 0066 tickVisibility = false; 0067 } 0068 value = Activity.getEnteredCard(); 0069 Activity.showOkButton(); 0070 } 0071 } 0072 } 0073 } 0074 0075 Image { 0076 id: validationImage 0077 visible: tickVisibility 0078 height: answerRectangle.height 0079 width: height 0080 sourceSize.height: height 0081 source: isCorrect ? correctAnswerImage : wrongAnswerImage 0082 anchors { 0083 left: answerRectangle.right 0084 leftMargin: background.layoutMargins * 0.5 0085 verticalCenter: answerRectangle.verticalCenter 0086 } 0087 } 0088 }