Commit 01990e65 authored by Johnny Jazeix's avatar Johnny Jazeix

note_names, move config to activityconfig (multiple dataset style)

parent 505fc748
/* 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
width: if(background) background.width
Column {
spacing: 10
Flow {
spacing: 5
width: activityConfiguration.width
GCText {
id: speedSliderText
text: qsTr("Speed")
fontSize: mediumSize
wrapMode: Text.WordWrap
}
Flow {
width: activityConfiguration.width
spacing: 5
GCSlider {
id: speedSlider
width: 250 * ApplicationInfo.ratio
value: speedSetting
minimumValue: 1
maximumValue: 5
scrollEnabled: false
}
}
}
}
property var dataToSave
function setDefaultValues() {
// Recreate the binding
speedSlider.value = Qt.binding(function() {return activityConfiguration.speedSetting;})
if(dataToSave.speedSetting) {
activityConfiguration.speedSetting = dataToSave.speedSetting
}
else {
activityConfiguration.speedSetting = 5
}
}
function saveValues() {
dataToSave = {"speedSetting": speedSlider.value}
}
}
......@@ -45,7 +45,7 @@ ActivityBase {
signal stop
Component.onCompleted: {
dialogActivityConfig.getInitialConfiguration()
dialogActivityConfig.initialize()
activity.start.connect(start)
activity.stop.connect(stop)
}
......@@ -112,46 +112,13 @@ ActivityBase {
property string clefType: "Treble"
DialogActivityConfig {
DialogChooseLevel {
id: dialogActivityConfig
currentActivity: activity
content: Component {
Item {
property alias speedSlider: speedSlider
height: column.height
Column {
id: column
spacing: 10 * ApplicationInfo.ratio
width: parent.width
GCText {
id: speedSliderText
text: qsTr("Speed")
fontSize: mediumSize
wrapMode: Text.WordWrap
}
Flow {
width: dialogActivityConfig.width
spacing: 5
GCSlider {
id: speedSlider
width: 250 * ApplicationInfo.ratio
value: activity.speedSetting
maximumValue: 5
minimumValue: 1
scrollEnabled: false
}
}
}
}
}
currentActivity: activity.activityInfo
onStart: {
if(!introMessage.visible || !iAmReady.visible) {
multipleStaff.pauseNoteAnimation()
addNoteTimer.pause()
}
onStartActivity: {
introMessage.visible = false;
iAmReady.visible = true;
}
onClose: {
home();
......@@ -159,20 +126,8 @@ ActivityBase {
iAmReady.visible = true;
}
onLoadData: {
if(dataToSave) {
if(dataToSave["speedSetting"]) {
activity.speedSetting = dataToSave["speedSetting"];
}
}
}
onSaveData: {
var oldSpeed = activity.speedSetting
activity.speedSetting = dialogActivityConfig.configItem.speedSlider.value
if(oldSpeed != activity.speedSetting) {
dataToSave = {"speedSetting": activity.speedSetting};
background.stop();
introMessage.visible = false;
iAmReady.visible = true;
if(activityData && activityData["speedSetting"]) {
activity.speedSetting = activityData["speedSetting"];
}
}
}
......@@ -473,16 +428,17 @@ ActivityBase {
Bar {
id: bar
content: BarEnumContent { value: (help | home | level | reload | config) }
content: BarEnumContent { value: (help | home | level | reload | activityConfig) }
onHelpClicked: {
displayDialog(dialogHelp)
}
onPreviousLevelClicked: Activity.previousLevel()
onNextLevelClicked: Activity.nextLevel()
onHomeClicked: activity.home()
onConfigClicked: {
dialogActivityConfig.active = true
displayDialog(dialogActivityConfig)
onActivityConfigClicked: {
multipleStaff.pauseNoteAnimation()
addNoteTimer.pause()
displayDialog(dialogActivityConfig)
}
onReloadClicked: {
iAmReady.visible = true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment