diff --git a/src/activities/family/Dataset.qml b/src/activities/family/Dataset.qml index e985aec78..ea8ee6707 100644 --- a/src/activities/family/Dataset.qml +++ b/src/activities/family/Dataset.qml @@ -1,576 +1,576 @@ /* GCompris - Dataset.qml * * Copyright (C) RUDRA NIL BASU (Qt Quick port) * * Authors: * Holger Kaelberer * RUDRA NIL BASU (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.6 QtObject { property real nodeWidth: background.nodeWidthRatio property real nodeHeight: background.nodeHeightRatio /* * Vertically, the screen is divided into three parts: * gen1: stands for Generation 1 * gen2: stands for Generation 2 * gen3: stands for Generation 3 */ readonly property real gen1: 0.10 readonly property real gen2: 0.40 readonly property real gen3: 0.70 /* * Horizontally, the screen is divided into left, center * and right */ readonly property real left: 0.2 readonly property real center: 0.4 readonly property real right: 0.6 /* * ext: exterior * int: interior */ readonly property real leftExt: 0.1 readonly property real leftInt: 0.3 readonly property real rightInt: 0.5 readonly property real rightExt: 0.7 /* * pairs are used to determine the correct * pair for a given relation in the family_find_relative * activity * A correct pair is formed by selecting a node of type * "pair1" and "pair2" only */ readonly property int pair1: -1 readonly property int pair2: 1 readonly property int noPair: 0 function rightXEdge(xPosition) { /* * Returns the x coordinate of the * right edge of a node */ return xPosition + nodeWidth } function nodeMidPointY(yPosition) { /* * Returns the y coordinate of the * midpoint of a node */ return yPosition + nodeHeight / 2 } function nodeMidPointX(xLeftPosition, xRightPosition) { /* * Returns the x coordinate of the * midpoint of two nodes */ return ((xLeftPosition + nodeWidth) + xRightPosition) / 2 } property var levelElements: [ // level 1 { edgeList: [ [left + nodeWidth, gen1 + nodeHeight / 2, right, gen1 + nodeHeight / 2], [((left + nodeWidth) + right) / 2, gen1 + nodeHeight / 2, ((left + nodeWidth) + right) / 2, gen2] ], nodePositions: [ [left, gen1], [right, gen1], [center, gen2] ], captions: [ [center - (nodeWidth * 3 / 4), gen2 + nodeHeight / 2], [left - nodeWidth / 2, gen1] ], nodeValue: ["man3.svg", "lady2.svg", "boy1.svg"], nodeWeights: [pair1, noPair, pair2], currentState: ["activeTo", "deactive", "active"], edgeState:["married","others"], answer: [qsTr("Father")], options: [qsTr("Father"), qsTr("Grandfather"), qsTr("Uncle")] }, // level 2 { edgeList: [ [left + nodeWidth, gen1 + nodeHeight / 2, right, gen1 + nodeHeight / 2], [((left + nodeWidth) + right) / 2, gen1 + nodeHeight / 2, ((left + nodeWidth) + right) / 2, gen2] ], nodePositions: [ [left, gen1], [right, gen1], [center, gen2] ], captions: [ [center - (nodeWidth * 3 / 4), gen2 + nodeHeight / 2], [right + nodeWidth, gen1] ], nodeValue: ["man3.svg", "lady2.svg", "boy1.svg"], nodeWeights: [noPair, pair1, pair2], currentState: ["deactive", "activeTo", "active"], edgeState:["married","others"], answer: [qsTr("Mother")], options: [qsTr("Mother"), qsTr("Grandmother"), qsTr("Aunt")] }, // level 3 { edgeList: [ [rightXEdge(left), nodeMidPointY(gen1), right, nodeMidPointY(gen1)], [nodeMidPointX(left, right), nodeMidPointY(gen1), nodeMidPointX(left, right), gen2 - nodeHeight / 4], [left + nodeWidth / 2, gen2 - nodeHeight / 4, right + nodeWidth / 2, gen2 - nodeHeight / 4], [left + nodeWidth / 2, gen2 - nodeHeight / 4, left + nodeWidth / 2, gen2], [right + nodeWidth / 2, gen2 - nodeHeight / 4, right + nodeWidth / 2, gen2] ], nodePositions: [ [left, gen1], [right, gen1], [left, gen2], [right, gen2] ], captions:[ [left - (nodeWidth * 3 / 4), gen2 + nodeHeight / 2], [right + nodeWidth, gen2] ], nodeValue: ["man3.svg", "lady2.svg", "boy1.svg", "boy2.svg"], nodeWeights: [noPair, noPair, pair1, pair2], currentState: ["deactive", "deactive", "active", "activeTo"], edgeState:["married","others","others","others"], answer: [qsTr("Brother")], options: [qsTr("Cousin"), qsTr("Brother"), qsTr("Sister")] }, // level 4 { edgeList: [ [rightXEdge(left), nodeMidPointY(gen1), right, nodeMidPointY(gen1)], [nodeMidPointX(left, right), nodeMidPointY(gen1), nodeMidPointX(left, right), gen2 - nodeHeight / 4], [left + nodeWidth / 2, gen2 - nodeHeight / 4, right + nodeWidth / 2, gen2 - nodeHeight / 4], [left + nodeWidth / 2, gen2 - nodeHeight / 4, left + nodeWidth / 2, gen2], [center + nodeWidth / 2, gen2 - nodeHeight / 4, center + nodeWidth / 2, gen2], [right + nodeWidth / 2, gen2 - nodeHeight / 4, right + nodeWidth / 2, gen2] ], nodePositions: [ [left, gen1], [right, gen1], [left, gen2], [center, gen2], [right, gen2] ], captions: [ [left - (nodeWidth * 3 / 4), gen2 + nodeHeight / 2], [center + nodeWidth / 2, (gen2 + nodeHeight)] ], nodeValue: ["man3.svg", "lady2.svg", "boy1.svg", "girl1.svg", "boy2.svg"], nodeWeights: [noPair, noPair, pair1, pair2, pair1], currentState: ["deactive", "deactive", "active", "activeTo", "deactive"], edgeState:["married", "others", "others", "others", "others", "others"], answer: [qsTr("Sister")], options: [qsTr("Cousin"), qsTr("Brother"), qsTr("Sister")] }, // level 5 { edgeList: [ [leftExt + nodeWidth, gen1 + nodeHeight / 2, rightInt, gen1 + nodeHeight / 2], [((leftExt + nodeWidth) + rightInt) / 2, gen1 + nodeHeight / 2, ((leftExt + nodeWidth) + rightInt) / 2, gen2], [leftInt + nodeWidth, gen2 + nodeHeight / 2, right, gen2 + nodeHeight / 2], [((leftInt + nodeWidth) + right) / 2, gen2 + nodeHeight / 2, ((leftInt + nodeWidth) + right) / 2, gen3 - nodeWidth / 4], [left + nodeWidth / 2, gen3 - nodeWidth / 4, right + nodeWidth / 2, gen3 - nodeWidth / 4], [left + nodeWidth / 2, gen3 - nodeWidth / 4, left + nodeWidth / 2, gen3], [center + nodeWidth / 2, gen3 - nodeWidth / 4, center + nodeWidth / 2, gen3], [right + nodeWidth / 2, gen3 - nodeWidth / 4, right + nodeWidth / 2, gen3] ], nodePositions: [ [leftExt, gen1], [rightInt, gen1], [leftInt, gen2], [right, gen2], [left, gen3], [center, gen3], [right, gen3] ], captions: [ [leftExt, gen3 + nodeHeight / 4], [leftExt, gen1 + nodeHeight] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man2.svg", "lady1.svg", "girl1.svg", "boy1.svg", "boy2.svg"], nodeWeights: [pair1, noPair, noPair, noPair, pair2, pair2, pair2], currentState: ["activeTo", "deactive", "deactive", "deactive", "active", "deactive", "deactive"], edgeState:["married","others","married","others","others","others","others","others" ], answer: [qsTr("Grandfather")], options: [qsTr("Granddaughter"), qsTr("Grandson"), qsTr("Grandfather"), qsTr("Grandmother")] }, // level 6 { edgeList: [ [leftExt + nodeWidth, gen1 + nodeHeight / 2, rightInt, gen1 + nodeHeight / 2], [((leftExt + nodeWidth) + rightInt) / 2, gen1 + nodeHeight / 2, ((leftExt + nodeWidth) + rightInt) / 2, gen2], [leftInt + nodeWidth, gen2 + nodeHeight / 2, right, gen2 + nodeHeight / 2], [((leftInt + nodeWidth) + right) / 2, gen2 + nodeHeight / 2, ((leftInt + nodeWidth) + right) / 2, gen3 - nodeWidth / 4], [left + nodeWidth / 2, gen3 - nodeWidth / 4, right + nodeWidth / 2, gen3 - nodeWidth / 4], [left + nodeWidth / 2, gen3 - nodeWidth / 4, left + nodeWidth / 2, gen3], [center + nodeWidth / 2, gen3 - nodeWidth / 4, center + nodeWidth / 2, gen3], [right + nodeWidth / 2, gen3 - nodeWidth / 4, right + nodeWidth / 2, gen3] ], nodePositions: [ [leftExt, gen1], [rightInt, gen1], [leftInt, gen2], [right, gen2], [left, gen3], [center, gen3], [right, gen3] ], captions: [ [right + nodeWidth, gen3 + (nodeHeight * 3 / 4)], [rightInt, gen1 + nodeHeight] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man2.svg", "lady1.svg", "boy1.svg", "girl1.svg", "boy2.svg"], nodeWeights: [noPair, pair1, noPair, noPair, pair2, pair2, pair2], currentState: ["deactive", "activeTo", "deactive", "deactive", "deactive", "deactive", "active", "active"], edgeState:["married","others","married","others","others","others","others","others" ], answer: [qsTr("Grandmother")], options: [qsTr("Granddaughter"), qsTr("Grandson"), qsTr("Grandfather"), qsTr("Grandmother")], }, // level 7 { edgeList: [ [leftExt + nodeWidth, gen1 + nodeHeight / 2, rightInt, gen1 + nodeHeight / 2], [((leftExt + nodeWidth) + rightInt) / 2, gen1 + nodeHeight / 2, ((leftExt + nodeWidth) + rightInt) / 2, gen2], [leftInt + nodeWidth, gen2 + nodeHeight / 2, right, gen2 + nodeHeight / 2], [((leftInt + nodeWidth) + right) / 2, gen2 + nodeHeight / 2, ((leftInt + nodeWidth) + right) / 2, gen3 - nodeWidth / 4], [left + nodeWidth / 2, gen3 - nodeWidth / 4, right + nodeWidth / 2, gen3 - nodeWidth / 4], [left + nodeWidth / 2, gen3 - nodeWidth / 4, left + nodeWidth / 2, gen3], [center + nodeWidth / 2, gen3 - nodeWidth / 4, center + nodeWidth / 2, gen3], [right + nodeWidth / 2, gen3 - nodeWidth / 4, right + nodeWidth / 2, gen3] ], nodePositions: [ [leftExt, gen1], [rightInt, gen1], [leftInt, gen2], [right, gen2], [left, gen3], [center, gen3], [right, gen3] ], captions: [ [leftExt + nodeWidth, gen1], [right + nodeWidth, gen3] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man2.svg", "lady1.svg", "boy1.svg", "boy2.svg","girl1.svg" ], nodeWeights: [pair1, pair1, noPair, noPair, noPair, noPair, pair2], currentState: ["active", "deactive", "deactive", "deactive", "deactive", "deactive", "activeTo"], edgeState:["married","others","married","others","others","others","others","others" ], answer: [qsTr("Granddaughter")], options: [qsTr("Granddaughter"), qsTr("Grandson"), qsTr("Grandfather"), qsTr("Grandmother")] }, // level 8 { edgeList: [ [leftExt + nodeWidth, gen1 + nodeHeight / 2, rightInt, gen1 + nodeHeight / 2], [((leftExt + nodeWidth) + rightInt) / 2, gen1 + nodeHeight / 2, ((leftExt + nodeWidth) + rightInt) / 2, gen2], [leftInt + nodeWidth, gen2 + nodeHeight / 2, right, gen2 + nodeHeight / 2], [((leftInt + nodeWidth) + right) / 2, gen2 + nodeHeight / 2, ((leftInt + nodeWidth) + right) / 2, gen3 - nodeWidth / 4], [left + nodeWidth / 2, gen3 - nodeWidth / 4, right + nodeWidth / 2, gen3 - nodeWidth / 4], [left + nodeWidth / 2, gen3 - nodeWidth / 4, left + nodeWidth / 2, gen3], [center + nodeWidth / 2, gen3 - nodeWidth / 4, center + nodeWidth / 2, gen3], [right + nodeWidth / 2, gen3 - nodeWidth / 4, right + nodeWidth / 2, gen3] ], nodePositions: [ [leftExt, gen1], [rightInt, gen1], [leftInt, gen2], [right, gen2], [left, gen3], [center, gen3], [right, gen3] ], captions: [ [rightInt + nodeWidth, gen1], [right + nodeWidth, gen3] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man2.svg", "lady1.svg", "boy1.svg", "girl1.svg", "boy2.svg"], nodeWeights: [pair1, pair1, noPair, noPair, pair2, noPair, pair2], currentState: ["deactive", "active", "deactive", "deactive", "deactive", "deactive", "activeTo", "active"], edgeState:["married","others","married","others","others","others","others","others" ], answer: [qsTr("Grandson")], options: [qsTr("Granddaughter"), qsTr("Grandson"), qsTr("Grandfather"), qsTr("Grandmother")] }, // level 9 { edgeList: [ [center + nodeWidth / 2, gen1 + nodeHeight, center + nodeWidth / 2, gen2 + nodeHeight / 2], [rightXEdge(left), nodeMidPointY(gen2), right, nodeMidPointY(gen2)], [left + nodeWidth / 2, gen2 + nodeHeight, left + nodeWidth / 2, gen3], [right + nodeWidth / 2, gen2 + nodeHeight, right + nodeWidth / 2, gen3] ], nodePositions: [ [center, gen1], [left, gen2], [right, gen2], [left, gen3], [right, gen3] ], captions: [ [(right + nodeWidth * 1.1), gen3 + nodeHeight / 4], [left - nodeWidth / 2, gen3 + nodeHeight / 4] ], nodeValue: ["grandfather.svg", "man3.svg", "man2.svg", "boy1.svg","boy2.svg"], nodeWeights: [noPair, noPair, noPair, pair2, pair1], currentState: ["deactive", "deactive", "deactive", "activeTo","active"], edgeState:["others","others","others","others"], answer: [qsTr("Cousin")], options: [qsTr("Brother"), qsTr("Sister"), qsTr("Cousin")] }, // level 10 { edgeList: [ [center + nodeWidth / 2, gen1 + nodeHeight, center + nodeWidth / 2, gen2 + nodeHeight / 2], [rightXEdge(left), nodeMidPointY(gen2), right, nodeMidPointY(gen2)], [left + nodeWidth / 2, gen2 + nodeHeight, left + nodeWidth / 2, gen3] ], nodePositions: [ [center, gen1], [left, gen2], [right, gen2], [left, gen3] ], captions: [ [left - nodeWidth * 3 / 4, gen3 + nodeHeight / 4], [right + nodeWidth * 1.1, gen2 + nodeHeight / 4] ], nodeValue: ["grandfather.svg", "man3.svg", "man2.svg", "boy1.svg"], nodeWeights: [noPair, noPair, pair1, pair2], currentState: ["deactive", "deactive", "activeTo", "active"], edgeState:["others","others","others"], answer: [qsTr("Uncle")], options: [qsTr("Uncle"), qsTr("Aunt"), qsTr("Nephew"), qsTr("Niece")] }, // level 11 { edgeList: [ [center + nodeWidth / 2, gen1 + nodeHeight, center + nodeWidth / 2, gen2 + nodeHeight / 2], [rightXEdge(left), nodeMidPointY(gen2), right, nodeMidPointY(gen2)], [left + nodeWidth / 2, gen2 + nodeHeight, left + nodeWidth / 2, gen3] ], nodePositions: [ [center, gen1], [left, gen2], [right, gen2], [left, gen3] ], captions: [ [right + nodeWidth * 1.1, gen2 + nodeHeight / 4], [left - nodeWidth * 3 / 4, gen3 + nodeHeight / 4] ], nodeValue: ["grandfather.svg", "man3.svg", "man2.svg", "boy1.svg"], nodeWeights: [noPair, noPair, pair2, pair1], currentState: ["deactive", "deactive", "active", "activeTo"], edgeState:["others","others","others"], answer: [qsTr("Nephew")], options: [qsTr("Uncle"), qsTr("Aunt"), qsTr("Nephew"), qsTr("Niece")] }, // level 12 { edgeList: [ [rightXEdge(left), gen1 + nodeHeight / 2, right, gen1 + nodeHeight / 2], [nodeMidPointX(left, right), nodeMidPointY(gen1), nodeMidPointX(left, right), nodeMidPointY(gen2)], [rightXEdge(left), nodeMidPointY(gen2), right, nodeMidPointY(gen2)], [left + nodeWidth / 2, gen2 + nodeHeight, left + nodeWidth / 2, gen3] ], nodePositions: [ [left, gen1], [right, gen1], [left, gen2], [right, gen2], [left, gen3] ], captions: [ [left - nodeWidth * 3 / 4, gen3 + nodeHeight / 4], [right + nodeWidth * 1.1, gen2 + nodeHeight / 4] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man3.svg", "lady1.svg", "babyboy.svg"], nodeWeights: [noPair, noPair, noPair, pair1, pair2], currentState: ["deactive", "deactive", "deactive", "activeTo", "active"], edgeState:["married","others","siblings","others","others","others"], answer: [qsTr("Aunt")], options: [qsTr("Uncle"), qsTr("Aunt"), qsTr("Nephew"), qsTr("Niece")] }, // level 13 { edgeList: [ [rightXEdge(left), gen1 + nodeHeight / 2, right, gen1 + nodeHeight / 2], [nodeMidPointX(left, right), nodeMidPointY(gen1), nodeMidPointX(left, right), nodeMidPointY(gen2)], [rightXEdge(left), nodeMidPointY(gen2), right, nodeMidPointY(gen2)], [left + nodeWidth / 2, gen2 + nodeHeight, left + nodeWidth / 2, gen3] ], nodePositions: [ [left, gen1], [right, gen1], [left, gen2], [right, gen2], [left, gen3] ], captions: [ [right + nodeWidth * 1.1, gen2 + nodeHeight / 4], [left - nodeWidth / 2, gen3 + nodeHeight / 4] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man3.svg", "lady1.svg", "babygirl.svg"], nodeWeights: [noPair, noPair, noPair, pair2, pair1], currentState: ["deactive", "deactive", "deactive", "active", "activeTo"], edgeState:["married","others","siblings","others","others","others"], answer: [qsTr("Niece")], options: [qsTr("Uncle"), qsTr("Aunt"), qsTr("Nephew"), qsTr("Niece")] }, // level 14 { edgeList: [ [rightXEdge(center), nodeMidPointY(gen1), rightExt, nodeMidPointY(gen1)], [nodeMidPointX(center, rightExt), nodeMidPointY(gen1), nodeMidPointX(center, rightExt), nodeMidPointY(gen2)], [rightXEdge(center), nodeMidPointY(gen2), rightExt, nodeMidPointY(gen2)], [rightXEdge(leftExt), nodeMidPointY(gen2), center, nodeMidPointY(gen2)] ], nodePositions: [ [center, gen1], [rightExt, gen1], [center, gen2], [rightExt, gen2], [leftExt, gen2] ], captions: [ [leftExt - nodeWidth / 2, gen2 + nodeHeight * 3 / 4], [center - nodeWidth * 3 / 4, gen1 + nodeHeight / 4] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man3.svg", "man1.svg", "lady2.svg"], nodeWeights: [pair1, noPair, noPair, noPair, pair2], currentState: ["activeTo", "deactive", "deactive", "deactive", "active"], edgeState:["married","others","others","married"], answer: [qsTr("Father-in-law")], options: [qsTr("Father-in-law"), qsTr("Mother-in-law"), qsTr("Sister-in-law"), qsTr("Brother-in-law"), qsTr("Daughter-in-law")] }, // level 15 { edgeList: [ [rightXEdge(center), nodeMidPointY(gen1), rightExt, nodeMidPointY(gen1)], [nodeMidPointX(center, rightExt), nodeMidPointY(gen1), nodeMidPointX(center, rightExt), nodeMidPointY(gen2)], [rightXEdge(center), nodeMidPointY(gen2), rightExt, nodeMidPointY(gen2)], [rightXEdge(leftExt), nodeMidPointY(gen2), center, nodeMidPointY(gen2)] ], nodePositions: [ [center, gen1], [rightExt, gen1], [center, gen2], [rightExt, gen2], [leftExt, gen2] ], captions: [ [leftExt - nodeWidth / 2, gen2 + nodeHeight * 3 / 4], [rightExt + nodeWidth * 1.1, gen1 + nodeHeight / 4] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man3.svg", "man1.svg", "lady2.svg"], nodeWeights: [noPair, pair1, noPair, noPair, pair2], currentState: ["deactive", "activeTo", "deactive", "deactive", "active"], edgeState:["married","others","others","married","others"], answer: [qsTr("Mother-in-law")], options: [qsTr("Father-in-law"), qsTr("Mother-in-law"), qsTr("Sister-in-law"), qsTr("Brother-in-law"), qsTr("Daughter-in-law")] }, // level 16 { edgeList: [ [rightXEdge(center), nodeMidPointY(gen1), rightExt, nodeMidPointY(gen1)], [nodeMidPointX(center, rightExt), nodeMidPointY(gen1), nodeMidPointX(center, rightExt), nodeMidPointY(gen2)], [rightXEdge(center), nodeMidPointY(gen2), rightExt, nodeMidPointY(gen2)], [rightXEdge(leftExt), nodeMidPointY(gen2), center, nodeMidPointY(gen2)] ], nodePositions: [ [center, gen1], [rightExt, gen1], [center, gen2], [rightExt, gen2], [leftExt, gen2] ], captions: [ [leftExt - nodeWidth / 2, gen2 + nodeHeight * 3 / 4], [rightExt + nodeWidth * 1.1, gen2 + nodeHeight / 4] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man3.svg", "man1.svg", "lady2.svg"], nodeWeights: [noPair, noPair, noPair, pair1, pair2], currentState: ["deactive", "deactive", "deactive", "activeTo", "active"], edgeState:["married","others","others","married","others"], answer: [qsTr("Brother-in-law")], options: [qsTr("Father-in-law"), qsTr("Mother-in-law"), qsTr("Sister-in-law"), qsTr("Brother-in-law"), qsTr("Daughter-in-law")] }, // level 17 { edgeList: [ [rightXEdge(leftInt), nodeMidPointY(gen1), rightInt, nodeMidPointY(gen1)], [nodeMidPointX(leftInt, rightInt), nodeMidPointY(gen1), nodeMidPointX(leftInt, rightInt), nodeMidPointY(gen2)], [rightXEdge(leftInt), nodeMidPointY(gen2), rightInt, nodeMidPointY(gen2)], [rightXEdge(leftExt), nodeMidPointY(gen2), leftInt, nodeMidPointY(gen2)], [rightXEdge(rightInt), nodeMidPointY(gen2), rightExt, nodeMidPointY(gen2)] ], nodePositions: [ [leftInt, gen1], [rightInt, gen1], [leftInt, gen2], [leftExt, gen2], [rightInt, gen2], [rightExt, gen2] ], captions: [ [leftExt - nodeWidth / 2, gen2], - [rightExt + nodeWidth, gen2 + nodeHeight / 4] + [rightInt + nodeWidth, gen2] ], nodeValue: ["grandfather.svg", "old-lady.svg", "man3.svg", "lady2.svg", "lady1.svg", "man1.svg"], nodeWeights: [noPair, noPair, noPair, pair1, pair2, noPair], - currentState: ["dective", "deactive", "deactive", "active", "deactive", "activeTo"], + currentState: ["dective", "deactive", "deactive", "active", "activeTo", "deactive"], edgeState:["married","others","others","married","married"], answer: [qsTr("Sister-in-law")], options: [qsTr("Father-in-law"), qsTr("Mother-in-law"), qsTr("Sister-in-law"), qsTr("Brother-in-law"), qsTr("Daughter-in-law")] }, // level 18 { edgeList: [ [rightXEdge(center), nodeMidPointY(gen1), rightExt, nodeMidPointY(gen1)], [nodeMidPointX(center, rightExt), nodeMidPointY(gen1), nodeMidPointX(center, rightExt), nodeMidPointY(gen2)], [rightXEdge(center), nodeMidPointY(gen2), rightExt, nodeMidPointY(gen2)], [rightXEdge(leftExt), nodeMidPointY(gen2), center, nodeMidPointY(gen2)] ], nodePositions: [ [center, gen1], [rightExt, gen1], [center, gen2], [leftExt, gen2], [rightExt, gen2] ], captions: [ [center - (nodeWidth * 3/ 4), gen1 + nodeHeight / 4], [leftExt - nodeWidth / 2, gen2 + nodeHeight / 2] ], nodeValue: ["grandfather.svg", "old-lady.svg", "lady2.svg", "man3.svg", "man1.svg"], nodeWeights: [pair1, pair1, noPair, pair2, noPair], currentState: ["active", "deactive", "deactive", "activeTo", "deactive", "deactive"], edgeState:["married","others","others","married","others"], answer: [qsTr("Son-in-law")], options: [qsTr("Son-in-law"), qsTr("Mother-in-law"), qsTr("Sister-in-law"), qsTr("Brother-in-law"), qsTr("Daughter-in-law")] } ] } diff --git a/src/activities/family/Family.qml b/src/activities/family/Family.qml index 2c42681b4..3b63a7b71 100644 --- a/src/activities/family/Family.qml +++ b/src/activities/family/Family.qml @@ -1,386 +1,386 @@ /* GCompris - family.qml * * Copyright (C) 2016 RAJDEEP KAUR * * Authors: * * RAJDEEP KAUR * * 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 QtGraphicalEffects 1.0 import "../../core" import "family.js" as Activity ActivityBase { id: activity - property string mode: "normal" + property string mode: "family" onStart: focus = true onStop: {} pageComponent: Image { id: background anchors.fill: parent source: Activity.url + "back.svg" sourceSize.width: parent.width height: parent.height fillMode: Image.PreserveAspectCrop property bool horizontalLayout: background.width > background.height signal start signal stop Component.onCompleted: { activity.start.connect(start) activity.stop.connect(stop) } property real treeAreaWidth: background.horizontalLayout ? background.width * 0.65 : background.width property real treeAreaHeight: background.horizontalLayout ? background.height : background.height * 0.65 property real nodeWidth: (0.8 * treeAreaWidth) / 5 property real nodeHeight: (0.8 * treeAreaWidth) / 5 property real nodeWidthRatio: nodeWidth / treeAreaWidth property real nodeHeightRatio: nodeHeight / treeAreaHeight onWidthChanged: loadDatasetDelay.start() onHeightChanged: if (!loadDatasetDelay.running) { loadDatasetDelay.start() } /* * Adding a delay before reloading the datasets * needed for fast width / height changes */ Timer { id: loadDatasetDelay running: false repeat: false interval: 100 onTriggered: Activity.loadDatasets() } // 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 nodeRepeater: nodeRepeater property alias answersChoice: answersChoice property alias edgeRepeater: edgeRepeater property alias ringRepeator: ringRepeator property alias dataset: dataset property string mode: activity.mode property alias questionTopic: question.questionTopic property alias selectedPairs: selectedPairs property point questionMarkPosition: questionMarkPosition property point meLabelPosition: meLabelPosition } onStart: { Activity.start(items) } onStop: { Activity.stop() } Dataset { id: dataset } // handling pair matching for family_find_relative Item { id: selectedPairs property int numberOfNodesSelected: 0 property var firstNodePointer property var secondNodePointer function reset() { numberOfNodesSelected = 0 } function deactivatePairs() { if (firstNodePointer && secondNodePointer) { firstNodePointer.changeState("deactive") secondNodePointer.changeState("deactive") } } function checkResult() { if (firstNodePointer.weight == (secondNodePointer.weight * -1) && firstNodePointer.weight != 0) { return true } else { return false } } function selectNode(node_) { if (numberOfNodesSelected >= 2) return if(numberOfNodesSelected == 0) { firstNodePointer = node_ firstNodePointer.changeState("activeTo") } else { secondNodePointer = node_ if (firstNodePointer == secondNodePointer) { deactivatePairs() reset() return } secondNodePointer.changeState("activeTo") // checking results if (checkResult()) { bonus.good("lion") } else { bonus.bad("lion") deactivatePairs() reset() return } } numberOfNodesSelected ++; } } Item { id: board width: background.width height: background.height Rectangle { id: treeArea color: "transparent" width: background.treeAreaWidth height: background.treeAreaHeight - anchors.horizontalCenter: activity.mode == "expert" ? board.horizontalCenter : undefined - anchors.verticalCenter: activity.mode == "expert" ? board.verticalCenter : undefined - border.color: activity.mode == "normal" ? "black" : "transparent" + anchors.horizontalCenter: activity.mode == "find_relative" ? board.horizontalCenter : undefined + anchors.verticalCenter: activity.mode == "find_relative" ? board.verticalCenter : undefined + border.color: activity.mode == "family" ? "black" : "transparent" border.width: 5 Item { id: treeItem Repeater { id: nodeRepeater model: ListModel{} delegate: Node { id: currentPointer x: xPosition * treeArea.width y: yPosition * treeArea.height width: treeArea.width / 5 height: treeArea.width / 5 nodeWidth: currentPointer.width nodeHeight: currentPointer.height nodeImageSource: Activity.url + nodeValue borderColor: "black" borderWidth: 8 color: "transparent" radius: nodeWidth / 2 state: currentState weight: nodeWeight states: [ State { name: "active" PropertyChanges { target: currentPointer borderColor: "blue" } }, State { name: "deactive" PropertyChanges { target: currentPointer } }, State { name: "activeTo" PropertyChanges { target: currentPointer borderColor: "yellow" } } ] } } Rectangle { id: me - visible: dataset.levelElements[bar.level-1].captions[0] !== undefined && activity.mode == "normal" + visible: dataset.levelElements[bar.level-1].captions[0] !== undefined && activity.mode == "family" x: items.meLabelPosition.x * treeArea.width y: items.meLabelPosition.y * treeArea.height width: treeArea.width/12 height: treeArea.height/14 radius: 5 border.color: "black" GCText { id: meLabel text: qsTr("Me") anchors { horizontalCenter: parent.horizontalCenter verticalCenter: parent.verticalCenter } } } Image { id: questionmark source: Activity.url + "questionmark.svg" - visible: dataset.levelElements[bar.level-1].captions[1] !== undefined && activity.mode == "normal" + visible: dataset.levelElements[bar.level-1].captions[1] !== undefined && activity.mode == "family" x: items.questionMarkPosition.x * treeArea.width y: items.questionMarkPosition.y * treeArea.height } Repeater { id: edgeRepeater model: ListModel {} delegate: Rectangle { id: edge opacity: 1 antialiasing: true transformOrigin: Item.TopLeft x: _x1 * treeArea.width y: _y1 * treeArea.height property var x2: _x2 * treeArea.width property var y2: _y2 * treeArea.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) color: "black" Behavior on height { NumberAnimation { duration: 2000 easing.type: Easing.OutExpo } } Behavior on width { NumberAnimation { duration: 2000 easing.type: Easing.OutExpo } } } } Repeater { id: ringRepeator model: ListModel{} delegate: Image { id: ring source: Activity.url + "rings.svg" width: treeArea.width * 0.04 height: treeArea.width * 0.04 x: ringx * treeArea.width y: ringy * treeArea.height } } } } Rectangle { id: answers color: "transparent" width: background.horizontalLayout ? background.width*0.35 : background.width height: background.horizontalLayout ? background.height : background.height*0.35 anchors.left: background.horizontalLayout ? treeArea.right : board.left anchors.top: background.horizontalLayout ? board.top: treeArea.bottom - border.color: activity.mode == "normal" ? "black" : "transparent" + border.color: activity.mode == "family" ? "black" : "transparent" border.width: 5 Rectangle { width: parent.width * 0.99 height: parent.height * 0.99 anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter color: "transparent" Grid { - visible: activity.mode == "normal" ? true : false + visible: activity.mode == "family" ? true : false 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.75 height: answers.height*Activity.answerButtonRatio textLabel: optionn isCorrectAnswer: textLabel === answer onCorrectlyPressed: bonus.good("lion") onIncorrectlyPressed: bonus.bad("lion") } } } } } } GCText { id: question property string questionTopic - visible: activity.mode == "expert" ? true : false + visible: activity.mode == "find_relative" ? true : false width: background.width anchors.horizontalCenter: background.horizontalCenter horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap fontSize: smallSize text: qsTr("Select one of the pairs denoting: %1").arg(questionTopic) Rectangle { width: parent.width height: parent.height anchors.horizontalCenter: parent.horizontalCenter z: parent.z - 1 radius: 10 border.width: 1 color: "white" opacity: 0.8 } } 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/Node.qml b/src/activities/family/Node.qml index 48039b6af..aab935b48 100644 --- a/src/activities/family/Node.qml +++ b/src/activities/family/Node.qml @@ -1,95 +1,95 @@ /* GCompris - Node.qml * * Copyright (C) RAJDEEP KAUR (Qt Quick port) * * Authors: * Holger Kaelberer * 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.0 import GCompris 1.0 import "../../core" import "family.js" as Activity Item { id: node property int nodeWidth property int nodeHeight property string nodeImageSource property string borderColor property real borderWidth property string color property real radius property int weight function changeState(state_) { currentPointer.state = state_ } Rectangle { id: content color: node.color width: 0.8 * nodeWidth height: 0.8 * nodeHeight border.color: borderColor border.width: borderWidth radius: node.radius Image { id: nodeImage source: nodeImageSource anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter width: parent.width * 0.6 height: parent.height * 0.6 SequentialAnimation { id: activeAnimation running: currentPointer.state === "active" || currentPointer.state === "activeTo" loops: Animation.Infinite alwaysRunToEnd: true NumberAnimation { target: nodeImage property: "rotation" from: 0; to: 10 duration: 200 easing.type: Easing.OutQuad } NumberAnimation { target: nodeImage property: "rotation" from: 10; to: -10 duration: 400 easing.type: Easing.InOutQuad } NumberAnimation { target: nodeImage property: "rotation" from: -10; to: 0 duration: 200 easing.type: Easing.InQuad } } } MouseArea { - visible: activity.mode == "expert" ? true : false + visible: activity.mode == "find_relative" ? true : false anchors.fill: parent onClicked: selectedPairs.selectNode(currentPointer) } } } diff --git a/src/activities/family/family.js b/src/activities/family/family.js index 87ef973df..8651841a0 100644 --- a/src/activities/family/family.js +++ b/src/activities/family/family.js @@ -1,149 +1,149 @@ /* GCompris - family.js * * Copyright (C) 2016 RAJDEEP KAUR * * Authors: * RAJDEEP KAUR * * 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 .import GCompris 1.0 as GCompris .import "qrc:/gcompris/src/core/core.js" as Core var currentLevel = 0 var items; var barAtStart; var url = "qrc:/gcompris/src/activities/family/resource/" var numberOfLevel var shuffledLevelIndex = [] var levelToLoad var answerButtonRatio = 0; function start(items_) { items = items_ currentLevel = 0 numberOfLevel = items.dataset.levelElements.length barAtStart = GCompris.ApplicationSettings.isBarHidden; GCompris.ApplicationSettings.isBarHidden = true; shuffle() initLevel() } function stop() { GCompris.ApplicationSettings.isBarHidden = barAtStart; } function initLevel() { items.bar.level = currentLevel + 1 items.selectedPairs.reset() levelToLoad = getCurrentLevelIndex() loadDatasets() } function loadDatasets() { if (!items) { return } var levelTree = items.dataset.levelElements[levelToLoad] answerButtonRatio = 1 / (levelTree.options.length + 4); items.nodeRepeater.model.clear(); items.answersChoice.model.clear(); items.edgeRepeater.model.clear(); items.ringRepeator.model.clear(); for(var i = 0 ; i < levelTree.nodePositions.length ; i++) { items.nodeRepeater.model.append({ "xPosition": levelTree.nodePositions[i][0], "yPosition": levelTree.nodePositions[i][1], "nodeValue": levelTree.nodeValue[i], - "currentState": items.mode == "normal" ? levelTree.currentState[i] : "deactive", + "currentState": items.mode == "family" ? levelTree.currentState[i] : "deactive", "nodeWeight": levelTree.nodeWeights[i] }); } for(var i = 0 ; i * * Authors: * RUDRA NIL BASU (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 "../../core" import "../family" Family { id: activity - property string mode: "expert" + property string mode: "find_relative" }