Commit 1f616fbd authored by Shubham Mishra's avatar Shubham Mishra Committed by Johnny Jazeix

share, add multiple dataset

parent 7e60bf27
/* GCompris - ActivityConfig.qml
*
* Copyright (C) 2020 Shubham Mishra <shivam828787@gmail.com>
*
* Authors:
* Shubham Mishra <shivam828787@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 bool easyMode: true
width: if(background) background.width
Column {
id: column
spacing: 10
width: parent.width
GCDialogCheckBox {
id: easyModeBox
width: activityConfiguration.width
text: qsTr("Display candy counter")
checked: easyMode // This is available in all editors.
onCheckedChanged: {
easyMode = checked
}
}
}
property var dataToSave
function setDefaultValues() {
if(dataToSave["mode"] === undefined) {
dataToSave["mode"] = "true";
}
easyModeBox.checked = (dataToSave.mode === "true")
}
function saveValues() {
dataToSave = { "mode": "" + easyMode }
}
}
......@@ -36,4 +36,5 @@ ActivityInfo {
credit: ""
section: "math arithmetic"
createdInVersion: 7000
levels :"1,2,3"
}
......@@ -36,7 +36,7 @@ ActivityBase {
signal stop
Component.onCompleted: {
dialogActivityConfig.getInitialConfiguration()
dialogActivityConfig.initialize()
activity.start.connect(start)
activity.stop.connect(stop)
}
......@@ -53,7 +53,6 @@ ActivityBase {
property int nbSubLevel
property alias listModel: listModel
property bool acceptCandy: false
property alias dataset: dataset
property alias girlWidget: girlWidget
property alias boyWidget: boyWidget
property alias candyWidget: candyWidget
......@@ -63,17 +62,13 @@ ActivityBase {
property int totalGirls
property int totalCandies
property int totalChildren: totalBoys + totalGirls
property var levels: activity.datasetLoader.data
property int barHeightAddon: ApplicationSettings.isBarHidden ? 1 : 3
property int cellSize: Math.round(Math.min(background.width / 12, background.height / (11 + barHeightAddon)))
property alias repeaterDropAreas: repeaterDropAreas
property int maxNumberOfCandiesPerWidget: 8
}
Loader {
id: dataset
asynchronous: false
}
onStart: { Activity.start(items) }
onStop: { Activity.stop() }
......@@ -247,9 +242,9 @@ ActivityBase {
Rectangle {
id: leftWidget
width: background.vert ?
items.cellSize * 1.74 : background.width
items.cellSize * 2.04 : background.width
height: background.vert ?
background.height : items.cellSize * 1.74
background.height : items.cellSize * 2.04
color: "#5a9de0"
border.color: "#3f81c4"
border.width: 4
......@@ -287,6 +282,7 @@ ActivityBase {
id: girlWidget
name: "girl"
total: items.totalGirls
visible: items.totalGirls !== 0
current: background.currentGirls
placedInChild: background.placedInGirls
}
......@@ -294,6 +290,7 @@ ActivityBase {
ChildWidget {
id: boyWidget
name: "boy"
visible: items.totalBoys !== 0
total: items.totalBoys
current: background.currentBoys
placedInChild: background.placedInBoys
......@@ -356,40 +353,22 @@ ActivityBase {
}
}
DialogActivityConfig {
DialogChooseLevel {
id: dialogActivityConfig
currentActivity: activity
content: Component {
Item {
height: column.height
Column {
id: column
spacing: 10
width: parent.width
GCDialogCheckBox {
id: easyModeBox
width: dialogActivityConfig.width
text: qsTr("Display candy counter")
checked: background.easyMode
onCheckedChanged: {
background.easyMode = checked
Activity.reloadRandom()
}
}
}
}
currentActivity: activity.activityInfo
onSaveData: {
levelFolder = dialogActivityConfig.chosenLevels
currentActivity.currentLevels = dialogActivityConfig.chosenLevels
ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels)
}
onLoadData: {
if(dataToSave && dataToSave["mode"]) {
background.easyMode = (dataToSave["mode"] === "true");
if(activityData && activityData["mode"]) {
background.easyMode = (activityData["mode"] === "true");
}
}
onSaveData: {
dataToSave = { "mode": "" + background.easyMode }
onStartActivity: {
background.stop();
background.start()
}
onClose: home()
......@@ -403,7 +382,7 @@ ActivityBase {
Bar {
id: bar
content: BarEnumContent { value: help | home | level | reload | config}
content: BarEnumContent { value: help | home | level | reload | activityConfig}
onHelpClicked: {
displayDialog(dialogHelp)
}
......@@ -411,9 +390,8 @@ ActivityBase {
onNextLevelClicked: Activity.nextLevel()
onHomeClicked: activity.home()
onReloadClicked: Activity.reloadRandom()
onConfigClicked: {
dialogActivityConfig.active = true
displayDialog(dialogActivityConfig)
onActivityConfigClicked: {
displayDialog(dialogActivityConfig)
}
}
......
This diff is collapsed.
This diff is collapsed.
/* GCompris - Data.qml
*
* Copyright (C) 2020 Shubham Mishra <email.shivam828787@gmail.com>
*
* Authors:
* shivam828787@gmail.com <email.shivam828787@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 <http://www.gnu.org/licenses/>.
*/
import GCompris 1.0
Data {
objective: qsTr("Maximum 30 candies and 6 kids, possible rest.")
difficulty: 5
data: [
[
{
"randomisedInputData": true,
"maxBoys": 0,
"maxGirls": 4,
"maxCandies": 6,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 10,
"alreadyPlaced": true
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 12,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 16,
"alreadyPlaced": true
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 16,
"alreadyPlaced": false
}
],
[
{
"randomisedInputData": true,
"maxBoys": 0,
"maxGirls": 4,
"maxCandies": 6,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 10,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 14,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 16,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 18,
"alreadyPlaced": false
}
],
[
{
"randomisedInputData": true,
"maxBoys": 0,
"maxGirls": 5,
"maxCandies": 10,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 3,
"maxCandies": 14,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 3,
"maxGirls": 2,
"maxCandies": 18,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 3,
"maxCandies": 22,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 26,
"alreadyPlaced": false
}
],
[
{
"randomisedInputData": true,
"maxBoys": 0,
"maxGirls": 4,
"maxCandies": 10,
"alreadyPlaced": true
},
{
"randomisedInputData": true,
"maxBoys": 2,
"maxGirls": 2,
"maxCandies": 14,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 3,
"maxGirls": 3,
"maxCandies": 18,
"alreadyPlaced": true
},
{
"randomisedInputData": true,
"maxBoys": 3,
"maxGirls": 3,
"maxCandies": 22,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 3,
"maxGirls": 3,
"maxCandies": 26,
"alreadyPlaced": false
}
],
[
{
"randomisedInputData": true,
"maxBoys": 0,
"maxGirls": 6,
"maxCandies": 12,
"alreadyPlaced": true
},
{
"randomisedInputData": true,
"maxBoys": 3,
"maxGirls": 3,
"maxCandies": 16,
"alreadyPlaced": true
},
{
"randomisedInputData": true,
"maxBoys": 3,
"maxGirls": 3,
"maxCandies": 20,
"alreadyPlaced": true
},
{
"randomisedInputData": true,
"maxBoys": 3,
"maxGirls": 3,
"maxCandies": 24,
"alreadyPlaced": false
},
{
"randomisedInputData": true,
"maxBoys": 3,
"maxGirls": 3,
"maxCandies": 30,
"alreadyPlaced": true
}
]
]
}
/* GCompris
*
* Copyright (C) 2016 Stefan Toncu <stefan.toncu29@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
/*
Numbers of kids are given in the left widget which eases kid work.
No rest (basket).
*/
QtObject {
property var levels : [
{
"instruction": qsTr("Paul wants to equally share 2 pieces of candy between 2 of his friends: one girl and one boy. Can you help him? First, place the children in center, then drag the pieces of candy to each of them."),
"totalBoys": 1,
"totalGirls": 1,
"totalCandies": 2,
"showCount": true,
"forceShowBasket": "false",
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("Now he wants to give 4 pieces of candy to his friends."),
"totalBoys": 1,
"totalGirls": 1,
"totalCandies": 4,
"showCount": true,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("Can you now give 6 of Paul's pieces of candy to his friends?"),
"totalBoys": 1,
"totalGirls": 1,
"totalCandies": 6,
"showCount": true,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("Paul has only 10 pieces of candy left. He eats 2 pieces of candy and he gives the rest to his friends. Can you help him equally split the 8 remaining pieces of candy?"),
"totalBoys": 1,
"totalGirls": 1,
"totalCandies": 8,
"showCount": true,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
}
]
}
/* GCompris
*
* Copyright (C) 2016 Stefan Toncu <stefan.toncu29@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
/*
Numbers of kids are given in the left widget which eases kid work.
There is a rest (basket)
*/
QtObject {
property var levels : [
{
"instruction": qsTr("George wants to equally share 3 pieces of candy between 2 of his friends: one girl and one boy. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them. Be careful, a rest will remain!"),
"totalBoys": 1,
"totalGirls": 1,
"totalCandies": 3,
"showCount": true,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("Maria wants to equally share 5 pieces of candy between 3 of her friends: one girl and two boys. Can she equally split the pieces of candy between her friends? First, place the children in center, then drag the pieces of candy to each of them. Be careful, a rest will remain!"),
"totalBoys": 2,
"totalGirls": 1,
"totalCandies": 5,
"showCount": true,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("John wants to equally share 10 pieces of candy between 3 of his friends: one boy and two girls. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them."),
"totalBoys": 1,
"totalGirls": 2,
"totalCandies": 10,
"showCount": true,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
}
]
}
/* GCompris
*
* Copyright (C) 2016 Stefan Toncu <stefan.toncu29@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
/*
Numbers of kids are not given anymore in the left widget which forces kids to understand this part.
No rest (basket).
*/
QtObject {
property var levels : [
{
"instruction": qsTr("Alice wants to equally share 3 pieces of candy between 3 of her friends: one girl and two boys. Can you help her? First, place the children in the center, then drag the pieces of candy to each of them."),
"totalBoys": 2,
"totalGirls": 1,
"totalCandies": 3,
"showCount": false,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("Now, Alice wants to give 6 pieces of candy to her friends"),
"totalBoys": 2,
"totalGirls": 1,
"totalCandies": 6,
"showCount": false,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("Can you help Alice give 9 pieces of candy to her friends: one girl and two boys?"),
"totalBoys": 2,
"totalGirls": 1,
"totalCandies": 9,
"showCount": false,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("Alice has 12 pieces of candy left. She wants to give them all to her friends. Can you help her split the pieces of candy equally?"),
"totalBoys": 2,
"totalGirls": 1,
"totalCandies": 12,
"showCount": false,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
}
]
}
/* GCompris
*
* Copyright (C) 2016 Stefan Toncu <stefan.toncu29@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
/*
Numbers of kids are not given anymore in the left widget.
There is a rest (basket).
*/
QtObject {
property var levels : [
{
"instruction": qsTr("Michael wants to equally share 5 pieces of candy between 2 of his friends: one girl and one boy. Can you help him? First, place the children in center, then drag the pieces of candy to each of them!"),
"totalBoys": 1,
"totalGirls": 1,
"totalCandies": 5,
"showCount": false,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("Helen has 3 friends: one boy and two girls. She wants to give them 7 pieces of candy. Help her split the pieces of candy between her friends!"),
"totalBoys": 1,
"totalGirls": 2,
"totalCandies": 7,
"showCount": false,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0
},
{
"instruction": qsTr("Michelle has 9 pieces of candy and wants to split them with two brothers and two sisters. Help her share the pieces of candy!"),
"totalBoys": 2,
"totalGirls": 2,
"totalCandies": 9,
"showCount": false,
"forceShowBasket": false,
"placedInGirls": 0,
"placedInBoys": 0