diff --git a/src/activities/gletters/ActivityConfig.qml b/src/activities/gletters/ActivityConfig.qml index 2b3619bf3..0ce55fc94 100644 --- a/src/activities/gletters/ActivityConfig.qml +++ b/src/activities/gletters/ActivityConfig.qml @@ -1,120 +1,126 @@ /* GCompris - ActivityConfig.qml * * Copyright (C) 2019 Akshay Kumar * * Authors: * Akshay Kumar * * 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 "../../core" Item { id: activityConfiguration property Item background property alias localeBox: localeBox property alias uppercaseBox: uppercaseBox property alias speedSlider: speedSlider property int speedSetting: 10 property bool uppercaseOnly: false property string locale: "system" width: if(background) background.width property alias availableLangs: langs.languages LanguageList { id: langs } Column { spacing: 10 Flow { spacing: 5 width: activityConfiguration.width GCComboBox { id: localeBox model: langs.languages background: activityConfiguration.background label: qsTr("Select your locale") } GCDialogCheckBox { id: uppercaseBox width: activityConfiguration.width text: qsTr("Uppercase only mode") checked: uppercaseOnly } GCText { id: speedSliderText text: qsTr("Speed") fontSize: mediumSize wrapMode: Text.WordWrap } Flow { width: activityConfiguration.width spacing: 5 GCSlider { id: speedSlider width: 250 * ApplicationInfo.ratio value: speedSetting maximumValue: 10 minimumValue: 1 scrollEnabled: false } } } } property var dataToSave function setDefaultValues() { // Recreate the binding uppercaseBox.checked = Qt.binding(function(){return activityConfiguration.uppercaseOnly;}) speedSlider.value = Qt.binding(function() {return activityConfiguration.speedSetting;}) var localeUtf8 = dataToSave.locale; if(localeUtf8 !== "system") { localeUtf8 += ".UTF-8"; } for(var i = 0 ; i < activityConfiguration.availableLangs.length ; i ++) { if(activityConfiguration.availableLangs[i].locale === localeUtf8) { activityConfiguration.localeBox.currentIndex = i; break; } } - activityConfiguration.locale = localeUtf8 + if(dataToSave.locale) { + activityConfiguration.locale = localeUtf8 + activityConfiguration.locale = activityConfiguration.availableLangs[0].locale + } + else { + localeBox.currentIndex = 0 + } activityConfiguration.uppercaseOnly = (dataToSave.uppercaseMode === "true") if(dataToSave.speedSetting) { activityConfiguration.speedSetting = dataToSave.speedSetting } else { activityConfiguration.speedSetting = 10 } } function saveValues() { var newLocale = activityConfiguration.availableLangs[activityConfiguration.localeBox.currentIndex].locale; // Remove .UTF-8 if(newLocale.indexOf('.') != -1) { newLocale = newLocale.substring(0, newLocale.indexOf('.')) } activityConfiguration.uppercaseOnly = activityConfiguration.uppercaseBox.checked speedSetting = speedSlider.value dataToSave = {"locale": newLocale, "uppercaseMode": "" + activityConfiguration.uppercaseOnly, "speedSetting": speedSetting} activityConfiguration.locale = newLocale; } } diff --git a/src/activities/reversecount/ActivityConfig.qml b/src/activities/reversecount/ActivityConfig.qml index e1bb7160a..2ca89e179 100644 --- a/src/activities/reversecount/ActivityConfig.qml +++ b/src/activities/reversecount/ActivityConfig.qml @@ -1,61 +1,65 @@ /* GCompris - ActivityConfig.qml * * Copyright (C) 2019 Johnny Jazeix * * Authors: * Johnny Jazeix * * 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 "../../core" Item { id: activityConfiguration property Item background property alias modeBox: modeBox width: if(background) background.width property var availableModes: [ { "text": qsTr("Dots"), "value": "dot" }, { "text": qsTr("Arabic numbers"), "value": "number" }, { "text": qsTr("Roman numbers"), "value": "roman" }, { "text": qsTr("Images"), "value": "image" } ] Flow { id: flow spacing: 5 width: parent.width GCComboBox { id: modeBox model: availableModes background: activityConfiguration.background label: qsTr("Select Domino Representation") } } property var dataToSave function setDefaultValues() { + if(dataToSave["mode"] === undefined) { + dataToSave["mode"] = "dot"; + 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}; } } diff --git a/src/activities/smallnumbers2/ActivityConfig.qml b/src/activities/smallnumbers2/ActivityConfig.qml index 59f712bc6..101c2b171 100644 --- a/src/activities/smallnumbers2/ActivityConfig.qml +++ b/src/activities/smallnumbers2/ActivityConfig.qml @@ -1,96 +1,100 @@ /* GCompris - ActivityConfig.qml * * Copyright (C) 2019 Akshay Kumar * * Authors: * Akshay Kumar * * 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 "../../core" Item { id: activityConfiguration property Item background property alias modeBox: modeBox property var availableModes: [ { "text": qsTr("Dots"), "value": "dot" }, { "text": qsTr("Arabic numbers"), "value": "number" }, { "text": qsTr("Roman numbers"), "value": "roman" }, { "text": qsTr("Images"), "value": "image" } ] property alias speedSlider: speedSlider property int speedSetting: 10 height: columnContent.height width: if(background) background.width Column { id: columnContent spacing: 10 Flow { spacing: 5 width: activityConfiguration.width GCComboBox { id: modeBox model: availableModes background: activityConfiguration.background label: qsTr("Select Domino Representation") } GCText { id: speedSliderText text: qsTr("Speed") fontSize: mediumSize wrapMode: Text.WordWrap height: 100 } Flow { width: activityConfiguration.width spacing: 5 GCSlider { id: speedSlider width: 250 * ApplicationInfo.ratio value: speedSetting maximumValue: 10 minimumValue: 1 scrollEnabled: false } } } } property var dataToSave function setDefaultValues() { speedSlider.value = Qt.binding(function() {return activityConfiguration.speedSetting;}) for(var i = 0 ; i < availableModes.length ; i++) { if(availableModes[i].value === dataToSave["mode"]) { modeBox.currentIndex = i; break; } } + if(dataToSave["mode"] === undefined) { + dataToSave["mode"] = "dot"; + modeBox.currentIndex = 0 + } if(dataToSave.speedSetting) { activityConfiguration.speedSetting = dataToSave.speedSetting } else { activityConfiguration.speedSetting = 10 } } function saveValues() { var newMode = availableModes[modeBox.currentIndex].value; speedSetting = speedSlider.value dataToSave = {"mode": newMode, "speedSetting": speedSetting} } } diff --git a/src/activities/traffic/ActivityConfig.qml b/src/activities/traffic/ActivityConfig.qml index 505c61aee..13fc7978a 100644 --- a/src/activities/traffic/ActivityConfig.qml +++ b/src/activities/traffic/ActivityConfig.qml @@ -1,64 +1,65 @@ /* GCompris - ActivityConfig.qml * * Copyright (C) 2019 Johnny Jazeix * * Authors: * Johnny Jazeix * * 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 "../../core" Item { id: activityConfiguration property Item background property alias modeBox: modeBox width: if(background) background.width property var availableModes: [ { "text": qsTr("Colors"), "value": "COLOR" }, { "text": qsTr("Images"), "value": "IMAGE" } ] Flow { id: flow spacing: 5 width: parent.width GCComboBox { id: modeBox model: availableModes background: activityConfiguration.background label: qsTr("Select your mode") } } property var dataToSave function setDefaultValues() { if(dataToSave["mode"] === undefined) { dataToSave["mode"] = "IMAGE"; + 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}; } } diff --git a/src/activities/wordsgame/ActivityConfig.qml b/src/activities/wordsgame/ActivityConfig.qml index 15caa46e1..c6f3d4394 100644 --- a/src/activities/wordsgame/ActivityConfig.qml +++ b/src/activities/wordsgame/ActivityConfig.qml @@ -1,120 +1,126 @@ /* GCompris - ActivityConfig.qml * * Copyright (C) 2019 Akshay Kumar * * Authors: * Akshay Kumar * * 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 "../../core" Item { id: activityConfiguration property Item background property alias localeBox: localeBox property alias uppercaseBox: uppercaseBox property bool uppercaseOnly: false property alias speedSlider: speedSlider property int speedSetting: 10 property string locale: "system" width: if(background) background.width property alias availableLangs: langs.languages LanguageList { id: langs } Column { spacing: 10 Flow { spacing: 5 width: activityConfiguration.width GCComboBox { id: localeBox model: langs.languages background: activityConfiguration.background label: qsTr("Select your locale") } GCDialogCheckBox { id: uppercaseBox width: parent.width text: qsTr("Uppercase only mode") checked: activityConfiguration.uppercaseOnly } GCText { id: speedSliderText text: qsTr("Speed") fontSize: mediumSize wrapMode: Text.WordWrap } Flow { width: activityConfiguration.width spacing: 5 GCSlider { id: speedSlider width: 250 * ApplicationInfo.ratio value: speedSetting maximumValue: 10 minimumValue: 1 scrollEnabled: false } } } } property var dataToSave function setDefaultValues() { // Recreate the binding uppercaseBox.checked = Qt.binding(function(){return activityConfiguration.uppercaseOnly;}) speedSlider.value = Qt.binding(function() {return activityConfiguration.speedSetting;}) var localeUtf8 = dataToSave.locale; if(localeUtf8 !== "system") { localeUtf8 += ".UTF-8"; } for(var i = 0 ; i < activityConfiguration.availableLangs.length ; i ++) { if(activityConfiguration.availableLangs[i].locale === localeUtf8) { activityConfiguration.localeBox.currentIndex = i; break; } } - activityConfiguration.locale = localeUtf8 + if(dataToSave.locale) { + activityConfiguration.locale = localeUtf8 + } + else { + localeBox.currentIndex = 0 + activityConfiguration.locale = activityConfiguration.availableLangs[0].locale + } activityConfiguration.uppercaseOnly = (dataToSave.uppercaseMode === "true") if(dataToSave.speedSetting) { activityConfiguration.speedSetting = dataToSave.speedSetting } else { activityConfiguration.speedSetting = 10 } } function saveValues() { var newLocale = activityConfiguration.availableLangs[activityConfiguration.localeBox.currentIndex].locale; // Remove .UTF-8 if(newLocale.indexOf('.') != -1) { newLocale = newLocale.substring(0, newLocale.indexOf('.')) } activityConfiguration.uppercaseOnly = activityConfiguration.uppercaseBox.checked speedSetting = speedSlider.value dataToSave = {"locale": newLocale, "uppercaseMode": "" + activityConfiguration.uppercaseOnly, "speedSetting": speedSetting} activityConfiguration.locale = newLocale; } }