diff --git a/src/activities/explore_farm_animals/ExploreLevels.qml b/src/activities/explore_farm_animals/ExploreLevels.qml index f308e01b6..911afbfc3 100644 --- a/src/activities/explore_farm_animals/ExploreLevels.qml +++ b/src/activities/explore_farm_animals/ExploreLevels.qml @@ -1,294 +1,294 @@ /* GCompris - ExploreLevels.qml * * Copyright (C) 2015 Ayush Agrawal * * Authors: * Beth Hadley (GTK+ version) * Ayush Agrawal (Qt Quick port) * Djalil MESLI (Qt Quick port) * Johnny Jazeix (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 import GCompris 1.0 import QtQuick.Controls 1.5 import "../../core" import "explore-level.js" as Activity ActivityBase { id: activity property int numberOfLevels property string url property bool hasAudioQuestions onStart: focus = true onStop: {} pageComponent: Item { id: background /* In order to accept any screen ratio the play area is always a 1000x1000 * square and is centered in a big background image that is 2000x2000 */ Image { id: bg source: dataset.item.backgroundImage sourceSize.width: 2000 * ApplicationInfo.ratio sourceSize.height: 2000 * ApplicationInfo.ratio width: 2000 * background.playRatio height: width anchors.centerIn: parent } property bool horizontalLayout: background.width > background.height property int playX: (activity.width - playWidth) / 2 property int playY: (activity.height - playHeight) / 2 property int playWidth: horizontalLayout ? activity.height : activity.width property int playHeight: playWidth property double playRatio: playWidth / 1000 focus: true 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 GCAudio audioVoices: activity.audioVoices property Item main: activity.main property alias background: background property alias bar: bar property alias bonus: bonus property alias score: score property alias progressbar: progressbar property alias ok: ok property alias dataModel: dataModel property alias dataset: dataset property alias instruction: instruction property alias instructionText: instructionText property alias descriptionPanel: descriptionPanel property bool hasAudioQuestions: activity.hasAudioQuestions property string currentAudio property var questionOrder property var currentQuestion: items.dataset ? items.dataset.item.tab[items.questionOrder[progressbar.value]] : "" } Loader{ id: dataset asynchronous: false onStatusChanged: { if (status == Loader.Ready) { // create table of size N filled with numbers from 0 to N items.questionOrder = Array.apply(null, {length: items.dataModel.count}).map(Number.call, Number) } } } onStart: { Activity.start(items, url, numberOfLevels) } onStop: { Activity.stop() } Keys.onEscapePressed: { descriptionPanel.visible ? descriptionPanel.closeDescriptionPanel() : home() } Repeater { id: dataModel model: dataset && dataset.item && dataset.item.tab ? dataset.item.tab.length : 0 AnimalLevels { questionId: index source: dataset.item.tab[index].image x: background.playX + background.playWidth * dataset.item.tab[index].x - width / 2 y: background.playY + background.playHeight * dataset.item.tab[index].y - height / 2 width: background.playWidth * dataset.item.tab[index].width height: background.playHeight * dataset.item.tab[index].height title: dataset.item.tab[index].title description: dataset.item.tab[index].text imageSource: dataset.item.tab[index].image2 question: dataset.item.tab[index].text2 audio: dataset.item.tab[index].audio !== undefined ? dataset.item.tab[index].audio : "" Component.onCompleted: { displayDescription.connect(displayDescriptionItem) } } } function displayDescriptionItem(animal) { descriptionPanel.title = animal.title descriptionPanel.description = animal.description descriptionPanel.imageSource = animal.imageSource descriptionPanel.visible = true descriptionPanel.showDescriptionPanel() } AnimalDescriptionLevels { id: descriptionPanel width: parent.width height: parent.height z: instruction.z + 1 } Column { id: progress visible: items.score.currentSubLevel != 1 - anchors.bottom: parent.bottom + anchors.bottom: bar.top anchors.right: parent.right anchors.margins: 10 * ApplicationInfo.ratio ProgressBar { id: progressbar - height: questionText.height - width: background.width / 2.5 + height: progressbarText.height + width: bar.width property string message onValueChanged: message = value + "/" + maximumValue onMaximumValueChanged: message = value + "/" + maximumValue GCText { id: progressbarText anchors.centerIn: parent fontSize: mediumSize font.bold: true color: "black" text: progressbar.message } } } Image { id: ok visible: progressbar.value === progressbar.maximumValue source:"qrc:/gcompris/src/core/resource/bar_ok.svg" sourceSize.width: questionText.height * 2 fillMode: Image.PreserveAspectFit anchors.right: progress.left - anchors.bottom: parent.bottom + anchors.bottom: bar.top anchors.margins: 10 * ApplicationInfo.ratio MouseArea { anchors.fill: parent onClicked: Activity.nextLevel() } } Row { id: row spacing: 10 * ApplicationInfo.ratio anchors.fill: parent anchors.margins: 10 * ApplicationInfo.ratio layoutDirection: leftCol.width === 0 ? Qt.RightToLeft : Qt.LeftToRight Column { id: leftCol spacing: 10 * ApplicationInfo.ratio Rectangle { id: instruction width: row.width - rightCol.width - 10 * ApplicationInfo.ratio height: instructionText.height color: "#CCCCCCCC" radius: 10 border.width: 3 border.color: "black" GCText { id: instructionText horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter anchors.centerIn: parent.Center color: "black" width: parent.width wrapMode: Text.Wrap text: (dataset.item && items.score.currentSubLevel - 1 != items.score.numberOfSubLevels && items.score.currentSubLevel != 0) ? dataset.item.instructions[items.score.currentSubLevel - 1].text : "" } MouseArea { anchors.fill: parent onClicked: instruction.visible = false enabled: instruction.visible } } Rectangle { id: question width: row.width - rightCol.width - 10 * ApplicationInfo.ratio height: questionText.height color: '#CCCCCCCC' radius: 10 border.width: 3 border.color: "black" visible: items.score.currentSubLevel == 3 || (items.score.currentSubLevel == 2 && !items.hasAudioQuestions) GCText { id: questionText horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter anchors.centerIn: parent.Center color: "black" width: parent.width wrapMode: Text.Wrap text: items.currentQuestion ? items.currentQuestion.text2 : "" } } } Column { id: rightCol spacing: 10 * ApplicationInfo.ratio Score { id: score anchors { bottom: undefined right: undefined } } BarButton { id: repeatItem source: "qrc:/gcompris/src/core/resource/bar_repeat.svg"; sourceSize.width: 60 * ApplicationInfo.ratio anchors.right: parent.right visible: items.score.currentSubLevel == 2 && activity.hasAudioQuestions //&& ApplicationSettings.isAudioVoicesEnabled onClicked: Activity.repeat(); } } } DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar content: BarEnumContent { value: help | home | level | reload } onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() onReloadClicked: Activity.start(items, url, numberOfLevels) } Bonus { id: bonus } } } diff --git a/src/activities/explore_farm_animals/resource/board/board1.qml b/src/activities/explore_farm_animals/resource/board/board1.qml index 9571c2db7..873864da6 100644 --- a/src/activities/explore_farm_animals/resource/board/board1.qml +++ b/src/activities/explore_farm_animals/resource/board/board1.qml @@ -1,162 +1,162 @@ /* GCompris * * Copyright (C) 2015 Johnny Jazeix * * Authors: * Beth Hadley (GTK+ version) * Johnny Jazeix (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 import GCompris 1.0 as GCompris QtObject { property string backgroundImage: "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/farm-animals.svg" property var tab : [ { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/horse.svg", "title": qsTr("Horse"), "text": qsTr("The horse goes 'neigh! neigh!'. Horses usually sleep standing up."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/horse.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/horse.jpg", "text2": qsTr("You can ride on the back of this animal!"), "x": 0.304, "y": 0.480, "width": 0.156, "height": 0.166 }, { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/chicken.svg", "title": qsTr("Chicken"), "text": qsTr("The chicken goes 'luck, cackle, cluck'. Chickens have over 200 different noises they can use to communicate."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/chickens.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/chicken.jpg", "text2": qsTr("This animal lays eggs."), - "x": 0.58, - "y": 0.73, + "x": 0.66, + "y": 0.67, "width": 0.190, - "height": 0.121 + "height": 0.119 }, { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/cow.svg", "title": qsTr("Cow"), "text": qsTr("The cow goes 'moo! moo!'. Cows are herbivorous mammals. They graze all day in the meadow."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/cow.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/cow.jpg", "text2": qsTr("You can drink the milk this animal produces."), "x": 0.364, "y": 0.620, "width": 0.305, "height": 0.172 }, { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/cat.svg", "title": qsTr("Cat"), "text": qsTr("The cat goes 'meow, meow'. Cats usually hate water because their fur doesn't stay warm when it is wet."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/cat.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/cat.jpg", "text2": qsTr("This pet likes chasing mice."), "x": 0.880, - "y": 0.775, + "y": 0.550, "width": 0.114, "height": 0.110 }, { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/pig.svg", "title": qsTr("Pig"), "text": qsTr("The pig goes 'oink, oink'. Pigs are the 4th most intelligent animal."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/pig.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/pig.jpg", "text2": qsTr("This animal likes to lie in the mud."), - "x": 0.75, - "y": 0.90, + "x": 0.42, + "y": 0.75, "width": 0.185, - "height": 0.173 + "height": 0.153 }, { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/duck.svg", "title": qsTr("Duck"), "text": qsTr("The duck goes 'quack, quack'. Ducks have special features like webbed feet and produce an oil to make their feathers 'waterproof'."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/duck.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/duck.jpg", "text2": qsTr("This animal has webbed feet so it can swim in the water."), "x": 0.163, - "y": 0.80, + "y": 0.76, "width": 0.210, - "height": 0.136 + "height": 0.134 }, { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/owl.svg", "title": qsTr("Owl"), "text": qsTr("The owl goes 'hoo. hoo.' The owl has excellent vision and hearing at night."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/owl.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/owl.jpg", "text2": qsTr("This animal likes to come out at night."), "x": 0.71, "y": 0.29, "width": 0.042, "height": 0.056 }, { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/dog.svg", "title": qsTr("Dog"), "text": qsTr("The dog goes 'bark! bark!'. Dogs are great human companions and usually enjoy love and attention."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/dog.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/dog.jpg", "text2": qsTr("This animal's ancestors were wolves."), "x": 0.120, "y": 0.600, "width": 0.126, "height": 0.101 }, { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/rooster.svg", "title": qsTr("Rooster"), "text": qsTr("The rooster goes 'coc-a-doodle-doo!'. Roosters have been on farms for about 5,000 years. Every morning it wakes the farm up with its noises."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/rooster.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/rooster.jpg", "text2": qsTr("This animal wakes the farm up in the morning."), - "x": 0.52, - "y": 0.90, + "x": 0.66, + "y": 0.78, "width": 0.122, - "height": 0.137 + "height": 0.127 }, { "image": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/sheep.svg", "title": qsTr("Sheep"), "text": qsTr("The sheep is a mammal that bears a fleece of wool. It is a grazing herbivore, bred for its wool, its meat, and its milk. The fleece can be removed and used to produce articles of clothing and blankets, among other things."), "audio": GCompris.ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/sheep.$CA"), "image2": "qrc:/gcompris/src/activities/explore_farm_animals/resource/animals/sheep.jpg", "text2": qsTr("This animal is a close relative to the goat."), "x": 0.66, - "y": 0.550, + "y": 0.548, "width": 0.20, - "height": 0.15 + "height": 0.13 } ] property var instructions : [ { "text": qsTr("Click on each farm animal to discover them.") }, { "text": qsTr("Click on the farm animal that makes the sound you hear.") }, { "text": qsTr("Click the animal that matches the description.") } ] }