ActivityConfig.qml 2.11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/* GCompris - ActivityConfig.qml
 *
* Copyright (C) 2020 Johnny Jazeix <jazeix@gmail.com>
 *
 * Authors:
 *   Johnny Jazeix <jazeix@gmail.com>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, see <https://www.gnu.org/licenses/>.
 */
import QtQuick 2.6
import GCompris 1.0

import "../../core"

Item {
    id: activityConfiguration
    property Item background
    property alias speedSlider: speedSlider
    property int speedSetting: 5
Timothée Giet's avatar
Timothée Giet committed
31
    width: if(background) background.width
32 33 34 35

    Flow {
        id: flow
        spacing: 5
Timothée Giet's avatar
Timothée Giet committed
36
        width: activityConfiguration.width
37 38 39 40 41 42 43
        GCText {
            id: speedSliderText
            text: qsTr("Speed")
            fontSize: mediumSize
            wrapMode: Text.WordWrap
        }
        Flow {
Timothée Giet's avatar
Timothée Giet committed
44
            width: activityConfiguration.width
45 46 47 48 49 50 51 52 53 54 55 56 57 58
            spacing: 5
            GCSlider {
                id: speedSlider
                width: 250 * ApplicationInfo.ratio
                value: speedSetting
                maximumValue: 5
                minimumValue: 1
                scrollEnabled: false
            }
        }
    }

    property var dataToSave
    function setDefaultValues() {
59
        speedSlider.value = Qt.binding(function() {return activityConfiguration.speedSetting;})
60 61 62 63 64 65
        if(dataToSave.speedSetting) {
            activityConfiguration.speedSetting = dataToSave.speedSetting
        }
        else {
            activityConfiguration.speedSetting = 5
        }
66 67 68 69 70 71
    }
    function saveValues() {
        speedSetting = speedSlider.value
        dataToSave = {"speedSetting": speedSetting}
    }
}