Warning, /education/gcompris/src/activities/balancebox/ActivityConfig.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - ActivityConfig.qml 0002 * 0003 * SPDX-FileCopyrightText: 2020 Timothée Giet <animtim@gmail.com> 0004 * 0005 * Authors: 0006 * Timothée Giet <animtim@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 0015 Item { 0016 id: activityConfiguration 0017 property Item background 0018 width: flick.width 0019 height: childrenRect.height 0020 property alias levelsBox: levelsBox 0021 property string loadedFilePath: "" 0022 property var availableLevels: [ 0023 { "text": qsTr("Built-in"), "value": "builtin" }, 0024 { "text": qsTr("User"), "value": "user" }, 0025 ] 0026 0027 Column { 0028 spacing: 10 * ApplicationInfo.ratio 0029 width: parent.width 0030 GCComboBox { 0031 id: levelsBox 0032 model: availableLevels 0033 background: activityConfiguration.background 0034 label: qsTr("Select your level set") 0035 } 0036 0037 GCButton { 0038 id: editorButton 0039 height: 50 * ApplicationInfo.ratio 0040 width: Math.min(parent.width, implicitWidth) 0041 text: enabled ? qsTr("Start the editor") : qsTr("Start the activity to access the editor") 0042 visible: levelsBox.currentIndex == 1 0043 enabled: !dialogChooseLevel.inMenu 0044 onClicked: startEditor() 0045 } 0046 0047 GCButton { 0048 id: loadButton 0049 height: 50 * ApplicationInfo.ratio 0050 width: Math.min(parent.width, implicitWidth) 0051 text: enabled ? qsTr("Load saved levels") : qsTr("Start the activity to load your levels") 0052 visible: levelsBox.currentIndex == 1 0053 enabled: !dialogChooseLevel.inMenu 0054 onClicked: creationHandler.loadWindow() 0055 } 0056 } 0057 0058 function startEditor() { 0059 editorLoader.active = true; 0060 displayDialog(editorLoader.item); 0061 } 0062 0063 property var dataToSave 0064 function setDefaultValues() { 0065 if(dataToSave["levels"] === undefined) { 0066 dataToSave["levels"] = "builtin"; 0067 levelsBox.currentIndex = 0; 0068 } 0069 for(var i = 0 ; i < availableLevels.length ; i++) { 0070 if(availableLevels[i].value === dataToSave["levels"]) { 0071 levelsBox.currentIndex = i; 0072 break; 0073 } 0074 } 0075 if(dataToSave["filePath"] != undefined) 0076 activityConfiguration.loadedFilePath = dataToSave["filePath"]; 0077 } 0078 0079 function saveValues() { 0080 var newLevels = availableLevels[levelsBox.currentIndex].value; 0081 if(!dialogChooseLevel.inMenu) 0082 activityConfiguration.loadedFilePath = activity.loadedFilePath; 0083 dataToSave = {"levels": newLevels, "filePath": activityConfiguration.loadedFilePath}; 0084 console.log("file path is " + activityConfiguration.loadedFilePath); 0085 } 0086 }