diff --git a/src/activities/family/Family.qml b/src/activities/family/Family.qml index 410a58fac..d5a4960de 100644 --- a/src/activities/family/Family.qml +++ b/src/activities/family/Family.qml @@ -1,249 +1,263 @@ /* GCompris - family.qml * * Copyright (C) 2016 RAJDEEP KAUR * * Authors: * * RAJDEEP KAUR (Qt Quick port) * * 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 . */ import QtQuick 2.1 import GCompris 1.0 import "../../core" import "family.js" as Activity ActivityBase { id: activity onStart: focus = true onStop: {} pageComponent: Image { id: background anchors.fill: parent source: Activity.url + "back.svg" sourceSize.width: parent.width fillMode: Image.PreserveAspectCrop signal start signal stop 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 nodecreator:nodecreator property alias answerschoice: answerschoice property alias edgecreator: edgecreator } onStart: { Activity.start(items) } onStop: { Activity.stop() } Item { id: partition width: background.width height: background.height Rectangle { id:tree color: "transparent" width: background.width*0.65 height: background.height border.color: "black" border.width: 5 Item { id: treestructure Repeater { id: nodecreator model: ListModel{} delegate: Tree { id: currentpointer x: xx*tree.width y: yy*tree.height width:tree.width/5 height:tree.width/5 recwidth: currentpointer.width recheight: currentpointer.height searchitem: 3 nodeimagesource: Activity.url+nodee nodetextvalue: "sad" bordercolor: "black" borderwidth: 4 colorr: "transparent" radius: recwidth/2 state:currentstate + MouseArea{ + id:nodemousearea + anchors.fill: parent + + } + states : [ State { name:"active" PropertyChanges { target: currentpointer bordercolor:"blue" } }, State { name:"deactive" PropertyChanges { target: currentpointer } + }, + State { + name:"activeto" + PropertyChanges { + target: currentpointer + bordercolor:"red" + } } + ] SequentialAnimation { id: anim - running:currentpointer.state === "active" ? true : false + running:currentpointer.state === "active" ? true : currentpointer.state === "activeto" ? true : false loops: Animation.Infinite alwaysRunToEnd: true NumberAnimation { target: currentpointer property: "rotation" from: 0; to: 10 duration: 200 easing.type: Easing.OutQuad } NumberAnimation { target: currentpointer property: "rotation" from: 10; to: -10 duration: 400 easing.type: Easing.InOutQuad } NumberAnimation { target: currentpointer property: "rotation" from: -10; to: 0 duration: 200 easing.type: Easing.InQuad } } } } Repeater { id:edgecreator model: ListModel{} delegate: Rectangle { id: edge opacity:1 antialiasing: true color:"black" transformOrigin:Item.TopLeft x: x1*tree.width y: y1*tree.height property var x2: x22*tree.width property var y2: y22*tree.height width: Math.sqrt(Math.pow(x - x2, 2) + Math.pow(y- y2, 2)) height: 4 * ApplicationInfo.ratio rotation: (Math.atan((y2 - y)/(x2-x)) * 180 / Math.PI) + (((y2-y) < 0 && (x2-x) < 0) * 180) + (((y2-y) >= 0 && (x2-x) < 0) * 180) Behavior on height { NumberAnimation { duration: 2000 easing.type: Easing.OutExpo } } Behavior on width { NumberAnimation { duration: 2000 easing.type: Easing.OutExpo } } } } } } Rectangle { id: answers color: "transparent" width: background.width*0.35 height: background.height anchors.left: tree.right border.color: "black" border.width: 5 Image { width: parent.width * 0.99 height: parent.height * 0.99 anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter source: Activity.url + "answerarea.svg" Grid { columns: 1 rowSpacing: 20 anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter Repeater { id: answerschoice model: ListModel{} delegate: AnswerButton { id: options width: answers.width*0.80 height: answers.width*0.25 textLabel: optionn onPressed: { if(textLabel === answer){ bonus.good("lion") } else { - bonus.bad("lion") + bonus.bad("lion") } } } } } } } } DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar content: BarEnumContent { value: help | home | level } onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() } Bonus { id: bonus Component.onCompleted: win.connect(Activity.nextLevel) } } } diff --git a/src/activities/family/family.js b/src/activities/family/family.js index 1a155f982..5d9b35577 100644 --- a/src/activities/family/family.js +++ b/src/activities/family/family.js @@ -1,219 +1,235 @@ /* GCompris - family.js * * Copyright (C) 2016 RAJDEEP KAUR * * Authors: * "RAJDEEP KAUR" (Qt Quick port) * * 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 . */ .pragma library .import QtQuick 2.0 as Quick var currentLevel = 0 var items var url = "qrc:/gcompris/src/activities/family/resource/" var treestructure = [ { edgelist:[ [0.41,0.25,0.64,0.25], [0.53,0.25,0.53,0.50] ], nodePositions:[ [0.211,0.20], [0.633,0.20], [0.4,0.50] ], rationn:[80,80,80] }, { edgelist:[ [0.41,0.25,0.64,0.25], [0.53,0.25,0.53,0.50] ], nodePositions:[ [0.211,0.20], [0.633,0.20], [0.4,0.50] ], rationn:[80,80,80] }, { edgelist:[ [0.41,0.25,0.64,0.25], [0.53,0.25,0.44,0.50], [0.53,0.25,0.63,0.50] ], nodePositions:[ [0.211,0.20], [0.633,0.20], [0.33,0.50], [0.55,0.50] ], rationn:[80,80,80] }, + { edgelist:[ [0.41,0.25,0.64,0.25], + [0.53,0.26,0.33,0.50], + [0.53,0.25,0.53,0.50], + [0.53,0.25,0.70,0.52] + ], + nodePositions:[ + [0.211,0.20], + [0.633,0.20], + [0.22,0.50], + [0.43,0.50], + [0.65,0.50] + ], + rationn:[80,80,80] - { edgelist:[[0.41,0.25,0.64,0.25], + }, + + { edgelist:[[0.41,0.25,0.64,0.25], [0.53,0.20,0.44,0.33], [0.53,0.25,0.59,0.33]], nodePositions:[ [0.180,0.09], [0.55,0.09], [0.08,0.35], [0.30,0.35], [0.50,0.35], [0.70,0.35], [0.01,0.65], [.21,0.65], [.41,0.65], [.61,0.65], [.81,0.65] ] - },/* + }, + /* { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodePositions:[] }, { edgelist:[], nodepositions:[] }*/ ] var dataset = [ { nodeleave:["man3.svg","lady2.svg","boy1.svg"], - currentstate:["active","deactive","active"], + currentstate:["active","deactive","activeto"], answer:["Father"], - optionss:["Father","Grandfather","Uncle"] + optionss:[qsTr("Father"),qsTr("Grandfather"),qsTr("Uncle")] }, { nodeleave:["man3.svg","lady2.svg","boy1.svg"], - currentstate:["deactive","active","active",], - answer:["Mother"], - optionss:["Mother","GrandMother","Aunty"] + currentstate:["deactive","active","activeto",], + answer:[qsTr("Mother")], + optionss:[qsTr("Mother"),qsTr("GrandMother"),qsTr("Aunty")] }, { nodeleave:["man3.svg","lady2.svg","boy1.svg","boy2.svg"], - currentstate:["deactive","deactive","active","active"], - answer:["Brother"], - optionss:["Cousin","Brother","Sister"] + currentstate:["deactive","deactive","active","activeto"], + answer:[qsTr("Brother")], + optionss:[qsTr("Cousin"),qsTr("Brother"),qsTr("Sister")] }, - { nodeleave:["grandpa.svg","old-lady.svg","man1.svg","lady2.svg","man2.svg","lady1.svg", - "boy1.svg","boy2.svg","girl2.svg","girl3.svg","girl4.svg"], - answer:["Father"], - optionss:["M"] + { nodeleave:["man3.svg","lady2.svg","boy1.svg","girl1.svg","boy2.svg"], + currentstate:["deactive","deactive","active","activeto","deactive"], + answer:[qsTr("Sister")], + optionss:[qsTr("Cousion"),qsTr("Brother"),qsTr("Sister")] } ] -var numberOfLevel = 3; +var numberOfLevel = 4; var mode = "image"; function start(items_) { items = items_ currentLevel = 0 initLevel() } function stop() { } function initLevel() { items.bar.level = currentLevel + 1 var test = treestructure[currentLevel] var test1 = dataset[currentLevel] items.nodecreator.model.clear(); items.answerschoice.model.clear(); items.edgecreator.model.clear(); for(var i = 0 ; i < test.nodePositions.length; i++){ items.nodecreator.model.append({ "xx": test.nodePositions[i][0], "yy": test.nodePositions[i][1], "nodee": test1.nodeleave[i], "rationn": test.rationn[i], "currentstate":test1.currentstate[i] }); } for(var j = 0;j <3; j++){ items.answerschoice.model.append({ "optionn": test1.optionss[j], "answer":test1.answer[0] }); } for(var k =0 ; k < test.edgelist.length ; k++){ items.edgecreator.model.append({ "x1": test.edgelist[k][0], "y1": test.edgelist[k][1], "x22": test.edgelist[k][2], "y22": test.edgelist[k][3] }); } } function nextLevel() { if(numberOfLevel <= ++currentLevel ) { currentLevel = 0 } initLevel(); } function previousLevel() { if(--currentLevel < 0) { currentLevel = numberOfLevel - 1 } initLevel(); }