diff --git a/src/activities/numeration_weights_integer/Numeration_weights_integer.qml b/src/activities/numeration_weights_integer/Numeration_weights_integer.qml index d71705a9d..bdfa86231 100644 --- a/src/activities/numeration_weights_integer/Numeration_weights_integer.qml +++ b/src/activities/numeration_weights_integer/Numeration_weights_integer.qml @@ -1,665 +1,666 @@ /* GCompris - Share.qml * * Copyright (C) 2019 Emmanuel Charruau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ // TODO: ne valider que si les poids sont dans la bonne case // TODO: ajouter des niveaux pour pouvoir le faire tester par un élève // TODO: fix error when removing a class dragging it // TODO: give new number only when bonus is finished // TODO: remove cellsize // TODO: is it possible to have a vertical mode? If not remove everything related to vertical mode // TODO: remove settings in bar menu import QtQuick 2.13 import GCompris 1.0 import QtQuick.Layouts 1.3 import QtQuick.Controls 1.5 import QtQml.Models 2.1 import "../../core" import "numeration_weights_integer.js" as Activity ActivityBase { id: activity onStart: focus = true onStop: {} pageComponent: Rectangle { id: background anchors.fill: parent color: "#ffffb3" signal start signal stop Component.onCompleted: { dialogActivityConfig.getInitialConfiguration() activity.start.connect(start) activity.stop.connect(stop) } // Add here the QML items you need to access in javascript QtObject { id: items property Item main: activity.main property alias background: background property alias mainZoneArea: mainZoneArea property alias bar: bar property alias bonus: bonus property alias instruction: instruction property alias warningRectangle: warningRectangle property alias dataset: dataset property alias numberClassListModel: numberClassListModel property alias numberClassDragListModel: numberClassDragListModel property alias numberWeightDragListModel: numberWeightDragListModel property alias numberClassTypeModel: numberClassTypeModel property alias leftWidget: leftWidget property alias progressBar: progressBar property alias numberClassDropAreaRepeater: numberClassDropAreaRepeater property alias classNameListView: classNameListView property int barHeightAddon: ApplicationSettings.isBarHidden ? 1 : 3 property int cellSize: Math.min(background.width / 11, background.height / (9 + barHeightAddon)) property var levels: activity.datasetLoader.item.data property alias numberToConvertRectangle: numberToConvertRectangle property alias tutorialSection: tutorialSection + property alias okButton: okButton } Loader { id: dataset asynchronous: false } onStart: { Activity.start(items) } onStop: { Activity.stop() } property bool vert: background.width >= background.height //mainZone DropArea { id: mainZoneArea width: background.vert ? background.width - leftWidget.width - 40 : background.width - 40 height: ApplicationSettings.isBarHidden ? background.height : background.vert ? background.height - (bar.height * 1.1) : background.height - (bar.height * 1.1) - leftWidget.height anchors { top: background.vert ? background.top : leftWidget.bottom left: background.vert ? leftWidget.right : parent.left leftMargin: 20 } keys: "NumberClassKey" //shows/hides the objective/instruction MouseArea { anchors.fill: mainZoneArea onClicked: instruction.show() } Rectangle { id: mainZoneAreaDropRectangleVisualisation anchors.fill: parent color: "pink" } onDropped: { var className = drag.source.name drag.source.dragEnabled = false Activity.appendClassNameColumn(className, drag.source, false) } Rectangle { id: topBanner height: mainZoneArea.height / 10 width: mainZoneArea.width anchors { left: mainZoneArea.left top: mainZoneArea.top } color: "green" Rectangle { id: numberToConvertRectangle anchors.fill: numberToConvertRectangleTxt color: "blue" opacity: 0.8 property alias text: numberToConvertRectangleTxt.text } //display number to convert GCText { id: numberToConvertRectangleTxt height: parent.height width: parent.width / 3 anchors { left: numberToConvertRectangle.left top: numberToConvertRectangle.top } opacity: numberToConvertRectangle.opacity //z: instruction.z fontSize: background.vert ? regularSize : smallSize color: "white" style: Text.Outline styleColor: "black" horizontalAlignment: Text.AlignHCenter wrapMode: TextEdit.WordWrap } ProgressBar { id: progressBar height: parent.height width: parent.width / 3 property int percentage: 0 maximumValue: 100 visible: true //!items.isTutorialMode anchors { bottom: parent.bottom right: parent.right rightMargin: 40 } GCText { anchors.centerIn: parent fontSize: mediumSize font.bold: true color: "black" //: The following translation represents percentage. text: qsTr("%1%").arg(parent.value) z: 2 } } } //store strings Integer and Decimal to display in numeration table header ListModel { id: numberClassTypeModel } Rectangle { id: numberClassTypeHeader width: mainZoneArea.width height: mainZoneArea.height / 20 anchors.top: topBanner.bottom anchors.left: parent.left anchors.right: parent.right border.color: "blue" border.width: 1 ListView { id: numberClassTypeHeaderListView anchors { fill: parent} model: numberClassTypeModel orientation: ListView.Horizontal delegate: Rectangle { width: numberClassTypeModel.get(index).numberClassTypeHeaderWidth height: numberClassTypeHeader.height border.width: 1 border.color: "black" color: "lightsteelblue" radius: 2 GCText { id: numberClassHeaderCaption anchors.fill: parent anchors.bottom: parent.bottom fontSizeMode: Text.Fit color: "black" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: numberClassTypeModel.get(index).numberClassType visible: numberClassTypeModel.get(index).numberClassTypeHeaderWidth === 0 ? false : true } } } } Rectangle { id: numberClassHeaders width: mainZoneArea.width height: mainZoneArea.height / 10 anchors.top: numberClassTypeHeader.bottom anchors.left: parent.left anchors.right: parent.right border.color: "red" border.width: 1 GCText { id: numberClassHeadersRectangleAdvice height: parent.height width: parent.width anchors { horizontalCenter: parent.horizontalCenter verticalCenter: parent.verticalCenter } opacity: visualModel.count === 0 ? 1 : 0 fontSizeMode: Text.Fit color: "black" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: qsTr("Drag here the class numbers") } ListView { id: classNameListView anchors { fill: parent} model: visualModel orientation: ListView.Horizontal interactive: false cacheBuffer: 50 } DelegateModel { id: visualModel model: numberClassListModel delegate: nnumberClassHeaderElement //Qt.createComponent("NumberClassHeaderElement.qml") //ask johnny for some help there } } Component { // ? what to do when removed element ? TypeError: Cannot read property 'misplaced' of undefined id: nnumberClassHeaderElement MouseArea { id: dragArea property bool held: false width: mainZoneArea.width / numberClassListModel.count height: numberClassHeaders.height drag.target: held ? content : undefined drag.axis: Drag.XAxis onPressed: held = true onReleased: { if ((content.x < leftWidget.width) && held) //? don't understand why I have a content.x = 0 when held is not true, this point needs to be cleared { console.log("index className element",index) numberClassListModel.get(index).element_src.dragEnabled = true numberClassListModel.remove(index,1) Activity.updateIntegerAndDecimalHeaderWidth() } held = false } Rectangle { id: content anchors { horizontalCenter: parent.horizontalCenter verticalCenter: parent.verticalCenter } width: mainZoneArea.width / numberClassListModel.count height: numberClassHeaders.height / 1.5 border.width: numberClassListModel.get(index).misplaced === true ? 5 : 1 //FIXME: when removing an element of NumberClassList model border color is stilll asked border.color: numberClassListModel.get(index).misplaced === true ? "red" : "lightsteelblue" color: dragArea.held ? "lightsteelblue" : "white" Behavior on color { ColorAnimation { duration: 100 } } radius: 2 Drag.active: dragArea.held Drag.source: dragArea Drag.hotSpot.x: width / 2 Drag.hotSpot.y: height / 2 states: State { when: dragArea.held ParentChange { target: content; parent: root } AnchorChanges { target: content anchors { horizontalCenter: undefined; verticalCenter: undefined } } } GCText { id: numberClassHeaderCaption anchors.fill: parent anchors.bottom: parent.bottom fontSizeMode: Text.Fit color: "black" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: numberClassListModel.get(index).name //here there a problem when removing a number class z: 100 } } DropArea { anchors { fill: parent; margins: 10 } onEntered: { console.log("dragArea.DelegateModel.itemsIndex",dragArea.DelegateModel.itemsIndex) console.log("classNameListView.count",classNameListView.count) //move class name columns except the decimal part which stays always on the last position if (dragArea.DelegateModel.itemsIndex < classNameListView.count - 1) { numberClassListModel.move(drag.source.DelegateModel.itemsIndex, dragArea.DelegateModel.itemsIndex,1) } } } } } RowLayout { id: numberClassDropAreasGridLayout property alias numberClassDropAreaRepeater: numberClassDropAreaRepeater anchors.top: numberClassHeaders.bottom width: parent.width height: parent.height - topBanner.height - numberClassHeaders.height - numberClassTypeHeader.height spacing: 10 Repeater { id: numberClassDropAreaRepeater model: numberClassListModel NumberClassDropArea { id: numberClassDropAreaElement //property alias numberWeightDragListModel: activity.background.numberWeightDragListModel //? className: name //name comes from numberClassListModel Layout.fillHeight: true Layout.fillWidth: true Layout.minimumWidth: 50 Layout.preferredWidth: 100 } } } Tutorial { id: tutorialSection tutorialText.anchors.top: undefined tutorialText.anchors.bottom: tutorialSection.bottom tutorialText.anchors.margins: tutorialSection.tutorialText.height tutorialDetails: Activity.tutorialInstructions useImage: false onSkipPressed: { Activity.initLevel() - tutorialImage.visible = false + tutorialImage.visible = false //? } } } ListModel { id: numberClassListModel } ListModel { id: numberClassDragListModel } ListModel { id: numberWeightDragListModel } //instruction rectangle Rectangle { id: instruction anchors.fill: instructionTxt opacity: 0.8 radius: 10 border.width: 2 z: 10 border.color: "black" gradient: Gradient { GradientStop { position: 0.0; color: "#000" } GradientStop { position: 0.9; color: "#666" } GradientStop { position: 1.0; color: "#AAA" } } property alias text: instructionTxt.text Behavior on opacity { PropertyAnimation { duration: 200 } } //shows/hides the Instruction MouseArea { anchors.fill: parent onClicked: instruction.hide() enabled: instruction.opacity !== 0 } function show() { if(text) opacity = 0.8 } function hide() { opacity = 0 } } //display level objective GCText { id: instructionTxt anchors { - top: background.vert ? parent.top : leftWidget.bottom + top: background.vert ? parent.top : leftWidget.bottom //? topMargin: -10 horizontalCenter: background.horizontalCenter } opacity: instruction.opacity z: instruction.z fontSize: background.vert ? regularSize : smallSize color: "white" style: Text.Outline styleColor: "black" horizontalAlignment: Text.AlignHCenter width: Math.max(Math.min(parent.width * 0.8, text.length * 8), parent.width * 0.3) wrapMode: TextEdit.WordWrap } //display level objective GCText { id: warningTxt anchors { horizontalCenter: background.horizontalCenter verticalCenter: background.verticalCenter } opacity: warningRectangle.opacity z: warningRectangle.z + 1 fontSize: regularSize color: "white" style: Text.Outline styleColor: "black" horizontalAlignment: Text.AlignHCenter width: Math.max(Math.min(parent.width * 0.8, text.length * 8), parent.width * 0.3) wrapMode: TextEdit.WordWrap } Rectangle { id: warningRectangle anchors.fill: warningTxt opacity: 0 radius: 10 border.width: 2 z: 10 border.color: "black" gradient: Gradient { GradientStop { position: 0.0; color: "#000" } GradientStop { position: 0.9; color: "#666" } GradientStop { position: 1.0; color: "#AAA" } } property alias text: warningTxt.text Behavior on opacity { PropertyAnimation { duration: 200 } } //shows/hides the Instruction MouseArea { anchors.fill: parent onClicked: warningRectangle.hide() enabled: warningRectangle.opacity !== 0 } function show() { if(text) opacity = 0.8 } function hide() { opacity = 0 } } //dragable weights list (leftwidget) Rectangle { id: leftWidget width: background.vert ? items.cellSize * 1.74 : background.width height: background.vert ? background.height : items.cellSize * 1.74 color: "#FFFF42" border.color: "#FFD85F" border.width: 4 z: 4 //grid with ok button and the different draggable number weights Flickable { id: flickableElement anchors.fill: parent width: background.height height: leftWidget.width //contentHeight: gridView.height contentHeight: gridView.height * 1.8 //? contentWidth: leftWidget.width boundsBehavior: Flickable.DragAndOvershootBounds Grid { id: gridView x: 10 y: 10 width: parent.width height: background.height //width: background.vert ? leftWidget.width : 3 * bar.height // height: background.vert ? background.height - 2 * bar.height : bar.height spacing: 10 columns: background.vert ? 1 : 5 //ok button Image { id: okButton source:"qrc:/gcompris/src/core/resource/bar_ok.svg" sourceSize.width: items.cellSize * 1.5 fillMode: Image.PreserveAspectFit MouseArea { id: mouseArea anchors.fill: parent enabled: background.finished ? false : true onPressed: okButton.opacity = 0.6 onReleased: okButton.opacity = 1 onClicked: { Activity.checkAnswer() } } } // numbers classes drag elements Repeater { id: numberClassDragElements model: numberClassDragListModel NumberClassDragElement { id: classDragElement name: model.name color: model.color Drag.keys: model.dragkeys } } // numbers columns weights and numbers weigths drag elements Repeater { id: numberWeightDragElements model: numberWeightDragListModel NumberWeightDragElement { id: weightComponentDragElement name: model.name imageName: model.imageName Drag.keys: model.dragkeys weightValue: model.weightValue caption: model.caption color: model.color selected: model.selected } } } } } //bar buttons DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar content: BarEnumContent { value: help | home | level | reload | config} onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() onReloadClicked: Activity.reloadRandom() //? onConfigClicked: { dialogActivityConfig.active = true displayDialog(dialogActivityConfig) } } Bonus { id: bonus } } } diff --git a/src/activities/numeration_weights_integer/numeration_weights_integer.js b/src/activities/numeration_weights_integer/numeration_weights_integer.js index 403eb0a60..85b8a9ae5 100644 --- a/src/activities/numeration_weights_integer/numeration_weights_integer.js +++ b/src/activities/numeration_weights_integer/numeration_weights_integer.js @@ -1,597 +1,598 @@ /* GCompris - numeration.js * * Copyright (C) 2019 Emmanuel Charruau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ .pragma library .import QtQuick 2.6 as Quick var currentLevel = 0 var numberOfLevel = 0 //? var items var numbersToConvert = [] var originalNumbersToConvert = [] var numbersCorrectlyAnswered = [] var scorePercentage = 0 var scorePourcentageStep = 0 var wrongAnswerAlreadyGiven = false var selectedNumberWeightDragElementIndex = -1 var numberHasADecimalPart = false var fullClassNamesConstantArray = ["Decimal Part","Unit class","Thousand class","Million class","Milliard class"] var classNamesUsedArray var numberClassesObj = { "Decimal Part": { name: qsTr("Decimal Part"), color: "black", dragkeys: "NumberClassKey"}, "Unit class": { name: qsTr("Unit class"), color: "black", dragkeys: "NumberClassKey"}, "Thousand class": { name: qsTr("Thousand class"), color: "black", dragkeys: "NumberClassKey"}, "Million class": { name: qsTr("Million class"), color: "black", dragkeys: "NumberClassKey"}, "Milliard class": { name: qsTr("Milliard class"), color: "black", dragkeys: "NumberClassKey"} } var numberWeightsColumnsArray = ["HundredColumn","TenColumn","UnitColumn"] var numberWeightComponentConstantArray = ["UnitColumn","TenColumn","HundredColumn","Unit","Ten","Hundred","Thousand","TenThousand", "OneHundredThousand","OneMillion","TenMillion","OneHundredMillion", "OneMilliard","TenMilliard","OneHundredMilliard"] var numberWeightDragArray = { "UnitColumn": { name: qsTr("Unit"), caption: "Unit", imageName: "", weightValue: "1", dragkeys: "numberWeightHeaderKey", color: "lightskyblue", selected: false }, "TenColumn": { name: qsTr("Ten"), caption: "Ten", imageName: "", weightValue: "10", dragkeys: "numberWeightHeaderKey", color: "lightskyblue", selected: false }, "HundredColumn": { name: qsTr("Hundred"), caption: "Hundred", imageName: "", weightValue: "100", dragkeys: "numberWeightHeaderKey", color: "lightskyblue", selected: false }, "Unit": { name: qsTr("Unit"), caption: "", imageName: "unit.svg", weightValue: "1", dragkeys: "numberWeightKey", color: "transparent", selected: false }, "Ten": { name: qsTr("Unit"), caption: "", imageName: "ten.svg", weightValue: "10", dragkeys: "numberWeightKey", color: "transparent", selected: false }, "Hundred": { name: qsTr("Unit"), caption: "", imageName: "hundred.svg", weightValue: "100", dragkeys: "numberWeightKey", color: "transparent", selected: false }, "Thousand": { name: qsTr("Unit"), caption: "1000", imageName: "weightCaption.svg", weightValue: "1000", dragkeys: "numberWeightKey", color: "transparent", selected: false }, "TenThousand": { name: qsTr("Unit"), caption: "10 000", imageName: "weightCaption.svg", weightValue: "10000", dragkeys: "numberWeightKey", color: "transparent", selected: false }, "OneHundredThousand": { name: qsTr("Unit"), caption: "100 000", imageName: "weightCaption.svg", weightValue: "100000", dragkeys: "numberWeightKey", color: "transparent", selected: false }, "OneMillion": { name: qsTr("Unit"), caption: "1 000 000", imageName: "weightCaption.svg", weightValue: "1000000", dragkeys: "numberWeightKey", color: "transparent", selected: false }, "TenMillion": { name: qsTr("Unit"), caption: "10 000 000", imageName: "weightCaption.svg", weightValue: "10000000", dragkeys: "numberWeightKey", color: "transparent", selected: false }, "OneHundredMillion": { name: qsTr("Unit"), caption: "100 000 000", imageName: "weightCaption.svg", weightValue: "100000000", dragkeys: "numberWeightKey", color: "transparent" , selected: false }, "OneMilliard": { name: qsTr("Unit"), caption: "1 000 000 000", imageName: "weightCaption.svg", weightValue: "1000000000", dragkeys: "numberWeightKey", color: "transparent" , selected: false }, "TenMilliard": { name: qsTr("Unit"), caption: "10 000 000 000", imageName: "weightCaption.svg", weightValue: "10000000000", dragkeys: "numberWeightKey", color: "transparent" , selected: false }, "OneHundredMilliard": { name: qsTr("Unit"), caption: "100 000 000 000", imageName: "weightCaption.svg", weightValue: "100000000000", dragkeys: "numberWeightKey", color: "transparent" , selected: false } } // for what is used name in numberWeightDragArray ? //? var numberClassTypeColumnsArray = ["Integer Part","Decimal Part"] var tutorialInstructions = [ { "instruction": qsTr("This activity teaches how to place numbers weights to represent a number quantity.") }, { - "instruction": qsTr("Before to enter any number weights you have to enter the number classes (unit class only if numbers are less than 1000 and unit classes and thousand class if they are more than 999."), + "instruction": qsTr("Here we will represent the quantity 1204."), "instructionQml": "qrc:/gcompris/src/activities/numeration_weights_integer/resource/tutorial0.qml" }, { - "instruction": qsTr("Here using drag and drop we add the unit class and the thousand class."), + "instruction": qsTr("Using drag and drop we add the unit class and the thousand class."), "instructionQml": "qrc:/gcompris/src/activities/numeration_weights_integer/resource/tutorial1.qml" }, { - "instruction": qsTr("The we have to enter the weight name in the rights columns.") - }, - { - "instruction": qsTr("Here using drag and drop we add the weight unit in the unit column."), + "instruction": qsTr("We add the different weights in the corresponding columns."), "instructionQml": "qrc:/gcompris/src/activities/numeration_weights_integer/resource/tutorial2.qml" }, { - "instruction": qsTr("To convert a decimal 5 to a binary value, 1 and 4 are added."), + "instruction": qsTr("Then we place the needed weights in the right columns to obtain in this example 1204."), "instructionQml": "qrc:/gcompris/src/activities/numeration_weights_integer/resource/tutorial3.qml" }, { - "instruction": qsTr("Their corresponding bits are set to 1, the others set to 0. Decimal 5 is equal to binary 101."), + "instruction": qsTr("Once the weights are enter, we click on the ok button."), "instructionQml": "qrc:/gcompris/src/activities/numeration_weights_integer/resource/tutorial4.qml" - }, - { - "instruction": qsTr("This image will help you to compute bits' value."), - "instructionQml": "qrc:/gcompris/src/activities/numeration_weights_integer/resource/tutorial5.qml" } ] function removeClassInNumberClassesArray(className) { console.log(numberClassesArray) var index = numberClassesArray.indexOf(className); if (index > -1) { numberClassesArray.splice(index, 1); } console.log(numberClassesArray) } function removeClassInNumberClassesArray() { numberClassesArray.pop(numberClass) } function setNumberWeightHeader(numberWeightImageTile,imageName,caption,weightValue) { if ( imageName !== "") { numberWeightImageTile.source = "qrc:/gcompris/src/activities/numeration_weights_integer/resource/images/" + imageName } numberWeightImageTile.caption = caption numberWeightImageTile.weightValue = weightValue } function setNumberWeightComponent(numberWeightImageTile,imageName,caption,weightValue) { if ( imageName !== "") { numberWeightImageTile.source = "qrc:/gcompris/src/activities/numeration_weights_integer/resource/images/" + imageName numberWeightImageTile.caption = caption numberWeightImageTile.weightValue = weightValue } } function removeNumberWeightComponent(numberWeightImageTile) { numberWeightImageTile.source = "" numberWeightImageTile.caption = "" numberWeightImageTile.weightValue = "" numberWeightImageTile.border.color = "black" } function resetNumerationTable() { for (var i = 0; i=0; i--,classNamesUsedIndex++) { if (items.numberClassListModel.get(i).name === classNamesUsedArray[classNamesUsedIndex]) { items.numberClassListModel.setProperty(i, "misplaced", false) } else { items.numberClassListModel.setProperty(i, "misplaced", true) allClassesColumnsInRightPositions = false } } return allClassesColumnsInRightPositions } function expectedAndEnteredValuesAreEquals() { var enteredValue = readNumerationTableEnteredValue() console.log("enteredValue/expected value:",enteredValue + " / " + parseInt(numbersToConvert[0],10)) //test if entered value is equal to number expected if (enteredValue === parseInt(numbersToConvert[0],10)) { return true } else { return false } } function checkEnteredValue() { var _expectedAndEnteredValuesAreEquals = expectedAndEnteredValuesAreEquals() if (_expectedAndEnteredValuesAreEquals) { return true } else { return false } } function evaluateAndDisplayProgresses(correctAnswer) { if (correctAnswer) { wrongAnswerAlreadyGiven = false items.bonus.good("flower") console.log("correct: scorePercentage before incrementation",scorePercentage) numbersCorrectlyAnswered.push(numbersToConvert.shift()) //remove first element and copy it in numbersCorrectlyAnswered scorePercentage = scorePercentage + scorePourcentageStep console.log("correct: scorePercentage after incrementation",scorePercentage) items.progressBar.value = scorePercentage if (scorePercentage > 97) { return true } items.numberToConvertRectangle.text = numbersToConvert[0] console.log("original NumbersToConvert: " + originalNumbersToConvert) console.log("NumbersToConvert: " + numbersToConvert) console.log("numbersCorrectlyAnswered: " + numbersCorrectlyAnswered) return } else { items.bonus.bad("flower") items.numberToConvertRectangle.text = numbersToConvert[0] console.log("incorrect: scorePercentage before incrementation",scorePercentage) console.log("wrongAnswerAlreadyGiven: ", wrongAnswerAlreadyGiven) if (wrongAnswerAlreadyGiven === false) { scorePercentage = scorePercentage - scorePourcentageStep if (scorePercentage < 0) scorePercentage = 0 items.progressBar.value = scorePercentage if (numbersToConvert.length < 2) { numbersToConvert.splice(2, 0, numbersCorrectlyAnswered[Math.floor(Math.random() * numbersCorrectlyAnswered.length)]) } console.log("number to convert before splice: ",numbersToConvert) numbersToConvert.splice(2, 0, numbersToConvert[0]); console.log("number to convert after splice: ",numbersToConvert) wrongAnswerAlreadyGiven = true console.log("incorrect: scorePercentage after incrementation",scorePercentage) } console.log("NumbersToConvert length: " + numbersToConvert.length) console.log("original NumbersToConvert: " + originalNumbersToConvert) console.log("NumbersToConvert: " + numbersToConvert) console.log("numbersCorrectlyAnswered: " + numbersCorrectlyAnswered) return false } } function start(items_) { items = items_ currentLevel = 0 setNumberWeightDragListModel(numberWeightComponentConstantArray) initLevel() numberOfLevel = items.levels.length // ? } function setNumberClassTypeListModel() { items.numberClassTypeModel.append({"numberClassType": "Integer Part", "numberClassTypeHeaderWidth": 0}) if (hasNumberADecimalPart()) { addDecimalHeaderToNumberClassTypeModel() } } function setClassNamesUsedArray(fullClassNamesArray) { var smallerNumberClass = items.levels[currentLevel].smallerNumberClass var biggerNumberClass = items.levels[currentLevel].biggerNumberClass if (!isClassNamePresentInfullClassNamesArray(fullClassNamesArray, smallerNumberClass)) { return fullClassNamesConstantArray } if (!isClassNamePresentInfullClassNamesArray(fullClassNamesArray, biggerNumberClass)) { return fullClassNamesConstantArray } return fullClassNamesArray.slice(fullClassNamesArray.indexOf(smallerNumberClass),fullClassNamesArray.indexOf(biggerNumberClass)+1) } function isClassNamePresentInfullClassNamesArray(fullClassNamesArray, className) { if (fullClassNamesArray.indexOf(className) !== -1) { return true } else { items.warningRectangle.text = qsTr("The class name \"" + className + "\" is not present in the available list: \"" + fullClassNamesArray+ "\". Check your configuration file (lower case or uppercase error?).") items.warningRectangle.show() return false } } function hasNumberADecimalPart() { for (var i=0; i * * Authors: * Timothée Giet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.13 import GCompris 1.0 import "../../../core" import "../../../activities" import "../numeration_weights_integer.js" as Activity Item { id: tutorial0 Component.onCompleted: { console.log("tutorial0_screen_loaded") //this is not a good solution, it does not work if tutorial0 is called before initLevel() is finished //? - console.log("yyyyyyyyyyyyyyyyyyyy") Activity.numbersToConvert.unshift(1204) Activity.items.numberToConvertRectangle.text = Activity.numbersToConvert[0] console.log(Activity.numbersToConvert) } } diff --git a/src/activities/numeration_weights_integer/resource/tutorial1.qml b/src/activities/numeration_weights_integer/resource/tutorial1.qml index 623f7119a..940ecc59d 100644 --- a/src/activities/numeration_weights_integer/resource/tutorial1.qml +++ b/src/activities/numeration_weights_integer/resource/tutorial1.qml @@ -1,115 +1,89 @@ /* GCompris - tutorial1.qml * * Copyright (C) 2018 Timothée Giet * * Authors: * Timothée Giet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.13 import GCompris 1.0 import "../../../core" import "../../../activities" Item { id: tutorial1 property bool animationIsRunning: animationIsRunning - property int unitClassDragButtonOrigX - property int unitClassDragButtonOrigY - property int thousandClassDragButtonOrigX - property int thousandClassDragButtonOrigY + property int numberClassDragButtonOrigX + property int numberClassDragButtonOrigY + property int numberClassDragButtonIndex + property int animationSequenceIndex + + readonly property int animation_DURATION: 3000 Component.onCompleted: { console.log("tutorial1_screen_loaded") - animUnitClassX.running = true - animUnitClassY.running = true + numberClassParallelAnimation.running = true + numberClassDragButtonIndex = 0 } + ParallelAnimation { + id: numberClassParallelAnimation - NumberAnimation{ - id: animUnitClassX + NumberAnimation { + id: animUnitColumnWeightX - target: numberClassDragElements.itemAt(0) - property: "x"; - to: background.width * 2/3 - duration: 300 //0 - onStarted: { - unitClassDragButtonOrigX = numberClassDragElements.itemAt(0).x - unitClassDragButtonOrigY = numberClassDragElements.itemAt(0).y - animationIsRunning = true - numberClassDragElements.itemAt(0).animationIsRunning = animationIsRunning - console.log("onStarted") + target: numberClassDragElements.itemAt(numberClassDragButtonIndex) + property: "x"; + to: background.width * (2-animationSequenceIndex)/3 + duration: animation_DURATION } - onFinished: { - numberClassDragElements.itemAt(0).Drag.drop() - console.log("Sent Drag drop") - animationIsRunning = false - numberClassDragElements.itemAt(0).x = unitClassDragButtonOrigX - numberClassDragElements.itemAt(0).z = 1000 - animThousandClassX.running = true - animThousandClassY.running = true - } - } - NumberAnimation{ - id: animUnitClassY + NumberAnimation { + id: animUnitColumnWeightY - target: numberClassDragElements.itemAt(0) - property: "y"; - to: background.height * 1/3 - duration: 300 //0 - onFinished: { - numberClassDragElements.itemAt(0).y = unitClassDragButtonOrigY + target: numberClassDragElements.itemAt(numberClassDragButtonIndex) + property: "y"; + to: background.height * 1/3 + duration: animation_DURATION } - } - - NumberAnimation{ - id: animThousandClassX - target: numberClassDragElements.itemAt(1) - property: "x"; - to: background.width * 1/3 - duration: 300 //0 onStarted: { - thousandClassDragButtonOrigX = numberClassDragElements.itemAt(1).x - thousandClassDragButtonOrigY = numberClassDragElements.itemAt(1).y + numberClassDragButtonOrigX = numberClassDragElements.itemAt(numberClassDragButtonIndex).x + numberClassDragButtonOrigY = numberClassDragElements.itemAt(numberClassDragButtonIndex).y + numberClassDragElements.itemAt(numberClassDragButtonIndex).Drag.start() animationIsRunning = true - numberClassDragElements.itemAt(1).animationIsRunning = animationIsRunning - console.log("onStarted") - } - onFinished: { - numberClassDragElements.itemAt(1).Drag.drop() - console.log("Sent Drag drop") - animationIsRunning = false - numberClassDragElements.itemAt(1).x = thousandClassDragButtonOrigX - numberClassDragElements.itemAt(1).z = 1000 + numberClassDragElements.itemAt(numberClassDragButtonIndex).animationIsRunning = animationIsRunning } - } - - NumberAnimation{ - id: animThousandClassY - target: numberClassDragElements.itemAt(1) - property: "y"; - to: background.height * 1/3 - duration: 300 //0 onFinished: { - numberClassDragElements.itemAt(1).y = thousandClassDragButtonOrigY + numberClassDragElements.itemAt(numberClassDragButtonIndex).Drag.drop() + numberClassDragElements.itemAt(numberClassDragButtonIndex).z = 1000 + if (animationSequenceIndex === 0) { + numberClassDragElements.itemAt(numberClassDragButtonIndex).x = numberClassDragButtonOrigX + numberClassDragElements.itemAt(numberClassDragButtonIndex).y = numberClassDragButtonOrigY + animationSequenceIndex++ + numberClassDragButtonIndex = 1 + numberClassParallelAnimation.running = true + } else if (animationSequenceIndex === 1) { + numberClassDragElements.itemAt(numberClassDragButtonIndex).x = numberClassDragButtonOrigX + numberClassDragElements.itemAt(numberClassDragButtonIndex).y = numberClassDragButtonOrigY + } } } } diff --git a/src/activities/numeration_weights_integer/resource/tutorial2.qml b/src/activities/numeration_weights_integer/resource/tutorial2.qml index 764789ec4..99cb52944 100644 --- a/src/activities/numeration_weights_integer/resource/tutorial2.qml +++ b/src/activities/numeration_weights_integer/resource/tutorial2.qml @@ -1,129 +1,131 @@ /* GCompris - tutorial2.qml * * Copyright (C) 2019 Emmanuel Charruau * * Authors: * Emmanuel Charruau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.13 import GCompris 1.0 import "../../../core" import "../../../activities" Item { id: tutorial2 property bool animationIsRunning: animationIsRunning property int weightColumnDragButtonOrigX property int weightColumnDragButtonOrigY property int animationSequenceIndex property int numberClassIndex property int numberColumnWeightIndex property int numberColumnWeightDragButtonIndex + readonly property int animation_DURATION: 300//0 + Component.onCompleted: { console.log("tutorial2_screen_loaded") animationSequenceIndex = 0 numberClassIndex = 0 numberColumnWeightIndex = 2 numberColumnWeightDragButtonIndex = 0 numberWeightsParallelAnimation.running = true } ParallelAnimation { id: numberWeightsParallelAnimation NumberAnimation { id: animUnitColumnWeightX target: numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex) property: "x"; to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).mapToItem(activity, 0, 0).x - duration: 300 //0 + duration: animation_DURATION } NumberAnimation { id: animUnitColumnWeightY target: numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex) property: "y"; to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).numberWeightHeaderElement.mapToItem(activity, 0, 0).y //to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).numberWeightsDropTiles.numberWeightDropAreaGridRepeater.itemAt(3).mapToItem(activity, 0, 0).y - duration: 300 //0 + duration: animation_DURATION } onStarted: { weightColumnDragButtonOrigX = numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x weightColumnDragButtonOrigY = numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).Drag.start() animationIsRunning = true numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).animationIsRunning = animationIsRunning } onFinished: { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).Drag.drop() numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).z = 1000 if (animationSequenceIndex === 0) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = weightColumnDragButtonOrigY animationSequenceIndex = 1 numberClassIndex = 0 numberColumnWeightIndex = 1 numberColumnWeightDragButtonIndex = 1 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 1) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = weightColumnDragButtonOrigY animationSequenceIndex = 2 numberClassIndex = 0 numberColumnWeightIndex = 0 numberColumnWeightDragButtonIndex = 2 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 2) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = weightColumnDragButtonOrigY animationSequenceIndex = 3 numberClassIndex = 1 numberColumnWeightIndex = 2 numberColumnWeightDragButtonIndex = 0 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 3) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = weightColumnDragButtonOrigY animationSequenceIndex = 4 numberClassIndex = 1 numberColumnWeightIndex = 1 numberColumnWeightDragButtonIndex = 1 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 4) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = weightColumnDragButtonOrigY animationSequenceIndex = 5 numberClassIndex = 1 numberColumnWeightIndex = 0 numberColumnWeightDragButtonIndex = 2 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 5) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = weightColumnDragButtonOrigY } } } } diff --git a/src/activities/numeration_weights_integer/resource/tutorial3.qml b/src/activities/numeration_weights_integer/resource/tutorial3.qml index 9816e15a5..628875313 100644 --- a/src/activities/numeration_weights_integer/resource/tutorial3.qml +++ b/src/activities/numeration_weights_integer/resource/tutorial3.qml @@ -1,137 +1,158 @@ /* GCompris - tutorial3.qml * * Copyright (C) 2019 Emmanuel Charruau * * Authors: * Emmanuel Charruau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.13 import GCompris 1.0 import "../../../core" import "../../../activities" Item { id: tutorial2 property bool animationIsRunning: animationIsRunning property int weightColumnDragButtonOrigX property int weightColumnDragButtonOrigY property int animationSequenceIndex property int numberClassIndex property int numberColumnWeightIndex - //unit weight = 3, ten weight = 4, hunderd weight = 5 etc... //whange cariable in tutorial2.qml //? property int dragButtonIndex - property int weightIndex + property int weightRowIndex + readonly property int unit_CLASS_INDEX: 1 + readonly property int thousand_CLASS_INDEX: 0 + readonly property int unit_COLUMN_INDEX: 2 + readonly property int tenth_COLUMN_INDEX: 1 + readonly property int hundred_COLUMN_INDEX: 0 + + + readonly property int unit_WEIGHT_BUTTON_INDEX: 3 + readonly property int ten_WEIGHT_BUTTON_INDEX: 4 + readonly property int hundred_WEIGHT_BUTTON_INDEX: 5 + readonly property int thousand_WEIGHT_BUTTON_INDEX: 6 + + readonly property int animation_DURATION: 300//0 Component.onCompleted: { - console.log("tutorial2_screen_loaded") + console.log("tutorial3_screen_loaded") animationSequenceIndex = 0 numberClassIndex = 1 numberColumnWeightIndex = 2 - dragButtonIndex = 3 + dragButtonIndex = unit_WEIGHT_BUTTON_INDEX numberWeightsParallelAnimation.running = true - weightIndex = 0 + weightRowIndex = 0 } ParallelAnimation { id: numberWeightsParallelAnimation NumberAnimation { id: animUnitColumnWeightX target: numberWeightDragElements.itemAt(dragButtonIndex) property: "x"; - to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).numberWeightsDropTiles.numberWeightDropAreaGridRepeater.itemAt(weightIndex).mapToItem(activity, 0, 0).x - duration: 3000 + to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).numberWeightsDropTiles.numberWeightDropAreaGridRepeater.itemAt(weightRowIndex).mapToItem(activity, 0, 0).x + duration: animation_DURATION } NumberAnimation { id: animUnitColumnWeightY target: numberWeightDragElements.itemAt(dragButtonIndex) property: "y"; - to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).numberWeightsDropTiles.numberWeightDropAreaGridRepeater.itemAt(weightIndex).mapToItem(activity, 0, 0).y - duration: 3000 + to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).numberWeightsDropTiles.numberWeightDropAreaGridRepeater.itemAt(weightRowIndex).mapToItem(activity, 0, 0).y + duration: animation_DURATION } onStarted: { weightColumnDragButtonOrigX = numberWeightDragElements.itemAt(dragButtonIndex).x weightColumnDragButtonOrigY = numberWeightDragElements.itemAt(dragButtonIndex).y numberWeightDragElements.itemAt(dragButtonIndex).Drag.start() animationIsRunning = true numberWeightDragElements.itemAt(dragButtonIndex).animationIsRunning = animationIsRunning } onFinished: { numberWeightDragElements.itemAt(dragButtonIndex).Drag.drop() - numberWeightDragElements.itemAt(dragButtonIndex).x = weightColumnDragButtonOrigX + numberWeightDragElements.itemAt(dragButtonIndex).x = weightColumnDragButtonOrigX //? numberWeightDragElements.itemAt(dragButtonIndex).z = 1000 if (animationSequenceIndex === 0) { numberWeightDragElements.itemAt(dragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(dragButtonIndex).y = weightColumnDragButtonOrigY - animationSequenceIndex = 1 - numberClassIndex = 1 + animationSequenceIndex++ + numberClassIndex = unit_CLASS_INDEX numberColumnWeightIndex = 2 - dragButtonIndex = 3 - weightIndex = 1 + dragButtonIndex = unit_WEIGHT_BUTTON_INDEX + weightRowIndex = 1 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 1) { numberWeightDragElements.itemAt(dragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(dragButtonIndex).y = weightColumnDragButtonOrigY - animationSequenceIndex = 2 - numberClassIndex = 1 - numberColumnWeightIndex = 2 - dragButtonIndex = 3 - weightIndex = 2 + animationSequenceIndex++ + numberClassIndex = unit_CLASS_INDEX + numberColumnWeightIndex = unit_COLUMN_INDEX + dragButtonIndex = unit_WEIGHT_BUTTON_INDEX + weightRowIndex = 2 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 2) { numberWeightDragElements.itemAt(dragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(dragButtonIndex).y = weightColumnDragButtonOrigY - animationSequenceIndex = 3 - numberClassIndex = 1 - numberColumnWeightIndex = 2 - dragButtonIndex = 3 - weightIndex = 3 + animationSequenceIndex++ + numberClassIndex = unit_CLASS_INDEX + numberColumnWeightIndex = unit_COLUMN_INDEX + dragButtonIndex = unit_WEIGHT_BUTTON_INDEX + weightRowIndex = 3 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 3) { numberWeightDragElements.itemAt(dragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(dragButtonIndex).y = weightColumnDragButtonOrigY - animationSequenceIndex = 4 - numberClassIndex = 1 - numberColumnWeightIndex = 2 - dragButtonIndex = 3 - weightIndex = 3 + animationSequenceIndex++ + numberClassIndex = unit_CLASS_INDEX + numberColumnWeightIndex = hundred_COLUMN_INDEX + dragButtonIndex = hundred_WEIGHT_BUTTON_INDEX + weightRowIndex = 0 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 4) { numberWeightDragElements.itemAt(dragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(dragButtonIndex).y = weightColumnDragButtonOrigY - animationSequenceIndex = 5 - numberClassIndex = 0 - numberColumnWeightIndex = 0 - dragButtonIndex = 3 + animationSequenceIndex++ + numberClassIndex = unit_CLASS_INDEX + numberColumnWeightIndex = hundred_COLUMN_INDEX + dragButtonIndex = hundred_WEIGHT_BUTTON_INDEX + weightRowIndex = 1 numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 5) { numberWeightDragElements.itemAt(dragButtonIndex).x = weightColumnDragButtonOrigX numberWeightDragElements.itemAt(dragButtonIndex).y = weightColumnDragButtonOrigY + animationSequenceIndex++ + numberClassIndex = thousand_CLASS_INDEX + numberColumnWeightIndex = unit_COLUMN_INDEX + dragButtonIndex = thousand_WEIGHT_BUTTON_INDEX + numberWeightsParallelAnimation.running = true + } else if (animationSequenceIndex === 6) { + numberWeightDragElements.itemAt(dragButtonIndex).x = weightColumnDragButtonOrigX + numberWeightDragElements.itemAt(dragButtonIndex).y = weightColumnDragButtonOrigY } } } } diff --git a/src/activities/numeration_weights_integer/resource/tutorial4.qml b/src/activities/numeration_weights_integer/resource/tutorial4.qml index 669c00177..a48f93c2d 100644 --- a/src/activities/numeration_weights_integer/resource/tutorial4.qml +++ b/src/activities/numeration_weights_integer/resource/tutorial4.qml @@ -1,142 +1,54 @@ /* GCompris - tutorial4.qml * - * Copyright (C) 2018 Timothée Giet + * Copyright (C) 2019 Emmanuel Charruau * * Authors: - * Timothée Giet + * Emmanuel Charruau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ -import QtQuick 2.6 -import GCompris 1.0 +import QtQuick 2.13 +import GCompris 1.0 import "../../../core" +import "../../../activities" -Rectangle { - anchors.fill: parent - color: "#80FFFFFF" - - Item { - id: topBlock - width: parent.width - height: parent.height * 0.2 - - GCText { - anchors { - right: parent.right - verticalCenter: parent.verticalCenter - } - text: qsTr("0 to 255 with") - fontSizeMode: Text.Fit - minimumPixelSize: 15 - color: "black" - horizontalAlignment: Text.AlignHCenter - width: 0.9 * parent.width - height: 0.9 * parent.height - wrapMode: Text.WordWrap - z: 2 - } - } - - Row { - id: tableBlock1 - width: parent.width * 0.9 - height: parent.height * 0.2 - anchors.top: topBlock.bottom - anchors.left: parent.left - anchors.leftMargin: parent.width * 0.05 - Repeater { - model: ["", "", "", "", "", "", "", ""] - Item { - id: item128 - width: parent.width / 8 - height: parent.height - anchors.verticalCenter: parent.verticalCenter - GCText { - anchors { - right: parent.right - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter - } - text: modelData - fontSizeMode: Text.Fit - minimumPixelSize: 15 - color: "black" - horizontalAlignment: Text.AlignHCenter - width: 0.9 * parent.width - height: 0.9 * parent.height - wrapMode: Text.WordWrap - z: 2 - } - } - } - } - - Row { - id: bulbBlock - width: parent.width * 0.9 - height: parent.height * 0.4 - anchors.top: tableBlock1.bottom - anchors.left: parent.left - anchors.leftMargin: parent.width * 0.05 - Repeater { - model: ["off", "off", "off", "off", "off", "off", "off", "off"] - Item { - id: item128 - width: parent.width / 8 - height: parent.height - anchors.verticalCenter: parent.verticalCenter - Image { - source: "bulb_" + modelData + ".svg" - fillMode: Image.PreserveAspectFit - anchors.fill: parent - sourceSize.width: implicitWidth - } - } - } +import "../numeration_weights_integer.js" as Activity + + +Item { + id: tutorial4 + + readonly property int animation_DURATION: 1000 + + Component.onCompleted: { + console.log("tutorial4_screen_loaded") + okButtonAnimation.running = true } - - Row { - width: parent.width * 0.9 - height: parent.height * 0.2 - anchors.top: bulbBlock.bottom - anchors.left: parent.left - anchors.leftMargin: parent.width * 0.05 - Repeater { - model: ["0", "0", "0", "0", "0", "0", "0", "0"] - Item { - id: item128 - width: parent.width / 8 - height: parent.height - anchors.verticalCenter: parent.verticalCenter - GCText { - anchors { - right: parent.right - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter - } - text: modelData - fontSizeMode: Text.Fit - minimumPixelSize: 15 - color: "black" - horizontalAlignment: Text.AlignHCenter - width: 0.9 * parent.width - height: 0.9 * parent.height - wrapMode: Text.WordWrap - z: 2 - } - } + + NumberAnimation { + id: okButtonAnimation + + target: okButton + property: "opacity"; + to: 0.1 + duration: animation_DURATION + + onFinished: { + console.log("test") + okButton.opacity = 1 + Activity.checkAnswer() } } }