Warning, /education/gcompris/src/activities/grammar_analysis/ActivityConfig.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - ActivityConfig.qml 0002 * 0003 * Copyright (C) 2022-2023 Bruno ANSELME <be.root@free.fr> 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 string locale: "system" 0020 property string configurationLocale: "system" 0021 height: childrenRect.height 0022 width: if(background) background.width * 0.9 0023 property alias availableLangs: langs.languages 0024 LanguageList { 0025 id: langs 0026 } 0027 0028 Column { 0029 id: innerColumn 0030 spacing: 10 * ApplicationInfo.ratio 0031 width: activityConfiguration.width 0032 GCComboBox { 0033 id: localeBox 0034 model: langs.languages 0035 background: activityConfiguration.background 0036 label: qsTr("Select your locale") 0037 } 0038 } 0039 0040 function setLocale(localeToSet) { 0041 // Store the locale as-is to be displayed in menu 0042 configurationLocale = localeToSet 0043 activityConfiguration.locale = Core.resolveLocale(localeToSet) 0044 } 0045 0046 property var dataToSave 0047 0048 function setDefaultValues() { 0049 var localeUtf8 = dataToSave.locale; 0050 if(localeUtf8 !== "system") { 0051 localeUtf8 += ".UTF-8"; 0052 } 0053 0054 if(dataToSave.locale) { 0055 setLocale(localeUtf8) 0056 } 0057 else { 0058 localeBox.currentIndex = 0 0059 setLocale(activityConfiguration.availableLangs[0].locale) 0060 } 0061 0062 for(var i = 0 ; i < activityConfiguration.availableLangs.length ; i ++) { 0063 if(activityConfiguration.availableLangs[i].locale === localeUtf8) { 0064 localeBox.currentIndex = i; 0065 break; 0066 } 0067 } 0068 } 0069 0070 function saveValues() { 0071 var newLocale = activityConfiguration.availableLangs[localeBox.currentIndex].locale; 0072 // Remove .UTF-8 0073 if(newLocale.indexOf('.') !== -1) { 0074 newLocale = newLocale.substring(0, newLocale.indexOf('.')) 0075 } 0076 0077 setLocale(newLocale); 0078 0079 dataToSave = {"locale": newLocale, "activityLocale": activityConfiguration.locale} 0080 } 0081 }