Commit ceaff141 authored by Deepak  Kumar's avatar Deepak Kumar Committed by Johnny Jazeix

superbrain, move config to activityconfig (multiple dataset style) + fix...

superbrain, move config to activityconfig (multiple dataset style) + fix initial value in graph_coloring
parent 3e7c2a09
......@@ -64,7 +64,7 @@ ActivityBase {
property alias nodesRepeater: nodesRepeater
property alias edgesRepeater: edgesRepeater
property alias chooserGrid: chooserGrid
property string mode
property string mode: "color"
}
onStart: { Activity.start(items) }
......
/* GCompris - ActivityConfig.qml
*
* Copyright (C) 2020 Deepak Kumar <deepakdk2431@gmail.com>
*
* Authors:
* Deepak Kumar <deepakdk2431@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 "../../core"
Item {
id: activityConfiguration
property Item background
property alias modeBox: modeBox
width: if(background) background.width
property var availableModes: [
{ "text": qsTr("Colors"), "value": "color" },
{ "text": qsTr("Shapes"), "value": "symbol" }
]
Flow {
id: flow
spacing: 5
width: parent.width
GCComboBox {
id: modeBox
model: availableModes
background: activityConfiguration.background
label: qsTr("Select your mode")
}
}
property var dataToSave
function setDefaultValues() {
if(dataToSave["mode"] === undefined) {
dataToSave["mode"] = "color";
modeBox.currentIndex = 0
}
for(var i = 0 ; i < availableModes.length ; i ++) {
if(availableModes[i].value === dataToSave["mode"]) {
modeBox.currentIndex = i;
break;
}
}
}
function saveValues() {
var newMode = availableModes[modeBox.currentIndex].value;
dataToSave = {"mode": newMode};
}
}
......@@ -33,7 +33,7 @@ Item {
Image {
id: symbol
visible: Activity.mode === "symbol"
visible: items.mode === "symbol"
fillMode: Image.PreserveAspectFit
source: Activity.symbols[root.searchItemIndex]
anchors.left: parent.left
......@@ -44,7 +44,7 @@ Item {
}
Rectangle {
id: symbolHighlighter
visible: (Activity.mode === "symbol") && root.highlightSymbol
visible: (items.mode === "symbol") && root.highlightSymbol
anchors.fill: parent
width: parent.width
height: parent.height
......@@ -55,7 +55,7 @@ Item {
Rectangle {
id: color
visible: Activity.mode === "color"
visible: items.mode === "color"
color: Activity.colors[root.searchItemIndex]
anchors.fill: parent
width: parent.width
......
......@@ -50,7 +50,7 @@ ActivityBase {
}
Component.onCompleted: {
dialogActivityConfig.getInitialConfiguration()
dialogActivityConfig.initialize()
activity.start.connect(start)
activity.stop.connect(stop)
}
......@@ -67,6 +67,7 @@ ActivityBase {
property alias guessModel: guessModel
property alias guessColumn: guessColumn
property alias currentRepeater: currentRepeater
property string mode: "color"
}
onStart: { Activity.start(items) }
......@@ -620,71 +621,29 @@ if (targetY < 0) {
onClose: home()
}
DialogActivityConfig {
DialogChooseLevel {
id: dialogActivityConfig
currentActivity: activity
content: Component {
Item {
property alias modeBox: modeBox
property var availableModes: [
{ "text": qsTr("Colors"), "value": "color" },
{ "text": qsTr("Shapes"), "value": "symbol" }
]
Flow {
id: flow
spacing: 5
width: dialogActivityConfig.width
GCComboBox {
id: modeBox
model: availableModes
background: dialogActivityConfig
label: qsTr("Select your mode")
currentActivity: activity.activityInfo
onClose: {
home()
}
}
}
}
onClose: home()
onLoadData: {
if(dataToSave && dataToSave["mode"]) {
Activity.mode = dataToSave["mode"];
}
}
onSaveData: {
var newMode = dialogActivityConfig.configItem.availableModes[dialogActivityConfig.configItem.modeBox.currentIndex].value;
if (newMode !== Activity.mode) {
chooserGrid.model = new Array();
Activity.mode = newMode;
dataToSave = {"mode": Activity.mode};
Activity.initLevel();
}
}
function setDefaultValues() {
for(var i = 0 ; i < dialogActivityConfig.configItem.availableModes.length ; i ++) {
if(dialogActivityConfig.configItem.availableModes[i].value === Activity.mode) {
dialogActivityConfig.configItem.modeBox.currentIndex = i;
break;
}
if(activityData && activityData["mode"]) {
items.mode = activityData["mode"];
}
}
}
Bar {
id: bar
content: BarEnumContent { value: help | home | level | config }
content: BarEnumContent { value: help | home | level | activityConfig }
onHelpClicked: {
displayDialog(dialogHelp)
}
onPreviousLevelClicked: Activity.previousLevel()
onNextLevelClicked: Activity.nextLevel()
onHomeClicked: activity.home()
onConfigClicked: {
dialogActivityConfig.active = true
// Set default values
dialogActivityConfig.setDefaultValues();
onActivityConfigClicked: {
displayDialog(dialogActivityConfig)
}
}
......
......@@ -53,7 +53,6 @@ var colors = [
"#FF04611a", // dark green
"#FFa0174b", // dark magenta
];
var mode = "color";
var symbols = [
baseUrl + "darkblue_star.svg",
baseUrl + "lightgreen_triangle.svg",
......
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