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