Commit 3cdb223d authored by Shubham Mishra's avatar Shubham Mishra Committed by Johnny Jazeix

number_sequence, drawletters, drawnumbers, clickanddraw, move config to...

number_sequence, drawletters, drawnumbers, clickanddraw, move config to activityconfig (multiple dataset style)
parent 2a1d62b5
/* 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 alias modeBox: modeBox
width: if(background) background.width
property var availableModes: [
{ "text": qsTr("Automatic"), "value": 1 },
{ "text": qsTr("Manual"), "value": 2 }
]
Flow {
id: flow
spacing: 5
width: parent.width
GCComboBox {
id: modeBox
model: availableModes
background: activityConfiguration.background
label: qsTr("Go to next level")
}
}
property var dataToSave
function setDefaultValues() {
if(dataToSave["mode"] === undefined) {
dataToSave["mode"] = 1;
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};
}
}
/* 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 alias modeBox: modeBox
width: if(background) background.width
property var availableModes: [
{ "text": qsTr("Automatic"), "value": 1 },
{ "text": qsTr("Manual"), "value": 2 }
]
Flow {
id: flow
spacing: 5
width: parent.width
GCComboBox {
id: modeBox
model: availableModes
background: activityConfiguration.background
label: qsTr("Go to next level")
}
}
property var dataToSave
function setDefaultValues() {
if(dataToSave["mode"] === undefined) {
dataToSave["mode"] = 1;
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};
}
}
/* 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 alias modeBox: modeBox
width: if(background) background.width
property var availableModes: [
{ "text": qsTr("Automatic"), "value": 1 },
{ "text": qsTr("Manual"), "value": 2 }
]
Flow {
id: flow
spacing: 5
width: parent.width
GCComboBox {
id: modeBox
model: availableModes
background: activityConfiguration.background
label: qsTr("Go to next level")
}
}
property var dataToSave
function setDefaultValues() {
if(dataToSave["mode"] === undefined) {
dataToSave["mode"] = 1;
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};
}
}
/* 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 alias modeBox: modeBox
width: if(background) background.width
property var availableModes: [
{ "text": qsTr("Automatic"), "value": 1 },
{ "text": qsTr("Manual"), "value": 2 }
]
Flow {
id: flow
spacing: 5
width: parent.width
GCComboBox {
id: modeBox
model: availableModes
background: activityConfiguration.background
label: qsTr("Go to next level")
}
}
property var dataToSave
function setDefaultValues() {
if(dataToSave["mode"] === undefined) {
dataToSave["mode"] = 1;
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};
}
}
......@@ -46,7 +46,7 @@ ActivityBase {
signal stop
Component.onCompleted: {
dialogActivityConfig.getInitialConfiguration()
dialogActivityConfig.initialize()
activity.start.connect(start)
activity.stop.connect(stop)
}
......@@ -65,7 +65,7 @@ ActivityBase {
property alias imageBack: imageBack
property alias imageBack2: imageBack2
property int pointIndexToClick
property int mode: 1
property int mode: 1 // default is automatic
}
onStart: { Activity.start(items,mode,dataset,url) }
......@@ -246,82 +246,40 @@ ActivityBase {
onClose: home()
}
DialogActivityConfig {
DialogChooseLevel {
id: dialogActivityConfig
currentActivity: activity
content: Component {
Item {
property alias modeBox: modeBox
property var availableModes: [
{ "text": qsTr("Automatic"), "value": 1 },
{ "text": qsTr("Manual"), "value": 2 }
]
Flow {
id: flow
spacing: 5
width: dialogActivityConfig.width
GCComboBox {
id: modeBox
model: availableModes
background: dialogActivityConfig
label: qsTr("Go to next level")
}
}
}
}
currentActivity: activity.activityInfo
onClose: home()
onLoadData: {
if(dataToSave && dataToSave["mode"]) {
items.mode = dataToSave["mode"];
if(activityData && activityData["mode"]) {
items.mode = activityData["mode"];
}
}
onSaveData: {
var newMode = dialogActivityConfig.configItem.availableModes[dialogActivityConfig.configItem.modeBox.currentIndex].value;
if (newMode !== items.mode) {
items.mode = newMode;
dataToSave = {"mode": items.mode};
}
if (items.mode == 1) {
bonus.win.connect(Activity.nextLevel)
} else {
bonus.win.disconnect(Activity.nextLevel)
}
Activity.initLevel();
}
function setDefaultValues() {
for(var i = 0 ; i < dialogActivityConfig.configItem.availableModes.length ; i++) {
if(dialogActivityConfig.configItem.availableModes[i].value === items.mode) {
dialogActivityConfig.configItem.modeBox.currentIndex = i;
break;
}
}
onStartActivity: {
background.stop()
background.start()
}
}
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)
}
}
Bonus {
id: bonus
Component.onCompleted: items.mode == 1 ? win.connect(Activity.nextLevel) : win.disconnect(Activity.nextLevel)
onWin: if(items.mode == 1) Activity.nextLevel();
}
}
}
......@@ -50,6 +50,7 @@ function stop() {
function initLevel() {
items.bar.level = currentLevel + 1
items.pointIndexToClick = 0
reset()
loadCoordinates()
loadBackgroundImage()
if(mode == "drawletters" || mode == "drawnumbers") {
......@@ -80,6 +81,13 @@ function playLetterSound(sound) {
items.audioVoices.append(sound)
}
function reset() {
for(var i = 0; i < items.pointImageRepeater.count; i++)
items.pointImageRepeater.itemAt(i).highlight = false;
for(var i = 0; i < items.segmentsRepeater.count; i++)
items.segmentsRepeater.itemAt(i).opacity = 0
}
function drawSegment(pointIndex) {
if (pointIndex == items.pointIndexToClick) {
......
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