Warning, /education/gcompris/src/activities/solar_system/PlanetInSolarModel.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - PlanetInSolarModel.qml
0002  *
0003  * SPDX-FileCopyrightText: 2018 Aman Kumar Gupta <gupta2140@gmail.com>
0004  *
0005  * Authors:
0006  *   Aman Kumar Gupta <gupta2140@gmail.com>
0007  *
0008  *   SPDX-License-Identifier: GPL-3.0-or-later
0009  */
0010 import QtQuick 2.12
0011 import GCompris 1.0
0012 import "../../core"
0013 import "solar_system.js" as Activity
0014 
0015 Item {
0016     id: planetItem
0017     width: background.itemWidth
0018     height: width
0019 
0020     property string planetImageSource
0021     property string planetName
0022     property double planetSize
0023     property bool planetHovered
0024     property bool hintMode
0025 
0026     // Name of the planet which hovers over the top of each planet
0027     GCText {
0028         id: planetNameText
0029         width: parent.width
0030         fontSizeMode: Text.Fit
0031         font.pointSize: NaN // need to clear font.pointSize explicitly
0032         font.pixelSize: parent.width * 0.18
0033         color: "white"
0034         text: planetName
0035 
0036         states: [
0037                 State {
0038                     name: "hScreen"
0039                     when: background.horizontalLayout
0040                     AnchorChanges {
0041                         target: planetNameText
0042                         anchors.bottom: planetItem.top
0043                         anchors.horizontalCenter: planetItem.horizontalCenter
0044                         anchors.left: undefined
0045                         anchors.verticalCenter: undefined
0046                     }
0047                     PropertyChanges {
0048                         target: planetNameText
0049                         anchors.bottomMargin: 20 * ApplicationInfo.ratio
0050                         anchors.leftMargin: 0
0051                         horizontalAlignment: Text.AlignHCenter
0052                     }
0053                 },
0054                 State {
0055                     name: "vScreen"
0056                     when: !background.horizontalLayout
0057                     AnchorChanges {
0058                         target: planetNameText
0059                         anchors.bottom: undefined
0060                         anchors.horizontalCenter: undefined
0061                         anchors.left: planetItem.right
0062                         anchors.verticalCenter: planetItem.verticalCenter
0063                     }
0064                     PropertyChanges {
0065                         target: planetNameText
0066                         anchors.bottomMargin: 0
0067                         anchors.leftMargin: 20 * ApplicationInfo.ratio
0068                         horizontalAlignment: Text.AlignLeft
0069                     }
0070                 }
0071 
0072         ]
0073 
0074         MouseArea {
0075             id: mouseAreaText
0076             anchors.fill: planetNameText
0077             enabled: !message.visible && !hintMode
0078             hoverEnabled: ApplicationInfo.isMobile ? false : true
0079             onEntered: planetHovered = true
0080             onExited: planetHovered = false
0081             onClicked: {
0082                 Activity.showQuizScreen(index)
0083             }
0084         }
0085     }
0086 
0087     Image {
0088         id: planetImage
0089         z: -10
0090         anchors.horizontalCenter: parent.horizontalCenter
0091         anchors.verticalCenter: parent.verticalCenter
0092         width: parent.width * planetSize
0093         height: planetImage.width
0094         fillMode: Image.PreserveAspectFit
0095         source: planetImageSource
0096     }
0097 
0098     states: [
0099             State {
0100                 name: "hover"
0101                 when: planetHovered
0102                 PropertyChanges {
0103                     target: planetNameText
0104                     scale: 1.2
0105                 }
0106                 PropertyChanges {
0107                     target: planetImage
0108                     scale: 1.2
0109                 }
0110             }
0111         ]
0112 
0113         Behavior on scale { NumberAnimation { duration: 70 } }
0114 
0115         MouseArea {
0116             id: mouseArea
0117             anchors.fill: planetItem
0118             enabled: !message.visible && !hintMode
0119             hoverEnabled: ApplicationInfo.isMobile ? false : true
0120             onEntered: planetHovered = true
0121             onExited: planetHovered = false
0122             onClicked: {
0123                 Activity.showQuizScreen(index)
0124             }
0125         }
0126 }