Commit bdf3ed35 authored by Timothée Giet's avatar Timothée Giet

learn_digits, add option to select digits representation

parent a6619a5c
/* GCompris - ActivityConfig.qml
*
* Copyright (C) 2020 Timothée Giet <animtim@gmail.com>
*
* Authors:
* Timothée Giet <animtim@gmail.com>
*
* 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 <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.6
import GCompris 1.0
import "../../core"
Item {
id: activityConfiguration
property Item background
property alias modeBox: modeBox
width: if(background) background.width
property var availableModes: [
{ "text": qsTr("Arabic numerals"), "value": 1 },
{ "text": qsTr("Dots"), "value": 2 },
{ "text": qsTr("Fingers"), "value": 3 }
]
Column {
spacing: 10 * ApplicationInfo.ratio
width: parent.width
GCComboBox {
id: modeBox
model: availableModes
background: activityConfiguration.background
label: qsTr("Digits representation")
}
}
property var dataToSave
function setDefaultValues() {
if(dataToSave["mode"] === undefined) {
dataToSave["mode"] = 1;
modeBox.currentIndex = 0
}
for(var i = 0 ; i < availableModes.length ; i ++) {
if(availableModes[i].value == dataToSave["mode"]) {
modeBox.currentIndex = i;
break;
}
}
}
function saveValues() {
var newMode = availableModes[modeBox.currentIndex].value;
dataToSave = {"mode": newMode};
}
}
......@@ -72,12 +72,15 @@ ActivityBase {
property int selectedCircle: -1
property bool inputLocked: false
property var levels: activity.datasetLoader.data
property int mode: 1 // default is arabic digits
property string imageSource: "qrc:/gcompris/src/core/resource/empty.svg"
}
property string locale: ApplicationSettings.locale
property bool isHorizontal: layoutArea.width >= layoutArea.height
onStart: {
Activity.start(items)
itemsHidden();
Activity.start(items);
}
onStop: { Activity.stop() }
......@@ -86,7 +89,11 @@ ActivityBase {
if(DownloadManager.areVoicesRegistered()) {
repeatItem.visible = true;
}
questionText.visible = true;
if(items.mode === 1) {
questionText.visible = true;
} else {
questionImage.visible = true;
}
scoreArea.visible = true;
circlesBackground.visible = true;
circlesArea.visible = true;
......@@ -94,6 +101,16 @@ ActivityBase {
items.inputLocked = false;
}
function itemsHidden() {
iAmReady.visible = true;
repeatItem.visible = false;
questionText.visible = false;
questionImage.visible = false;
scoreArea.visible = false;
circlesBackground.visible = false;
circlesArea.visible = false;
}
ReadyButton {
id: iAmReady
onClicked: background.itemsVisible();
......@@ -154,6 +171,17 @@ ActivityBase {
style: Text.Outline
styleColor: "white"
}
Image {
id: questionImage
visible: false
anchors.centerIn: textArea
height: Math.min(textArea.height, textArea.width)
width: height
sourceSize.width: height
sourceSize.height: height
fillMode: Image.PreserveAspectFit
source: items.imageSource
}
Item {
id: scoreArea
width: textArea.width
......@@ -400,6 +428,11 @@ ActivityBase {
DialogChooseLevel {
id: dialogActivityConfig
currentActivity: activity.activityInfo
onLoadData: {
if(activityData && activityData["mode"]) {
items.mode = activityData["mode"];
}
}
onSaveData: {
levelFolder = dialogActivityConfig.chosenLevels
currentActivity.currentLevels = dialogActivityConfig.chosenLevels
......
......@@ -28,6 +28,7 @@ var numberOfLevel;
var items;
var questionsLeft;
var questionsArray;
var url = ""
function start(items_) {
Core.checkForVoices(items_.main);
......@@ -52,6 +53,12 @@ function initLevel() {
items.circlesModel = items.levels[currentLevel].circlesModel;
items.currentSubLevel = 0;
items.nbSubLevel = questionsArray.length;
if(items.mode === 2)
url = "qrc:/gcompris/src/activities/learn_digits/resource/dots-";
else if(items.mode === 3)
url = "qrc:/gcompris/src/activities/learn_digits/resource/hands-";
else
url = "";
if(!items.iAmReady.visible)
initQuestion();
if(items.selectedCircle >= 0)
......@@ -86,7 +93,11 @@ function initQuestion() {
items.answer = 0;
var questionIndex = Math.floor(Math.random() * Math.floor(questionsLeft.length - 1));
items.question = questionsLeft[questionIndex];
playLetter(items.question.toString());
var questionString = items.question.toString()
if(items.mode != 1) {
items.imageSource = url + questionString + ".svg"
}
playLetter(questionString);
}
function resetCircles() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment