Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question and answer activity #230

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/activities/activities.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ paintings
penalty
photo_hunter
planegame
question_and_answer
railroad
readingh
readingv
Expand Down
40 changes: 40 additions & 0 deletions src/activities/question_and_answer/ActivityInfo.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* GCompris - ActivityInfo.qml
*
* Copyright (C) 2018 Amit Sagtani <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/
import GCompris 1.0

ActivityInfo {
name: "question_and_answer/Question_and_answer.qml"
difficulty: 3
icon: "question_and_answer/question_and_answer.svg"
author: "Amit Sagtani &lt;[email protected]&gt;"
demo: true
//: Activity title
title: "Question_and_answer activity"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no underscore in title, use a real name (that will be displayed on screen)

//: Help title
description: ""
//intro: "put here in comment the text for the intro voice"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to be updated

//: Help goal
goal: ""
//: Help prerequisite
prerequisite: ""
//: Help manual
manual: ""
credit: ""
section: "fun"
createdInVersion: 9500
}
1 change: 1 addition & 0 deletions src/activities/question_and_answer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GCOMPRIS_ADD_RCC(activities/question_and_answer *.qml *.svg *.js resource/*)
219 changes: 219 additions & 0 deletions src/activities/question_and_answer/MenuScreen.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
/* GCompris - MenuScreen.qml
*
* Copyright (C) Amit Sagtani <[email protected]>
*
* Authors:
* Pascal Georges ([email protected]) (GTK+ version)
* Holger Kaelberer <[email protected]> (Qt Quick port of imageid)
* Siddhesh suthar <[email protected]> (Qt Quick port)
* Bruno Coudoin <[email protected]> (Integration Lang dataset)
*
* 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 <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.6
import GCompris 1.0
import QtGraphicalEffects 1.0
import QtQuick.Controls 1.5

import "../../core"
import "question_and_answer.js" as Activity

Image {
id: menuScreen
anchors.fill: parent
fillMode: Image.Tile
source: "qrc:/gcompris/src/activities/digital_electricity/resource/texture02.png" //"qrc:/gcompris/src/activities/algebra_by/resource/background.svg"
sourceSize.width: Math.max(parent.width, parent.height)
opacity: 0

property alias menuModel: menuModel
//property alias iAmReady: iAmReady
property bool keyboardMode: false
property bool started: opacity == 1

Behavior on opacity { PropertyAnimation { duration: 200 } }

visible: opacity != 0

function start() {
focus = true
forceActiveFocus()
menuGrid.currentIndex = 0
opacity = 1
}

function stop() {
focus = false
opacity = 0
}

Keys.onEscapePressed: {
home()
}

//Keys.enabled : (items.mode == "expert") ? false : true
Keys.onPressed: {
if(event.key === Qt.Key_Space) {
menuGrid.currentItem.selectCurrentItem()
event.accepted = true
}
if(event.key === Qt.Key_Enter) {
menuGrid.currentItem.selectCurrentItem()
event.accepted = true
}
if(event.key === Qt.Key_Return) {
menuGrid.currentItem.selectCurrentItem()
event.accepted = true
}
if(event.key === Qt.Key_Left) {
menuGrid.moveCurrentIndexLeft()
event.accepted = true
}
if(event.key === Qt.Key_Right) {
menuGrid.moveCurrentIndexRight()
event.accepted = true
}
if(event.key === Qt.Key_Up) {
menuGrid.moveCurrentIndexUp()
event.accepted = true
}
if(event.key === Qt.Key_Down) {
menuGrid.moveCurrentIndexDown()
event.accepted = true
}
}

Keys.onReleased: {
keyboardMode = true
event.accepted = false
}

// sections
property int iconWidth: 180 * ApplicationInfo.ratio
property int iconHeight: 180 * ApplicationInfo.ratio

property int levelCellWidth: background.width / Math.floor(background.width / iconWidth )
property int levelCellHeight: iconHeight * 1.2

ListModel {
id: menuModel
}

GridView {
id: menuGrid
anchors {
fill: parent
bottomMargin: bar.height
}
cellWidth: levelCellWidth
cellHeight: levelCellHeight
clip: true
model: menuModel
keyNavigationWraps: true
property int spacing: 10

delegate: Item {
id: delegateItem
width: levelCellWidth - menuGrid.spacing
height: levelCellHeight - menuGrid.spacing
property string sectionName: name
opacity: 1

Rectangle {
id: activityBackground
width: levelCellWidth - menuGrid.spacing
height: levelCellHeight - menuGrid.spacing
anchors.horizontalCenter: parent.horizontalCenter
color: "white"
opacity: 0.5
}

Image {
id: containerImage
source: image
anchors.top: activityBackground.top
anchors.horizontalCenter: parent.horizontalCenter
height: activityBackground.height*0.8 - 6
width: height
anchors.margins: 5
sourceSize.height: height
fillMode: Image.PreserveAspectCrop
clip: true
}

GCText {
id: categoryName
anchors.top: containerImage.bottom
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
width: activityBackground.width
height: activityBackground.height*0.2 - 6
fontSizeMode: Text.Fit
elide: Text.ElideRight
maximumLineCount: 2
wrapMode: Text.WordWrap
text: name
opacity: 1 //(items.mode == "expert") ? 0 : 1
}

ParticleSystemStarLoader {
id: particles
anchors.fill: activityBackground
}
MouseArea {
anchors.fill: activityBackground
enabled: menuScreen.started
onClicked: selectCurrentItem()
}

function selectCurrentItem() {
particles.burst(50)
console.log(name)
Activity.initializeSubActivity(index)
menuScreen.stop()
}

} //delegate close

highlight: Rectangle {
width: levelCellWidth - menuGrid.spacing
height: levelCellHeight - menuGrid.spacing
color: "#AA41AAC4"
border.width: 3
border.color: "black"
visible: true
Behavior on x { SpringAnimation { spring: 2; damping: 0.2 } }
Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } }
}

Rectangle {
id: menusMask
visible: false
anchors.fill: menuGrid
gradient: Gradient {
GradientStop { position: 0.0; color: "#FFFFFFFF" }
GradientStop { position: 0.92; color: "#FFFFFFFF" }
GradientStop { position: 0.96; color: "#00FFFFFF" }
}
}

layer.enabled: ApplicationInfo.useOpenGL
layer.effect: OpacityMask {
id: activitiesOpacity
source: menuGrid
maskSource: menusMask
anchors.fill: menuGrid
}
} // grid view close
}
Loading