Warning, /education/gcompris/src/activities/wordsgame/ActivityConfig.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - ActivityConfig.qml 0002 * 0003 * SPDX-FileCopyrightText: 2019 Akshay Kumar <email.akshay98@gmail.com> 0004 * 0005 * Authors: 0006 * Akshay Kumar <email.akshay98@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 uppercaseBox: uppercaseBox 0021 property bool uppercaseOnly: false 0022 property alias speedSlider: speedSlider 0023 property int speedSetting: 10 0024 property string locale: "system" 0025 property string configurationLocale: "system" 0026 width: flick.width 0027 height: childrenRect.height 0028 property alias availableLangs: langs.languages 0029 LanguageList { 0030 id: langs 0031 } 0032 0033 Column { 0034 spacing: 10 * ApplicationInfo.ratio 0035 width: activityConfiguration.width 0036 GCComboBox { 0037 id: localeBox 0038 model: langs.languages 0039 background: activityConfiguration.background 0040 label: qsTr("Select your locale") 0041 } 0042 GCDialogCheckBox { 0043 id: uppercaseBox 0044 text: qsTr("Uppercase only mode") 0045 checked: activityConfiguration.uppercaseOnly 0046 } 0047 GCText { 0048 id: speedSliderText 0049 text: qsTr("Speed") 0050 width: parent.width 0051 fontSize: mediumSize 0052 wrapMode: Text.WordWrap 0053 } 0054 GCSlider { 0055 id: speedSlider 0056 width: 250 * ApplicationInfo.ratio 0057 value: speedSetting 0058 to: 10 0059 from: 1 0060 wheelEnabled: false 0061 } 0062 } 0063 0064 function setLocale(localeToSet) { 0065 // Store the locale as-is to be displayed in menu 0066 configurationLocale = localeToSet 0067 activityConfiguration.locale = Core.resolveLocale(localeToSet) 0068 } 0069 0070 property var dataToSave 0071 function setDefaultValues() { 0072 // Recreate the binding 0073 uppercaseBox.checked = Qt.binding(function(){return activityConfiguration.uppercaseOnly;}) 0074 speedSlider.value = Qt.binding(function() {return activityConfiguration.speedSetting;}) 0075 0076 var localeUtf8 = dataToSave.locale; 0077 if(localeUtf8 !== "system") { 0078 localeUtf8 += ".UTF-8"; 0079 } 0080 0081 if(dataToSave.locale) { 0082 setLocale(localeUtf8) 0083 } 0084 else { 0085 activityConfiguration.localeBox.currentIndex = 0 0086 setLocale(activityConfiguration.availableLangs[0].locale) 0087 } 0088 0089 for(var i = 0 ; i < activityConfiguration.availableLangs.length ; i ++) { 0090 if(activityConfiguration.availableLangs[i].locale === localeUtf8) { 0091 activityConfiguration.localeBox.currentIndex = i; 0092 break; 0093 } 0094 } 0095 0096 activityConfiguration.uppercaseOnly = (dataToSave.uppercaseMode === "true") 0097 if(dataToSave.speedSetting) { 0098 activityConfiguration.speedSetting = dataToSave.speedSetting 0099 } 0100 else { 0101 activityConfiguration.speedSetting = 10 0102 } 0103 } 0104 0105 function saveValues() { 0106 var newLocale = activityConfiguration.availableLangs[activityConfiguration.localeBox.currentIndex].locale; 0107 // Remove .UTF-8 0108 if(newLocale.indexOf('.') != -1) { 0109 newLocale = newLocale.substring(0, newLocale.indexOf('.')) 0110 } 0111 0112 activityConfiguration.uppercaseOnly = activityConfiguration.uppercaseBox.checked 0113 0114 speedSetting = speedSlider.value 0115 0116 setLocale(newLocale); 0117 dataToSave = {"locale": newLocale, "uppercaseMode": "" + activityConfiguration.uppercaseOnly, "speedSetting": speedSetting, "activityLocale": activityConfiguration.locale} 0118 } 0119 }