diff --git a/src/activities/multiplication_tables/Multiplication_tables.qml b/src/activities/multiplication_tables/Multiplication_tables.qml index d8042bff3..f0bc89c5a 100644 --- a/src/activities/multiplication_tables/Multiplication_tables.qml +++ b/src/activities/multiplication_tables/Multiplication_tables.qml @@ -1,370 +1,303 @@ /* GCompris - multiplication_tables.qml * * Copyright (C) 2016 Nitish Chauhan * * Authors: * * Nitish Chauhan (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 QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1 import "../../core" import "multiplication_tables.js" as Activity import "multiplicationtables_dataset.js" as Dataset ActivityBase { - id: activity - - property string url: "qrc:/gcompris/src/activities/multiplication_tables/resource/" - property double startTime: 0 - property int flag: 0 - property var dataset: Dataset - property string mode: "multiplicationtables" - - onStart: focus = true - onStop: {} - - pageComponent: Rectangle { - id: background - anchors.fill: parent - color: "#ABCDEF" - 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 heading_text: heading_text - property alias start_button: start_button - property alias stop_button: stop_button - property alias time: time - property alias score: score - - property alias questionGrid: questionGrid - property alias repeater: repeater - - - } - - onStart: { - Activity.start(items, mode, dataset, url) - - } - onStop: { - Activity.stop() - } - - //........................................................................... - - - // main heading - GCText { - id: heading_text - text:"Heading Text" - font.pointSize: 30 - color: "red" - anchors.top: parent.top; - anchors.margins: 20 - anchors.horizontalCenter: parent.horizontalCenter - - } - - - - Grid { - - id: questionGrid - - spacing: 40 + id: activity + + property string url: "qrc:/gcompris/src/activities/multiplication_tables/resource/" + property double startTime: 0 + property int flag: 0 + property + var dataset: Dataset + property string mode: "multiplicationtables" + + onStart: focus = true + onStop: {} + + pageComponent: Rectangle { + id: background + anchors.fill: parent + color: "#ABCDEF" + 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 start_button: start_button + property alias stop_button: stop_button + property alias time: time + property alias score: score + property alias questionGrid: questionGrid + property alias repeater: repeater - anchors { + } - left: parent.left - right: parent.rigth - top: heading_text.bottom - margins: 20 + onStart: { + Activity.start(items, mode, dataset, url) } + onStop: { + Activity.stop() + } + + Flow { + id: questionGrid + anchors.fill: parent + anchors.bottom: bar.top + spacing: 50 - Repeater { + anchors { + left: background.left + right: background.rigth + margins: 60 + } + Repeater { id: repeater model: 10 Question { - - - } - - } - - - } - - - -//} - - - Button { - id: stop_button - text: qsTr(" FINISH ") - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors { - bottomMargin: 50 - rightMargin: 120 - } - - - - style: ButtonStyle { - background: Rectangle { - implicitWidth: 100 - implicitHeight: 40 - border.width: control.activeFocus ? 2 : 1 - border.color: "blue" - radius: 4 - gradient: Gradient { - GradientStop { - position: 0;color: control.pressed ? "#729fcf" : "#729fcf" - } - GradientStop { - position: 1;color: control.pressed ? "#3465a4" : "#3465a4" + } } - } } - } + Image { + id: player + source: url + "children.svg" + anchors { + bottom: bar.bottom + right: parent.right + } + width: height * 0.83 + height: bar.height * 1.2 + } - onClicked: { - + Button { + id: stop_button + text: qsTr(" FINISH ") + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors { + bottomMargin: 50 + rightMargin: 120 + } - if (flag == 1) { + style: ButtonStyle { + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + border.width: control.activeFocus ? 2 : 1 + border.color: "blue" + radius: 4 + gradient: Gradient { + GradientStop { + position: 0;color: control.pressed ? "#729fcf" : "#729fcf" + } + GradientStop { + position: 1;color: control.pressed ? "#3465a4" : "#3465a4" + } + } + } + } + onClicked: { + if (flag == 1) { + score.visible = true + var str1 = new Date().getTime() - startTime + time.text = qsTr("Your time: %1 ms").arg(str1) + startTime = 0 + flag = 0 + start_button.text = qsTr("START AGAIN") + Activity.verifyAnswer() + } + } + } - score.visible = true - var str1 = new Date().getTime() - startTime - time.text = qsTr("Your time: %1 ms").arg(str1) + Button { + id: start_button + text: qsTr(" START ") + anchors.bottom: parent.bottom + anchors.right: stop_button.left + anchors { + bottomMargin: 50 + rightMargin: 30 + } + style: ButtonStyle { + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + border.width: control.activeFocus ? 2 : 1 + border.color: "blue" + radius: 4 + gradient: Gradient { + GradientStop { + position: 0;color: control.pressed ? "#729fcf" : "#729fcf" + } + GradientStop { + position: 1;color: control.pressed ? "#3465a4" : "#3465a4" + } + } + } + } - startTime = 0 - flag = 0 - start_button.text = qsTr("Start again") - Activity.verifyAnswer() + onClicked: { + if (startTime == 0 && flag == 0) { + Activity.resetvalue() + start_button.text = qsTr(" START ") + time.text = qsTr(" Your timer started...") + startTime = new Date().getTime() + flag = 1 + } + } } - } - } + GCText { + id: score + font.pointSize: 20 + color: "#4B6319" + font.bold: true + anchors.bottom: time.top + anchors.right: parent.right - - Button { - id: start_button - text: qsTr(" START ") - anchors.bottom: parent.bottom - anchors.right: stop_button.left - anchors { - bottomMargin: 50 - rightMargin: 30 - } - - style: ButtonStyle { - background: Rectangle { - implicitWidth: 100 - implicitHeight: 40 - border.width: control.activeFocus ? 2 : 1 - border.color: "blue" - radius: 4 - gradient: Gradient { - GradientStop { - position: 0;color: control.pressed ? "#729fcf" : "#729fcf" - } - GradientStop { - position: 1;color: control.pressed ? "#3465a4" : "#3465a4" + anchors { + bottomMargin: 15 + rightMargin: 150 } - } + Layout.alignment: Qt.AlignCenter } - } - - - onClicked: { - - if (startTime == 0 && flag == 0) { - - Activity.resetvalue() - start_button.text = qsTr(" START ") - time.text = qsTr(" Your timer started...") - startTime = new Date().getTime() - flag = 1 + GCText { + id: time + font.pixelSize: 23 + font.bold: true + color: '#4B6319' + anchors.bottom: start_button.top + anchors.right: parent.right + anchors { + bottomMargin: 30 + rightMargin: 130 + } + text: qsTr("--") + Layout.alignment: Qt.AlignCenter } - } - - } - - - GCText { - id: score - font.pointSize: 20 - - color: "#cc0000" - font.bold: true - - anchors.bottom: time.top - anchors.right: parent.right - - anchors { - bottomMargin: 15 - rightMargin: 150 - - - } - - Layout.alignment: Qt.AlignCenter - } - - - - - //........implementing timer.............. - - - GCText { - id: time - font.pixelSize: 23 - font.bold: true - color: '#cc0000' - anchors.bottom: start_button.top - anchors.right: parent.right - anchors { - bottomMargin: 30 - rightMargin: 130 - } - text: qsTr("--") - Layout.alignment: Qt.AlignCenter - } - - - - //........timerend.......................................................... - - - + DialogActivityConfig { + id: dialogActivityConfig + currentActivity: activity + content: Component { + Item { + height: column.height + + Column { + id: column + spacing: 10 + width: parent.width + + GCDialogCheckBox { + id: easyModeBox1 + width: 250 * ApplicationInfo.ratio + text: qsTr("School Mode") + checked: background.easyMode + onCheckedChanged: { + background.easyMode = checked + Activity.reloadRandom() + } + } + } + } + } - //........................................................................... + onLoadData: { + if (dataToSave && dataToSave["mode"]) { + background.easyMode = (dataToSave["mode"] === "true"); + } + } - DialogActivityConfig { - id: dialogActivityConfig - currentActivity: activity - content: Component { - Item { - height: column.height + onSaveData: { + dataToSave = { + "mode": "" + background.easyMode + } + } - Column { - id: column - spacing: 10 - width: parent.width + onClose: home() + } - GCDialogCheckBox { - id: easyModeBox1 - width: 250 * ApplicationInfo.ratio - text: qsTr("School Mode") - checked: background.easyMode - onCheckedChanged: { - background.easyMode = checked - Activity.reloadRandom() - } - } - } + DialogHelp { + id: dialogHelp + onClose: home() } - } - onLoadData: { - if (dataToSave && dataToSave["mode"]) { - background.easyMode = (dataToSave["mode"] === "true"); + Bar { + id: bar + content: BarEnumContent { + value: help | home | level | config + } + onHelpClicked: { + displayDialog(dialogHelp) + } + onPreviousLevelClicked: Activity.previousLevel() + onNextLevelClicked: Activity.nextLevel() + onHomeClicked: activity.home() + onReloadClicked: Activity.reloadRandom() + onConfigClicked: { + dialogActivityConfig.active = true + displayDialog(dialogActivityConfig) + } } - } - onSaveData: { - dataToSave = { - "mode": "" + background.easyMode + Bonus { + id: bonus + Component.onCompleted: win.connect(Activity.nextLevel) } - } - - onClose: home() - } - - - - DialogHelp { - id: dialogHelp - onClose: home() - } - - - - - Bar { - id: bar - content: BarEnumContent { - value: help | home | level | config - } - onHelpClicked: { - displayDialog(dialogHelp) - } - onPreviousLevelClicked: Activity.previousLevel() - onNextLevelClicked: Activity.nextLevel() - onHomeClicked: activity.home() - onReloadClicked: Activity.reloadRandom() - onConfigClicked: { - dialogActivityConfig.active = true - displayDialog(dialogActivityConfig) - } - } - - - Bonus { - id: bonus - Component.onCompleted: win.connect(Activity.nextLevel) } - } } diff --git a/src/activities/multiplication_tables/Question.qml b/src/activities/multiplication_tables/Question.qml index dff9b595a..3b06f1b07 100644 --- a/src/activities/multiplication_tables/Question.qml +++ b/src/activities/multiplication_tables/Question.qml @@ -1,92 +1,87 @@ /* GCompris * * * 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 QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1 - import "multiplication_tables.js" as Activity - import QtGraphicalEffects 1.0 import "../../core" import GCompris 1.0 Row { id: row1 property string url: "qrc:/gcompris/src/activities/multiplication_tables/resource/" - - property alias questionText: tabletext_1.text - property alias answerText: ans_1.text + property alias questionText: questionText.text + property alias answerText: answerText.text property alias questionImage: question_image.source property alias questionImage_visible: question_image.opacity // 10 questions GCText { - id: tabletext_1 + id: questionText text:"Question" font.pointSize: 20 font.bold: true color: "black" } TextField { - id: ans_1 + id: answerText height: 35 font.pixelSize: 20 style: TextFieldStyle { - textColor: "red" + textColor: "#006060" background: Rectangle { radius: 5 color: "orange" implicitWidth: 100 implicitHeight: 24 border.color: "#333" border.width: 1 } } } Image { id: question_image width: 70;height: 50 fillMode: Image.PreserveAspectFit source: "qrc:/gcompris/src/activities/multiplication_tables/resource/wrong.svg" opacity: 0 } - - } diff --git a/src/activities/multiplication_tables/multiplication_tables.js b/src/activities/multiplication_tables/multiplication_tables.js index 8c0caac5f..7bac844d1 100644 --- a/src/activities/multiplication_tables/multiplication_tables.js +++ b/src/activities/multiplication_tables/multiplication_tables.js @@ -1,161 +1,155 @@ /* GCompris - multiplication_tables.js * * Copyright (C) 2016 Nitish Chauhan * * Authors: * * "Nitish Chauhan" (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.2 as Quick - .import GCompris 1.0 as GCompris //for ApplicationInfo - .import "qrc:/gcompris/src/core/core.js" as Core + .import QtQuick 2.2 as Quick + .import GCompris 1.0 as GCompris //for ApplicationInfo + .import "qrc:/gcompris/src/core/core.js" as Core var currentLevel = 0 var items var mode var dataset var numberOfLevel var url var table var question = [] var answer = [] var score_cnt = 0 function start(_items, _mode, _dataset, _url) { - items = _items - mode = _mode - dataset = _dataset.get() - url = _url - numberOfLevel = dataset.length - currentLevel = 0 - initLevel() + items = _items + mode = _mode + dataset = _dataset.get() + url = _url + numberOfLevel = dataset.length + currentLevel = 0 + initLevel() } - function stop() {} function initLevel() { - items.bar.level = currentLevel + 1 - loadCoordinates() - - + loadQuestions() } -function loadCoordinates() { - - var i +function loadQuestions() { - question = dataset[currentLevel].questions - answer = dataset[currentLevel].answers - table = dataset[currentLevel].TableName + var i - items.heading_text.text = qsTr("Table of %1").arg(table) + question = dataset[currentLevel].questions + answer = dataset[currentLevel].answers + table = dataset[currentLevel].TableName - for(i=0;i * 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 . */ - function get() { return [ - { - "TableName": "2", - "questions": ["2 X 1","2 X 2","2 X 3","2 X 4","2 X 5","2 X 6","2 X 7","2 X 8","2 X 9","2 X 10"], - "answers": ["2","4","6","8","10","12","14","16","18","20"] - }, - { - "TableName": "3", - "questions": ["3 X 1","3 X 2","3 X 3","3 X 4","3 X 5","3 X 6","3 X 7","3 X 8","3 X 9","3 X 10"], - "answers": ["3","6","9","12","15","18","21","24","27","30"] - }, - - - { - "TableName": "4", - "questions": ["4 X 1","4 X 2","4 X 3","4 X 4","4 X 5","4 X 6","4 X 7","4 X 8","4 X 9","4 X 10"], - "answers": ["4","8","12","16","20","24","28","32","36","40"] - }, - { - "TableName": "5", - "questions": ["5 X 1","5 X 2","5 X 3","5 X 4","5 X 5","5 X 6","5 X 7","5 X 8","5 X 9","5 X 10"], - "answers": ["5","10","15","20","25","30","35","40","45","50"] - }, - { - "TableName": "6", - "questions": ["6 X 1","6 X 2","6 X 3","6 X 4","6 X 5","6 X 6","6 X 7","6 X 8","6 X 9","6 X 10"], - "answers": ["6","12","18","24","30","36","42","48","54","60"] - }, - { - "TableName": "7", - "questions": ["7 X 1","7 X 2","7 X 3","7 X 4","7 X 5","7 X 6","7 X 7","7 X 8","7 X 9","7 X 10"], - "answers": ["7","14","21","28","35","42","48","56","63","70"] - }, - { - "TableName": "8", - "questions": ["8 X 1","8 X 2","8 X 3","8 X 4","8 X 5","8 X 6","8 X 7","8 X 8","8 X 9","8 X 10"], - "answers": ["8","16","24","32","40","48","56","64","72","80"] - }, - { - "TableName": "9", - "questions": ["9 X 1","9 X 2","9 X 3","9 X 4","9 X 5","9 X 6","9 X 7","9 X 8","9 X 9","9 X 10"], - "answers": ["9","18","27","36","45","54","63","72","81","90"] - } + { + "TableName": "2", + "questions": ["2 X 1", "2 X 2", "2 X 3", "2 X 4", "2 X 5", "2 X 6", "2 X 7", "2 X 8", "2 X 9", "2 X 10"], + "answers": ["2", "4", "6", "8", "10", "12", "14", "16", "18", "20"] + }, + { + "TableName": "3", + "questions": ["3 X 1", "3 X 2", "3 X 3", "3 X 4", "3 X 5", "3 X 6", "3 X 7", "3 X 8", "3 X 9", "3 X 10"], + "answers": ["3", "6", "9", "12", "15", "18", "21", "24", "27", "30"] + }, + { + "TableName": "4", + "questions": ["4 X 1", "4 X 2", "4 X 3", "4 X 4", "4 X 5", "4 X 6", "4 X 7", "4 X 8", "4 X 9", "4 X 10"], + "answers": ["4", "8", "12", "16", "20", "24", "28", "32", "36", "40"] + }, + { + "TableName": "5", + "questions": ["5 X 1", "5 X 2", "5 X 3", "5 X 4", "5 X 5", "5 X 6", "5 X 7", "5 X 8", "5 X 9", "5 X 10"], + "answers": ["5", "10", "15", "20", "25", "30", "35", "40", "45", "50"] + }, + { + "TableName": "6", + "questions": ["6 X 1", "6 X 2", "6 X 3", "6 X 4", "6 X 5", "6 X 6", "6 X 7", "6 X 8", "6 X 9", "6 X 10"], + "answers": ["6", "12", "18", "24", "30", "36", "42", "48", "54", "60"] + }, + { + "TableName": "7", + "questions": ["7 X 1", "7 X 2", "7 X 3", "7 X 4", "7 X 5", "7 X 6", "7 X 7", "7 X 8", "7 X 9", "7 X 10"], + "answers": ["7", "14", "21", "28", "35", "42", "48", "56", "63", "70"] + }, + { + "TableName": "8", + "questions": ["8 X 1", "8 X 2", "8 X 3", "8 X 4", "8 X 5", "8 X 6", "8 X 7", "8 X 8", "8 X 9", "8 X 10"], + "answers": ["8", "16", "24", "32", "40", "48", "56", "64", "72", "80"] + }, + { + "TableName": "9", + "questions": ["9 X 1", "9 X 2", "9 X 3", "9 X 4", "9 X 5", "9 X 6", "9 X 7", "9 X 8", "9 X 9", "9 X 10"], + "answers": ["9", "18", "27", "36", "45", "54", "63", "72", "81", "90"] + } ] } - - -