Warning, /education/gcompris/src/activities/lang/Lang.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - lang.qml 0002 * 0003 * Copyright (C) Siddhesh suthar <siddhesh.it@gmail.com> (Qt Quick port) 0004 * 0005 * Authors: 0006 * Pascal Georges (pascal.georges1@free.fr) (GTK+ version) 0007 * Holger Kaelberer <holger.k@elberer.de> (Qt Quick port of imageid) 0008 * Siddhesh suthar <siddhesh.it@gmail.com> (Qt Quick port) 0009 * Bruno Coudoin <bruno.coudoin@gcompris.net> (Integration Lang dataset) 0010 * 0011 * SPDX-License-Identifier: GPL-3.0-or-later 0012 */ 0013 import QtQuick 2.12 0014 import GCompris 1.0 0015 import QtGraphicalEffects 1.0 0016 0017 import "../../core" 0018 import "lang.js" as Activity 0019 import "spell_it.js" as SpellActivity 0020 import "qrc:/gcompris/src/core/core.js" as Core 0021 0022 ActivityBase { 0023 id: activity 0024 0025 onStart: focus = true 0026 onStop: {} 0027 0028 // When opening a dialog, it steals the focus and re set it to the activity. 0029 // We need to set it back to the active item in order to have key events. 0030 onFocusChanged: { 0031 if(focus) { 0032 Activity.focusEventInput(); 0033 } 0034 } 0035 0036 pageComponent: Rectangle { 0037 id: background 0038 color: "#85D8F6" 0039 anchors.fill: parent 0040 0041 property bool englishFallback: false 0042 0043 signal start 0044 signal stop 0045 signal voiceError 0046 signal voiceDone 0047 0048 Component.onCompleted: { 0049 activity.start.connect(start) 0050 activity.stop.connect(stop) 0051 } 0052 0053 // Add here the QML items you need to access in javascript 0054 QtObject { 0055 id: items 0056 property Item main: activity.main 0057 property GCAudio audioVoices: activity.audioVoices 0058 property alias background: background 0059 property alias bar: bar 0060 property alias imageReview: imageReview 0061 property alias parser: parser 0062 property alias menuModel: menuScreen.menuModel 0063 property var wordList 0064 property alias menuScreen: menuScreen 0065 property alias englishFallbackDialog: englishFallbackDialog 0066 property string locale: 'system' 0067 property alias dialogActivityConfig: dialogActivityConfig 0068 property var categoriesTranslations: activity.categoriesTranslations 0069 } 0070 0071 onStart: { 0072 Activity.init(items) 0073 dialogActivityConfig.initialize() 0074 activity.audioVoices.error.connect(voiceError) 0075 activity.audioVoices.done.connect(voiceDone) 0076 Activity.start() 0077 } 0078 0079 onStop: { 0080 dialogActivityConfig.saveData() 0081 Activity.stop() 0082 } 0083 0084 JsonParser { 0085 id: parser 0086 onError: console.error("lang: Error parsing json: " + msg); 0087 } 0088 0089 MenuScreen { 0090 id: menuScreen 0091 } 0092 0093 ImageReview { 0094 id: imageReview 0095 } 0096 0097 DialogHelp { 0098 id: dialogHelp 0099 onClose: home() 0100 } 0101 0102 Bar { 0103 id: bar 0104 anchors.bottom: keyboardArea.top 0105 content: menuScreen.started ? withConfig : withoutConfig 0106 property BarEnumContent withConfig: BarEnumContent { value: help | home | activityConfig } 0107 property BarEnumContent withoutConfig: BarEnumContent { value: help | home } 0108 onHelpClicked: { 0109 displayDialog(dialogHelp) 0110 } 0111 onHomeClicked: { 0112 if(!items.menuScreen.started && !items.imageReview.started) 0113 // We're in a mini game, start imageReview 0114 items.imageReview.start() 0115 else if(items.imageReview.started) 0116 // Leave imageReview 0117 Activity.launchMenuScreen() 0118 else 0119 home() 0120 } 0121 onActivityConfigClicked: { 0122 displayDialog(dialogActivityConfig) 0123 } 0124 } 0125 0126 // This is a stop to hold the virtual keyboard from a mini game 0127 Row { 0128 id: keyboardArea 0129 anchors.bottom: parent.bottom 0130 width: parent.width 0131 } 0132 0133 Loader { 0134 id: englishFallbackDialog 0135 sourceComponent: GCDialog { 0136 parent: activity 0137 isDestructible: false 0138 message: qsTr("We are sorry, we don't have yet a translation for your language.") + " " + 0139 qsTr("GCompris is developed by the KDE community, you can translate GCompris by joining a translation team on <a href=\"%2\">%2</a>").arg("https://l10n.kde.org/") + 0140 "<br /> <br />" + 0141 qsTr("We switched to English for this activity but you can select another language in the configuration dialog.") 0142 onStart: { 0143 menuScreen.stop(); 0144 forceActiveFocus(); 0145 parent.Keys.enabled = false; 0146 } 0147 onClose: { 0148 background.englishFallback = false; 0149 menuScreen.start(); 0150 } 0151 } 0152 anchors.fill: parent 0153 focus: true 0154 active: background.englishFallback 0155 onStatusChanged: if (status == Loader.Ready) item.start() 0156 } 0157 0158 DialogChooseLevel { 0159 id: dialogActivityConfig 0160 currentActivity: activity.activityInfo 0161 onClose: { 0162 home(); 0163 } 0164 onSaveData: { 0165 // Save progress for the locale 0166 activityData[ApplicationInfo.getVoicesLocale(items.locale)] = 0167 Activity.lessonsToSavedProperties() 0168 0169 levelFolder = dialogActivityConfig.chosenLevels; 0170 currentActivity.currentLevels = dialogActivityConfig.chosenLevels; 0171 ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels); 0172 } 0173 onLoadData: { 0174 if(activityData && activityData["locale"]) { 0175 items.locale = Core.resolveLocale(activityData["locale"]); 0176 } 0177 else { 0178 items.locale = Core.resolveLocale(items.locale); 0179 } 0180 } 0181 onStartActivity: { 0182 // Reload the locale information when restarting the activity 0183 loadData() 0184 background.start(); 0185 } 0186 } 0187 } 0188 0189 property var categoriesTranslations: {"otherChapter": qsTr("other"), 0190 "otherLesson": qsTr("other"), 0191 "action": qsTr("action"), "adjective": qsTr("adjective"), 0192 "color": qsTr("color"), "number": qsTr("number"), 0193 "people": qsTr("people"), "bodyparts": qsTr("bodyparts"), 0194 "clothes": qsTr("clothes"), "emotion": qsTr("emotion"), 0195 "job": qsTr("job"), "sport": qsTr("sport"), 0196 "nature": qsTr("nature"), "animal": qsTr("animal"), 0197 "fruit": qsTr("fruit"), "plant": qsTr("plant"), 0198 "vegetables": qsTr("vegetables"), "object": qsTr("object"), 0199 "construction": qsTr("construction"), 0200 "furniture": qsTr("furniture"), "houseware": qsTr("houseware"), 0201 "tool": qsTr("tool"), "food": qsTr("food"), 0202 "transport": qsTr("transport")} 0203 0204 }