Warning, /education/gcompris/src/activities/readingv/ActivityConfig.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - ActivityConfig.qml
0002 *
0003 * SPDX-FileCopyrightText: 2020 Johnny Jazeix <jazeix@gmail.com>
0004 *
0005 * Authors:
0006 * Johnny Jazeix <jazeix@gmail.com>
0007 *
0008 * SPDX-License-Identifier: GPL-3.0-or-later
0009 */
0010 import QtQuick 2.12
0011 import GCompris 1.0
0012
0013 import "../../core"
0014 import "qrc:/gcompris/src/core/core.js" as Core
0015
0016 Item {
0017 id: activityConfiguration
0018 property Item background
0019 property alias localeBox: localeBox
0020 property alias speedSlider: speedSlider
0021 property int speedSetting: 10
0022 property string locale: "system"
0023 property string configurationLocale: "system"
0024 width: flick.width
0025 height: childrenRect.height
0026 property alias availableLangs: langs.languages
0027 LanguageList {
0028 id: langs
0029 }
0030
0031 Column {
0032 spacing: 10 * ApplicationInfo.ratio
0033 width: activityConfiguration.width
0034 GCComboBox {
0035 id: localeBox
0036 model: langs.languages
0037 background: activityConfiguration.background
0038 label: qsTr("Select your locale")
0039 }
0040 GCText {
0041 id: speedSliderText
0042 width: parent.width
0043 text: qsTr("Speed")
0044 fontSize: mediumSize
0045 wrapMode: Text.WordWrap
0046 }
0047 GCSlider {
0048 id: speedSlider
0049 width: 250 * ApplicationInfo.ratio
0050 value: speedSetting
0051 to: 10
0052 from: 1
0053 wheelEnabled: false
0054 }
0055 }
0056
0057 function setLocale(localeToSet) {
0058 // Store the locale as-is to be displayed in menu
0059 configurationLocale = localeToSet
0060 activityConfiguration.locale = Core.resolveLocale(localeToSet)
0061 }
0062
0063 property var dataToSave
0064 function setDefaultValues() {
0065 // Recreate the binding
0066 speedSlider.value = Qt.binding(function() {return activityConfiguration.speedSetting;})
0067
0068 var localeUtf8 = dataToSave.locale;
0069 if(localeUtf8 !== "system") {
0070 localeUtf8 += ".UTF-8";
0071 }
0072
0073 if(dataToSave.locale) {
0074 setLocale(localeUtf8)
0075 }
0076 else {
0077 activityConfiguration.localeBox.currentIndex = 0
0078 setLocale(activityConfiguration.availableLangs[0].locale)
0079 }
0080
0081 if(dataToSave.speedSetting) {
0082 activityConfiguration.speedSetting = dataToSave.speedSetting
0083 }
0084 else {
0085 activityConfiguration.speedSetting = 10
0086 }
0087
0088 for(var i = 0 ; i < activityConfiguration.availableLangs.length ; i ++) {
0089 if(activityConfiguration.availableLangs[i].locale === localeUtf8) {
0090 activityConfiguration.localeBox.currentIndex = i;
0091 break;
0092 }
0093 }
0094 }
0095
0096 function saveValues() {
0097 var newLocale = activityConfiguration.availableLangs[activityConfiguration.localeBox.currentIndex].locale;
0098 // Remove .UTF-8
0099 if(newLocale.indexOf('.') != -1) {
0100 newLocale = newLocale.substring(0, newLocale.indexOf('.'))
0101 }
0102
0103 speedSetting = speedSlider.value
0104
0105 setLocale(newLocale);
0106 dataToSave = {"locale": newLocale, "speedSetting": speedSetting, "activityLocale": activityConfiguration.locale}
0107 }
0108 }