Warning, /education/gcompris/src/activities/memory/ActivityConfig.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - ActivityConfig.qml
0002  *
0003  * SPDX-FileCopyrightText: 2021 Mariam Fahmy <mariamfahmy66@gmail.com>
0004  *
0005  * Authors:
0006  *   Mariam Fahmy <mariamfahmy66@gmail.com>
0007  *
0008  *   SPDX-License-Identifier: GPL-3.0-or-later
0009  */
0010 
0011 
0012 import QtQuick 2.12
0013 import GCompris 1.0
0014 
0015 import "../../core"
0016 
0017 Item {
0018     id: activityConfiguration
0019     property Item background
0020     property alias modeBox: modeBox
0021     width: flick.width
0022     property var availableModes: [
0023         { "text": qsTr("1 player"), "value": 1 },
0024         { "text": qsTr("2 players"), "value": 2 }
0025     ]
0026     Column {
0027         spacing: 10 * ApplicationInfo.ratio
0028         width: parent.width
0029         GCComboBox {
0030             id: modeBox
0031             model: availableModes
0032             background: activityConfiguration.background
0033             label: qsTr("Choose number of players")
0034         }
0035     }
0036 
0037     property var dataToSave
0038 
0039     function setDefaultValues() {
0040         if(dataToSave["mode"] == undefined) {
0041             dataToSave["mode"] = 1;
0042             modeBox.currentIndex = 0
0043         }
0044         for(var i = 0 ; i < availableModes.length ; i++) {
0045             if(availableModes[i].value == dataToSave["mode"]) {
0046                 modeBox.currentIndex = i;
0047                 break;
0048             }
0049         }
0050     }
0051 
0052     function saveValues() {
0053         var newMode = availableModes[modeBox.currentIndex].value;
0054         dataToSave = {"mode": newMode};
0055     }
0056 }