Git commit 7721615817162efc3b82baac6853f2331a63d6ba by Bruno Coudoin. Committed on 19/12/2014 at 14:50. Pushed by bcoudoin into branch 'devel2'. imageid, minor code improvements M +27 -23 src/activities/imageid/Imageid.qml M +4 -16 src/activities/imageid/imageid.js M +0 -1 src/activities/imageid/lang_api.js http://commits.kde.org/gcompris/7721615817162efc3b82baac6853f2331a63d6ba diff --git a/src/activities/imageid/Imageid.qml b/src/activities/imageid/Im= ageid.qml index 08f990d..c4c4bdd 100644 --- a/src/activities/imageid/Imageid.qml +++ b/src/activities/imageid/Imageid.qml @@ -75,7 +75,12 @@ ActivityBase { property alias wordImage: wordImage property alias wordListModel: wordListModel property alias parser: parser - property GCAudio audioVoices: activity.audioVoices + property variant goodWord + + function playWord() { + activity.audioVoices.append(ApplicationInfo.getAudioFilePa= th(goodWord.voice)) + } + onGoodWordChanged: playWord() } = onStart: { @@ -84,8 +89,9 @@ ActivityBase { if(!DownloadManager.haveLocalResource("data/words/words.rcc"))= { var buttonHandler =3D new Array(); buttonHandler[StandardButton.No] =3D function() {}; - buttonHandler[StandardButton.Yes] =3D function() { Downloa= dManager.updateResource("data/words/words.rcc") }; - dialog =3D Core.showMessageDialog(parent, qsTr("Download?"= ), + buttonHandler[StandardButton.Yes] =3D function() { + DownloadManager.updateResource("data/words/words.rcc")= }; + dialog =3D Core.showMessageDialog(parent, qsTr("Downlo= ad?"), qsTr("Are you ok to downlo= ad the images for this activity"), "", StandardIcon.Question, @@ -119,8 +125,12 @@ ActivityBase { anchors.margins: 10 * ApplicationInfo.ratio = Item { - width: background.horizontalLayout ? background.width * 0.= 45 : background.width - gridId.anchors.margins * 2 - height: background.horizontalLayout ? background.height - = bar.height : (background.height - bar.height) * 0.4 + width: background.horizontalLayout + ? background.width * 0.55 + : background.width - gridId.anchors.margins * 2 + height: background.horizontalLayout + ? background.height - bar.height + : (background.height - bar.height) * 0.4 Image { id: imageFrame anchors { @@ -145,8 +155,12 @@ ActivityBase { ListView { id: wordListView = - width: background.horizontalLayout ? background.width * 0.= 45 : background.width - gridId.anchors.margins * 2 - height: background.horizontalLayout ? background.height - = bar.height : (background.height - bar.height) * 0.40 + width: background.horizontalLayout + ? background.width * 0.40 + : background.width - gridId.anchors.margins * 2 + height: background.horizontalLayout + ? background.height - bar.height + : (background.height - bar.height) * 0.40 spacing: 10 * ApplicationInfo.ratio orientation: Qt.Vertical verticalLayoutDirection: ListView.TopToBottom @@ -163,37 +177,27 @@ ActivityBase { height: wordListView.buttonHeight = textLabel: word - isCorrectAnswer: word =3D=3D=3D Activity.getCorrectAns= wer() + isCorrectAnswer: word =3D=3D=3D items.goodWord.transla= tedTxt onCorrectlyPressed: bonus.good("smiley"); } } } = - DropShadow { - anchors.fill: imageFrame - cached: true - horizontalOffset: 12 - verticalOffset: 12 - radius: 8.0 - samples: 16 - color: "#ff292950" - source: imageFrame - } - - onVoiceError: repeatItem.visible =3D false onVoiceDone: repeatItem.visible =3D true + onVoiceError: repeatItem.visible =3D false = BarButton { id: repeatItem source: "qrc:/gcompris/src/core/resource/bar_repeat.svgz"; sourceSize.width: 80 * ApplicationInfo.ratio + z: 12 anchors { top: parent.top - right: parent.right - margins: 10 + left: parent.left + margins: 10 * ApplicationInfo.ratio } - onClicked: Activity.playWord(); + onClicked: items.playWord() } = DialogHelp { diff --git a/src/activities/imageid/imageid.js b/src/activities/imageid/ima= geid.js index 0d577de..e5c4fb1 100755 --- a/src/activities/imageid/imageid.js +++ b/src/activities/imageid/imageid.js @@ -35,7 +35,6 @@ var items; var baseUrl =3D "qrc:/gcompris/src/activities/imageid/resource/"; var dataset =3D null; var lessons -var goodWord = function init(items_) { items =3D items_; @@ -50,7 +49,6 @@ function start() { currentSubLevel =3D 0; = dataset =3D Lang.load(items.parser, baseUrl + "words.json") - Lang.getChapterModel(dataset) lessons =3D Lang.getAllLessons(dataset) maxLevel =3D lessons.length = @@ -60,11 +58,6 @@ function start() { function stop() { } = -function getCorrectAnswer() -{ - return goodWord.translatedTxt -} - function initLevel() { items.bar.level =3D currentLevel + 1; = @@ -76,11 +69,11 @@ function initLevel() { = // initialize sublevel items.score.currentSubLevel =3D currentSubLevel + 1; - goodWord =3D wordList[currentSubLevel] + items.goodWord =3D wordList[currentSubLevel] = -// Core.shuffle(allWords); + Core.shuffle(allWords); var selectedWords =3D [] - selectedWords.push(goodWord.translatedTxt) + selectedWords.push(items.goodWord.translatedTxt) for (var i =3D 0; i < wordList.length; i++) { if(wordList[i].translatedTxt !=3D=3D selectedWords[0]) selectedWords.push(wordList[i].translatedTxt) @@ -94,12 +87,7 @@ function initLevel() { for (var j =3D 0; j < selectedWords.length; j++) { items.wordListModel.append({"word": selectedWords[j] }) } - items.wordImage.source =3D "qrc:/" + goodWord.image; - playWord() -} - -function playWord() { - items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath(goo= dWord.voice)) + items.wordImage.source =3D "qrc:/" + items.goodWord.image; } = function nextLevel() { diff --git a/src/activities/imageid/lang_api.js b/src/activities/imageid/la= ng_api.js index 54c2d1d..9e1f147 100644 --- a/src/activities/imageid/lang_api.js +++ b/src/activities/imageid/lang_api.js @@ -64,7 +64,6 @@ function getChapter(dataset, chapter) { function getChapterModel(dataset) { var chapters =3D [] for (var c =3D 0; c < dataset.length; c++) { - console.log(dataset[c].content[0].content[0].image) chapters.push( {'name': dataset[c].name, 'image': dataset[c].content[0].content[0].image,