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 { ...@@ -64,7 +64,7 @@ ActivityBase {
property alias nodesRepeater: nodesRepeater property alias nodesRepeater: nodesRepeater
property alias edgesRepeater: edgesRepeater property alias edgesRepeater: edgesRepeater
property alias chooserGrid: chooserGrid property alias chooserGrid: chooserGrid
property string mode property string mode: "color"
} }
onStart: { Activity.start(items) } 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 { ...@@ -33,7 +33,7 @@ Item {
Image { Image {
id: symbol id: symbol
visible: Activity.mode === "symbol" visible: items.mode === "symbol"
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
source: Activity.symbols[root.searchItemIndex] source: Activity.symbols[root.searchItemIndex]
anchors.left: parent.left anchors.left: parent.left
...@@ -44,7 +44,7 @@ Item { ...@@ -44,7 +44,7 @@ Item {
} }
Rectangle { Rectangle {
id: symbolHighlighter id: symbolHighlighter
visible: (Activity.mode === "symbol") && root.highlightSymbol visible: (items.mode === "symbol") && root.highlightSymbol
anchors.fill: parent anchors.fill: parent
width: parent.width width: parent.width
height: parent.height height: parent.height
...@@ -55,7 +55,7 @@ Item { ...@@ -55,7 +55,7 @@ Item {
Rectangle { Rectangle {
id: color id: color
visible: Activity.mode === "color" visible: items.mode === "color"
color: Activity.colors[root.searchItemIndex] color: Activity.colors[root.searchItemIndex]
anchors.fill: parent anchors.fill: parent
width: parent.width width: parent.width
......
...@@ -50,7 +50,7 @@ ActivityBase { ...@@ -50,7 +50,7 @@ ActivityBase {
} }
Component.onCompleted: { Component.onCompleted: {
dialogActivityConfig.getInitialConfiguration() dialogActivityConfig.initialize()
activity.start.connect(start) activity.start.connect(start)
activity.stop.connect(stop) activity.stop.connect(stop)
} }
...@@ -67,6 +67,7 @@ ActivityBase { ...@@ -67,6 +67,7 @@ ActivityBase {
property alias guessModel: guessModel property alias guessModel: guessModel
property alias guessColumn: guessColumn property alias guessColumn: guessColumn
property alias currentRepeater: currentRepeater property alias currentRepeater: currentRepeater
property string mode: "color"
} }
onStart: { Activity.start(items) } onStart: { Activity.start(items) }
...@@ -620,71 +621,29 @@ if (targetY < 0) { ...@@ -620,71 +621,29 @@ if (targetY < 0) {
onClose: home() onClose: home()
} }
DialogActivityConfig { DialogChooseLevel {
id: dialogActivityConfig id: dialogActivityConfig
currentActivity: activity currentActivity: activity.activityInfo
content: Component { onClose: {
Item { home()
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")
}
}
}
} }
onClose: home()
onLoadData: { onLoadData: {
if(dataToSave && dataToSave["mode"]) { if(activityData && activityData["mode"]) {
Activity.mode = dataToSave["mode"]; items.mode = activityData["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;
}
} }
} }
} }
Bar { Bar {
id: bar id: bar
content: BarEnumContent { value: help | home | level | config } content: BarEnumContent { value: help | home | level | activityConfig }
onHelpClicked: { onHelpClicked: {
displayDialog(dialogHelp) displayDialog(dialogHelp)
} }
onPreviousLevelClicked: Activity.previousLevel() onPreviousLevelClicked: Activity.previousLevel()
onNextLevelClicked: Activity.nextLevel() onNextLevelClicked: Activity.nextLevel()
onHomeClicked: activity.home() onHomeClicked: activity.home()
onConfigClicked: { onActivityConfigClicked: {
dialogActivityConfig.active = true
// Set default values
dialogActivityConfig.setDefaultValues();
displayDialog(dialogActivityConfig) displayDialog(dialogActivityConfig)
} }
} }
......
...@@ -53,7 +53,6 @@ var colors = [ ...@@ -53,7 +53,6 @@ var colors = [
"#FF04611a", // dark green "#FF04611a", // dark green
"#FFa0174b", // dark magenta "#FFa0174b", // dark magenta
]; ];
var mode = "color";
var symbols = [ var symbols = [
baseUrl + "darkblue_star.svg", baseUrl + "darkblue_star.svg",
baseUrl + "lightgreen_triangle.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