diff --git a/src/activities/multiplication_tables/Multiplication_tables.qml b/src/activities/multiplication_tables/Multiplication_tables.qml --- a/src/activities/multiplication_tables/Multiplication_tables.qml +++ b/src/activities/multiplication_tables/Multiplication_tables.qml @@ -1,29 +1,30 @@ /* 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 . - */ +* +* 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 "." import "multiplication_tables.js" as Activity import "multiplicationtables_dataset.js" as Dataset @@ -39,7 +40,7 @@ pageComponent: Rectangle { id: background - anchors.fill: parent + anchors.fill: parent color: "#ABCDEF" signal start signal stop @@ -53,9 +54,10 @@ QtObject { id: items property Item main: activity.main - property alias background: background - property alias bar: bar + property alias background: background + property alias bar: bar property alias bonus: bonus + property string mode2: "normalMode" property alias start_button: start_button property alias stop_button: stop_button property alias time: time @@ -100,86 +102,6 @@ height: bar.height * 1.2 } - Button { - id: stop_button - text: qsTr("FINISH") - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors { - bottomMargin: bar.height * 0.4 - rightMargin: bar.height * 1.5 - } - - style: ButtonStyle { - background: Rectangle { - implicitWidth: bar.height * 0.9 - implicitHeight: bar.height * 0.3 - 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 (startButtonClicked == true) { - score.visible = true - var str1 = (new Date().getTime() - startTime)/1000 - time.text = qsTr("Your time: %1 seconds").arg(str1) - startTime = 0 - startButtonClicked = false - start_button.text = qsTr("START AGAIN") - Activity.verifyAnswer() - Activity.cannotAnswer() - } - } - } - - Button { - id: start_button - text: qsTr("START") - anchors.bottom: parent.bottom - anchors.right: stop_button.left - anchors { - bottomMargin: bar.height * 0.4 - rightMargin: bar.height * 0.4 - } - style: ButtonStyle { - background: Rectangle { - implicitWidth: bar.height * 0.9 - implicitHeight: bar.height * 0.3 - 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 (startTime == 0 && startButtonClicked == false) { - Activity.resetvalue() - Activity.canAnswer() - start_button.text = qsTr("START") - time.text = qsTr(" Your Timer Started...") - startTime = new Date().getTime() - startButtonClicked = true - } - } - } - GCText { id: score font.pointSize: 20 @@ -189,7 +111,7 @@ anchors.right: parent.right anchors { bottomMargin: bar.height * 0.09 - rightMargin: bar.height * 1.6 + rightMargin: bar.height * 1.8 } Layout.alignment: Qt.AlignCenter } @@ -199,52 +121,90 @@ font.pixelSize: 23 font.bold: true color: '#4B6319' - anchors.bottom: start_button.top + anchors.bottom: start_stop_buttons.top anchors.right: parent.right anchors { bottomMargin: bar.height * 0.3 - rightMargin: 130 + rightMargin: bar.height * 1.3 } - text: qsTr("--") + text: "--" Layout.alignment: Qt.AlignCenter } - DialogActivityConfig { - id: dialogActivityConfig - currentActivity: activity - content: Component { - Item { - height: column.height - Column { - id: column - spacing: 10 - width: parent.width + Flow{ + id: start_stop_buttons + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors { + bottomMargin: bar.height * 0.4 + rightMargin: bar.height * 1.5 + } - GCDialogCheckBox { - id: easyModeBox1 - width: 250 * ApplicationInfo.ratio - text: qsTr("School Mode") - checked: background.easyMode - onCheckedChanged: { - background.easyMode = checked - Activity.reloadRandom() + Button { + id: start_button + text: qsTr("START") + style: ButtonStyle { + background: Rectangle { + implicitWidth: bar.height * 0.9 + implicitHeight: bar.height * 0.3 + 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 (startTime == 0 && startButtonClicked == false) { + Activity.resetvalue() + Activity.canAnswer() + start_button.text = qsTr("START") + time.text = qsTr(" Your Timer Started...") + startTime = new Date().getTime() + startButtonClicked = true + } + } } - onLoadData: { - if (dataToSave && dataToSave["mode"]) { - background.easyMode = (dataToSave["mode"] === "true"); + Button { + id: stop_button + text: qsTr("FINISH") + style: ButtonStyle { + background: Rectangle { + implicitWidth: bar.height * 0.9 + implicitHeight: bar.height * 0.3 + 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" + } + } + } } - } - onSaveData: { - dataToSave = { - "mode": "" + background.easyMode + onClicked: { + if (startButtonClicked == true) { + score.visible = true + var str1 = (new Date().getTime() - startTime)/1000 + time.text = qsTr("Your time:- %1 seconds").arg(str1) + startTime = 0 + startButtonClicked = false + start_button.text = qsTr("START AGAIN") + Activity.verifyAnswer() + Activity.cannotAnswer() + } } } - onClose: home() } DialogHelp { @@ -252,6 +212,54 @@ onClose: home() } + DialogActivityConfig { + id: dialogActivityConfig + content: Component { + Column { + id: column + spacing: 5 + width: dialogActivityConfig.width + height: dialogActivityConfig.height + property alias normalMode: normalMode + property alias schoolMode: schoolMode + + GCDialogCheckBox { + id: normalMode + width: column.width - 50 + text: qsTr("Normal mode") + checked: (items.mode2 == "normalMode") ? true : false + onCheckedChanged: { + if(normalMode.checked) { + items.mode2 = "normalMode" + } + } + } + GCDialogCheckBox { + id: schoolMode + width: normalMode.width + text: qsTr("School mode") + checked: (items.mode2 == "schoolMode") ? true : false + onCheckedChanged: { + if(schoolMode.checked) { + items.mode2 = "schoolMode" + } + } + } + } + } + onLoadData: { + if(dataToSave && dataToSave["mode2"]) + items.mode = dataToSave["mode2"] + if(dataToSave && dataToSave["displayUpdateDialogAtStart"]) + items.displayUpdateDialogAtStart = (dataToSave["displayUpdateDialogAtStart"] == "true") ? true : false + } + onSaveData: { + dataToSave["mode2"] = items.mode2 + dataToSave["displayUpdateDialogAtStart"] = items.displayUpdateDialogAtStart ? "true" : "false" + } + onClose: home() + } + Bar { id: bar content: BarEnumContent { diff --git a/src/activities/multiplication_tables/Question.qml b/src/activities/multiplication_tables/Question.qml --- a/src/activities/multiplication_tables/Question.qml +++ b/src/activities/multiplication_tables/Question.qml @@ -1,73 +1,71 @@ /* 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 . - */ +* +* +* 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 "multiplicationtables_dataset.js" as Dataset - import "../../core" import GCompris 1.0 Flow { - id: questionItem - property string url: "qrc:/gcompris/src/activities/multiplication_tables/resource/" - property alias questionText: questionText.text - property alias answerText: answerText.text - property alias answerTextReadonly: answerText.readOnly - property alias questionImage: question_image.source - property alias questionImageOpacity: question_image.opacity + id: questionItem + property string url: "qrc:/gcompris/src/activities/multiplication_tables/resource/" + property alias questionText: questionText.text + property alias answerText: answerText.text + property alias answerTextReadonly: answerText.readOnly + property alias questionImage: question_image.source + property alias questionImageOpacity: question_image.opacity GCText { - id: questionText - text:qsTr("Question") - font.pointSize: 20 - font.bold: true - color: "black" + id: questionText + text:qsTr("Question") + font.pointSize: 20 + font.bold: true + color: "black" } - TextField { - id: answerText - height: 35 - validator: IntValidator{bottom: 1; top: 200;} - activeFocusOnPress: true - readOnly: true - font.pixelSize: 20 - style: TextFieldStyle { - textColor: "#006060" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: bar.height * 0.9 - implicitHeight: bar.height * 0.3 - border.color: "#333" - border.width: 1 - } - - } + TextField { + id: answerText + height: 35 + validator: IntValidator{bottom: 1; top: 200;} + activeFocusOnPress: true + readOnly: true + font.pixelSize: 20 + style: TextFieldStyle { + textColor: "#006060" + background: Rectangle { + radius: 5 + color: "orange" + implicitWidth: bar.height * 0.9 + implicitHeight: bar.height * 0.3 + border.color: "#333" + border.width: 2 + } + } } - Image { - id: question_image - width: bar.height * 0.3 - height: bar.height * 0.3 - fillMode: Image.PreserveAspectFit - source: "qrc:/gcompris/src/activities/multiplication_tables/resource/wrong.svg" - opacity: 0 - } + Image { + id: question_image + width: bar.height * 0.3 + height: bar.height * 0.3 + 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 --- a/src/activities/multiplication_tables/multiplication_tables.js +++ b/src/activities/multiplication_tables/multiplication_tables.js @@ -1,30 +1,31 @@ /* 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 . - */ +* +* 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 schoolMode var items var mode var dataset @@ -48,7 +49,7 @@ function stop() {} function initLevel() { - items.bar.level = currentLevel + 1 + items.bar.level = currentLevel + 1 resetvalue(); items.start_button.text = qsTr("START") items.score.visible = false @@ -86,14 +87,14 @@ function canAnswer() { var q for (q = 0; q < question.length; q++) { - items.repeater.itemAt(q).answerTextReadonly = false + items.repeater.itemAt(q).answerTextReadonly = false } } function cannotAnswer() { var r for (r = 0; r < question.length; r++) { - items.repeater.itemAt(r).answerTextReadonly = true + items.repeater.itemAt(r).answerTextReadonly = true } } @@ -113,12 +114,12 @@ if (numberOfLevel <= ++currentLevel) { currentLevel = 0 } - initLevel(); + initLevel(); } function previousLevel() { if (--currentLevel < 0) { currentLevel = numberOfLevel - 1 } - initLevel(); + initLevel(); } diff --git a/src/activities/multiplication_tables/resource/README b/src/activities/multiplication_tables/resource/README new file mode 100644 --- /dev/null +++ b/src/activities/multiplication_tables/resource/README @@ -0,0 +1,8 @@ +image credits :- +1.) children.svg :- The image is copyright of Mathieu Ignacio (mignacio at april point org). +This is released under the GPL. + +2.) right.svg :- the image is taken from openclipart.org (https://openclipart.org/search/?query=right+tick) + +3.) wrong.svg :- the image is taken from openclipart.org (https://openclipart.org/detail/15815/right-or-wrong-5) +