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

learn_digits, add option to disable voices

parent 7ee65dd5
......@@ -27,6 +27,8 @@ Item {
id: activityConfiguration
property Item background
property alias modeBox: modeBox
property alias enableVoicesBox: enableVoicesBox
property bool voicesEnabled: enableVoicesBox.checked
width: if(background) background.width
property var availableModes: [
{ "text": qsTr("Arabic numerals"), "value": 1 },
......@@ -42,14 +44,26 @@ Item {
background: activityConfiguration.background
label: qsTr("Digits representation")
}
GCDialogCheckBox {
id: enableVoicesBox
text: qsTr("Enable voices")
checked: voicesEnabled
}
}
property var dataToSave
function setDefaultValues() {
// Recreate the binding
enableVoicesBox.checked = Qt.binding(function(){return activityConfiguration.voicesEnabled;});
if(dataToSave["mode"] === undefined) {
dataToSave["mode"] = 1;
modeBox.currentIndex = 0
modeBox.currentIndex = 0;
}
if(dataToSave["voicesEnabled"] === undefined) {
dataToSave["voicesEnabled"] = "true";
enableVoicesBox.checked = true;
}
for(var i = 0 ; i < availableModes.length ; i ++) {
if(availableModes[i].value == dataToSave["mode"]) {
......@@ -57,11 +71,13 @@ Item {
break;
}
}
voicesEnabled = (dataToSave.voicesEnabled === "true")
}
function saveValues() {
var newMode = availableModes[modeBox.currentIndex].value;
dataToSave = {"mode": newMode};
voicesEnabled = enableVoicesBox.checked
dataToSave = {"mode": newMode, "voicesEnabled": "" + voicesEnabled};
}
}
......@@ -75,6 +75,7 @@ ActivityBase {
property bool inputLocked: false
property var levels: activity.datasetLoader.data
property int mode: 1 // default is arabic numerals
property bool voicesEnabled: true
property string imageSource: "qrc:/gcompris/src/core/resource/empty.svg"
}
property string locale: ApplicationSettings.locale
......@@ -88,7 +89,7 @@ ActivityBase {
function itemsVisible() {
iAmReady.visible = false;
if(DownloadManager.areVoicesRegistered() && !operationMode) {
if(DownloadManager.areVoicesRegistered() && !operationMode && items.voicesEnabled) {
repeatItem.visible = true;
}
if(items.mode === 1) {
......@@ -434,6 +435,9 @@ ActivityBase {
if(activityData && activityData["mode"]) {
items.mode = activityData["mode"];
}
if(activityData && activityData["voicesEnabled"]) {
items.voicesEnabled = activityData["voicesEnabled"] === "true" ? true : false;
}
}
onSaveData: {
levelFolder = dialogActivityConfig.chosenLevels
......@@ -442,7 +446,7 @@ ActivityBase {
}
onStartActivity: {
background.stop();
background.start()
background.start();
}
onClose: home()
......
......@@ -34,7 +34,7 @@ var url = ""
function start(items_, operationMode_) {
items = items_;
operationMode = operationMode_;
if(!operationMode)
if(!operationMode && items.voicesEnabled)
Core.checkForVoices(items_.main);
numberOfLevel = items.levels.length;
currentLevel = 0;
......@@ -108,7 +108,8 @@ function initQuestion() {
} else {
items.question = questionsArray[questionIndex];
items.questionText = items.question.toString()
playLetter(items.questionText);
if(items.voicesEnabled)
playLetter(items.questionText);
}
if(items.mode != 1) {
items.imageSource = url + items.questionText + ".svg"
......@@ -174,7 +175,7 @@ function processKey(event) {
items.circlesLine.itemAt(items.selectedCircle).clickCircle();
} else if(event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
checkAnswer();
} else if(event.key === Qt.Key_Tab && !operationMode) {
} else if(event.key === Qt.Key_Tab && !operationMode && items.voicesEnabled) {
playLetter(items.question.toString());
}
}
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