1/* GCompris - ActivityConfig.qml 2 * 3 * SPDX-FileCopyrightText: 2020 Shubham Mishra <shivam828787@gmail.com> 4 * 5 * Authors: 6 * Shubham Mishra <shivam828787@gmail.com> 7 * 8 * SPDX-License-Identifier: GPL-3.0-or-later 9 */ 10import QtQuick 2.9 11import GCompris 1.0 12 13import "../../core" 14 15Item { 16 id: activityConfiguration 17 property Item background 18 property alias modeBox: modeBox 19 width: if(background) background.width 20 property var availableModes: [ 21 { "text": qsTr("Easy"), "value": 1 }, 22 { "text": qsTr("Medium"), "value": 2 }, 23 { "text": qsTr("Difficult"), "value": 3 } 24 ] 25 Column { 26 spacing: 10 * ApplicationInfo.ratio 27 width: parent.width 28 GCComboBox { 29 id: modeBox 30 model: availableModes 31 background: activityConfiguration.background 32 label: qsTr("Select your difficulty") 33 } 34 } 35 36 property var dataToSave 37 38 function setDefaultValues() { 39 if(dataToSave["mode"] === undefined) { 40 dataToSave["mode"] = 1; 41 modeBox.currentIndex = 0 42 } 43 for(var i = 0 ; i < availableModes.length ; i++) { 44 if(availableModes[i].value == dataToSave["mode"]) { 45 modeBox.currentIndex = i; 46 break; 47 } 48 } 49 } 50 51 function saveValues() { 52 var newMode = availableModes[modeBox.currentIndex].value; 53 if (newMode != dataToSave["mode"]) { 54 dataToSave["mode"] = newMode; 55 dataToSave = {"mode": dataToSave["mode"]}; 56 } 57 } 58} 59