Skip to content
Permalink
Browse files
categorization activity
  • Loading branch information
divyam3897 authored and petitlapin committed Jan 23, 2017
1 parent aab769e commit 43ef8edeaa8a72994e861aefaabe22c56d790677
Show file tree
Hide file tree
Showing 222 changed files with 7,306 additions and 0 deletions.
@@ -17,6 +17,7 @@ ballcatch
braille_alphabets
braille_fun
canal_lock
categorization
chess
chess_2players
chess_partyend
@@ -0,0 +1,35 @@
/* GCompris - ActivityInfo.qml
*
* Copyright (C) 2016 Divyam Madaan <divyam3897@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

ActivityInfo {
name: "categorization/Categorization.qml"
difficulty: 4
icon: "categorization/categorization.svg"
author: "Divyam Madaan &lt;divyam3897@gmail.com&gt;"
demo: true
title: qsTr("Categorization")
description: qsTr("Categorize the elements into correct and incorrect groups")
//intro: "Categorize the elements into the correct group"
goal: qsTr("Build conceptual thinking and enrich knowledge")
prerequisite: qsTr("Can drag elements using mouse")
manual: qsTr("Review the instructions and then drag and drop the elements as specified")
credit: ""
section: "fun"
createdInVersion: 8000
}
@@ -0,0 +1 @@
GCOMPRIS_ADD_RCC(activities/categorization *.qml *.svg *.js resource/*.* resource/*/*)
@@ -0,0 +1,225 @@
/* GCompris - categorization.qml
*
* Copyright (C) 2016 Divyam Madaan <divyam3897@gmail.com>
*
* Authors:
* Divyam Madaan <divyam3897@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 QtQuick 2.1
import QtQuick.Controls 1.1
import GCompris 1.0

import "../../core"
import "categorization.js" as Activity
import "qrc:/gcompris/src/core/core.js" as Core
import "."

ActivityBase {
id: activity

onStart: focus = true
onStop: {}

property string boardsUrl: "qrc:/gcompris/src/activities/categorization/resource/"
property bool vert: background.width < background.height

pageComponent: Image {
id: background
source: "qrc:/gcompris/src/activities/lang/resource/imageid-bg.svg"
anchors.fill: parent
sourceSize.width: parent.width
signal start
signal stop

property bool categoriesFallback: (items.categoriesCount == 6) ? true : false

Component.onCompleted: {
activity.start.connect(start)
activity.stop.connect(stop)
}

// Add here the QML items you need to access in javascript
QtObject {
id: items
property Item main: activity.main
property alias background: background
property alias bar: bar
property alias bonus: bonus
property alias categoryReview: categoryReview
property alias menuScreen: menuScreen
property alias menuModel: menuScreen.menuModel
property alias dialogActivityConfig: dialogActivityConfig
property string mode: "easy"
property bool instructionsVisible: true
property bool categoryImageChecked: (mode === "easy" || mode === "medium")
property bool scoreChecked: (mode === "easy")
property bool iAmReadyChecked: (mode === "expert")
property bool displayUpdateDialogAtStart: true
property var details
property alias file: file
property var categoriesCount
}

onStart: {
Activity.init(items, boardsUrl)
dialogActivityConfig.getInitialConfiguration()
Activity.start()
}

onStop: {
dialogActivityConfig.saveDatainConfiguration()
}

MenuScreen {
id: menuScreen

File {
id: file
onError: console.error("File error: " + msg);
}
}

CategoryReview {
id: categoryReview
}

ExclusiveGroup {
id: configOptions
}

DialogActivityConfig {
id: dialogActivityConfig
content: Component {
Column {
id: column
spacing: 5
width: dialogActivityConfig.width
height: dialogActivityConfig.height
property alias easyModeBox: easyModeBox
property alias mediumModeBox: mediumModeBox
property alias expertModeBox: expertModeBox

GCDialogCheckBox {
id: easyModeBox
width: column.width - 50
text: qsTr("Instructions and score visible")
checked: (items.mode == "easy") ? true : false
exclusiveGroup: configOptions
onCheckedChanged: {
if(easyModeBox.checked) {
items.mode = "easy"
menuScreen.iAmReady.visible = false
}
}
}

GCDialogCheckBox {
id: mediumModeBox
width: easyModeBox.width
text: qsTr("Instructions visible and score invisible")
checked: (items.mode == "medium") ? true : false
exclusiveGroup: configOptions
onCheckedChanged: {
if(mediumModeBox.checked) {
items.mode = "medium"
menuScreen.iAmReady.visible = false
}
}
}

GCDialogCheckBox {
id: expertModeBox
width: easyModeBox.width
text: qsTr("Instructions and score invisible")
checked: (items.mode == "expert") ? true : false
exclusiveGroup: configOptions
onCheckedChanged: {
if(expertModeBox.checked) {
items.mode = "expert"
menuScreen.iAmReady.visible = true
}
}
}
}
}
onLoadData: {
if(dataToSave && dataToSave["mode"])
items.mode = dataToSave["mode"]
if(dataToSave && dataToSave["displayUpdateDialogAtStart"])
items.displayUpdateDialogAtStart = (dataToSave["displayUpdateDialogAtStart"] == "true") ? true : false
}

onSaveData: {
dataToSave["data"] = Activity.categoriesToSavedProperties(dataToSave)
dataToSave["mode"] = items.mode
dataToSave["displayUpdateDialogAtStart"] = items.displayUpdateDialogAtStart ? "true" : "false"
}
onClose: home()
}

DialogHelp {
id: dialogHelp
onClose: home()
}

Bar {
id: bar
content: menuScreen.started ? withConfig : withoutConfig
property BarEnumContent withConfig: BarEnumContent { value: help | home | config }
property BarEnumContent withoutConfig: BarEnumContent { value: home | level }
onPreviousLevelClicked: Activity.previousLevel()
onNextLevelClicked: Activity.nextLevel()
onHelpClicked: {
displayDialog(dialogHelp)
}
onHomeClicked: {
if(items.menuScreen.started)
activity.home()
else if(items.categoryReview.started)
Activity.launchMenuScreen()
}
onConfigClicked: {
dialogActivityConfig.active = true
displayDialog(dialogActivityConfig)
}
}

Bonus {
id: bonus
Component.onCompleted: win.connect(Activity.nextLevel)
}

Loader {
id: categoriesFallbackDialog
sourceComponent: GCDialog {
parent: activity.main
message: qsTr("You don't have all the images for this activity. " +
"Press Update to get the complete dataset. " +
"Press the Cross to play with demo version or 'Never show this dialog later' if you want to never see again this dialog.")
button1Text: qsTr("Update the image set")
button2Text: qsTr("Never show this dialog later")
onClose: background.categoriesFallback = false
onButton1Hit: DownloadManager.downloadResource('data2/words/words.rcc')
onButton2Hit: { items.displayUpdateDialogAtStart = false; dialogActivityConfig.saveDatainConfiguration() }
}
anchors.fill: parent
focus: true
active: background.categoriesFallback && items.displayUpdateDialogAtStart
onStatusChanged: if (status == Loader.Ready) item.start()
}
}
}

0 comments on commit 43ef8ed

Please sign in to comment.