Commit 3f3494af authored by Johnny Jazeix's avatar Johnny Jazeix

play_piano, move config to activityconfig (multiple dataset style)

parent 616df1fc
/* 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 QtQuick.Controls 1.5
import "../../core"
Item {
id: activityConfiguration
property Item background
readonly property string coloredNotes: "coloredNotes"
readonly property string coloredlessNotes: "colorlessNotes"
property string mode: coloredNotes
width: if(background) background.width
ExclusiveGroup {
id: configOptions
}
Flow {
id: flow
spacing: 5
width: parent.width
GCDialogCheckBox {
id: coloredNotesModeBox
width: flow.width - 50
text: qsTr("Display colored notes.")
checked: activityConfiguration.mode === coloredNotes
exclusiveGroup: configOptions
onCheckedChanged: {
if(coloredNotesModeBox.checked) {
activityConfiguration.mode = coloredNotes
}
}
}
GCDialogCheckBox {
id: colorlessNotesModeBox
width: coloredNotesModeBox.width
text: qsTr("Display colorless notes.")
checked: activityConfiguration.mode === coloredlessNotes
exclusiveGroup: configOptions
onCheckedChanged: {
if(colorlessNotesModeBox.checked) {
activityConfiguration.mode = coloredlessNotes
}
}
}
}
property var dataToSave
function setDefaultValues() {
if(dataToSave["mode"] === undefined) {
dataToSave["mode"] = coloredNotes;
}
activityConfiguration.mode = dataToSave["mode"];
if(activityConfiguration.mode === coloredNotes) {
coloredNotesModeBox.checked = true
}
else {
colorlessNotesModeBox.checked = true
}
}
function saveValues() {
dataToSave = {"mode": activityConfiguration.mode};
}
}
......@@ -20,7 +20,6 @@
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.6
import QtQuick.Controls 1.5
import GCompris 1.0
import "../../core"
......@@ -44,6 +43,7 @@ ActivityBase {
signal stop
Component.onCompleted: {
dialogActivityConfig.initialize()
activity.start.connect(start)
activity.stop.connect(stop)
}
......@@ -110,7 +110,6 @@ ActivityBase {
}
onStart: {
dialogActivityConfig.getInitialConfiguration()
Activity.start(items)
}
onStop: { Activity.stop() }
......@@ -244,57 +243,18 @@ ActivityBase {
onUndoButtonClicked: Activity.undoPreviousAnswer()
}
ExclusiveGroup {
id: configOptions
}
DialogActivityConfig {
DialogChooseLevel {
id: dialogActivityConfig
content: Component {
Column {
id: column
spacing: 5
width: dialogActivityConfig.width
height: dialogActivityConfig.height
property alias coloredNotesModeBox: coloredNotesModeBox
property alias colorlessNotesModeBox: colorlessNotesModeBox
currentActivity: activity.activityInfo
GCDialogCheckBox {
id: coloredNotesModeBox
width: column.width - 50
text: qsTr("Display colored notes.")
checked: items.mode === "coloredNotes"
exclusiveGroup: configOptions
onCheckedChanged: {
if(coloredNotesModeBox.checked) {
items.mode = "coloredNotes"
}
}
}
GCDialogCheckBox {
id: colorlessNotesModeBox
width: coloredNotesModeBox.width
text: qsTr("Display colorless notes.")
checked: items.mode === "colorlessNotes"
exclusiveGroup: configOptions
onCheckedChanged: {
if(colorlessNotesModeBox.checked) {
items.mode = "colorlessNotes"
}
}
}
}
}
onLoadData: {
if(dataToSave && dataToSave["mode"])
items.mode = dataToSave["mode"]
}
onSaveData: dataToSave["mode"] = items.mode
onClose: {
home()
}
onLoadData: {
if(activityData && activityData["mode"]) {
items.mode = activityData["mode"];
}
}
onVisibleChanged: {
multipleStaff.eraseAllNotes()
iAmReady.visible = true
......@@ -308,13 +268,12 @@ ActivityBase {
Bar {
id: bar
content: BarEnumContent { value: help | home | level | config | reload }
content: BarEnumContent { value: help | home | level | activityConfig | reload }
onHelpClicked: displayDialog(dialogHelp)
onPreviousLevelClicked: Activity.previousLevel()
onNextLevelClicked: Activity.nextLevel()
onHomeClicked: activity.home()
onConfigClicked: {
dialogActivityConfig.active = true
onActivityConfigClicked: {
displayDialog(dialogActivityConfig)
}
onReloadClicked: {
......
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