Warning, /education/gcompris/src/activities/letter-in-word/Card.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - Card.qml 0002 * 0003 * SPDX-FileCopyrightText: 2016 Akshat Tandon <akshat.tandon@research.iiit.ac.in> 0004 * 2020 Timothée Giet <animtim@gmail.com> 0005 * 0006 * Authors: 0007 * Akshat Tandon <akshat.tandon@research.iiit.ac.in> 0008 * Timothée Giet <animtim@gmail.com> 0009 * 0010 * SPDX-License-Identifier: GPL-3.0-or-later 0011 */ 0012 0013 import QtQuick 2.12 0014 import GCompris 1.0 0015 import QtGraphicalEffects 1.0 0016 import "../../core" 0017 import "letter-in-word.js" as Activity 0018 0019 Rectangle { 0020 id: cardItem 0021 property bool mouseActive: true 0022 color: "#01FFFFFF" //setting the base as not totally transparent rectangle avoids the bug of randomly overlapping images when highlight moves 0023 0024 Image { 0025 id: wordPic 0026 width: cardItem.width * 0.8 0027 height: width 0028 anchors.top: parent.top 0029 anchors.horizontalCenter: parent.horizontalCenter 0030 sourceSize.width: width 0031 fillMode: Image.PreserveAspectFit 0032 source: imgurl 0033 } 0034 0035 Rectangle { 0036 width: cardBg.width + 10 * ApplicationInfo.ratio 0037 height: cardBg.height + 10 * ApplicationInfo.ratio 0038 radius: 15 * ApplicationInfo.ratio 0039 color: "#00000000" 0040 border.width: 5 * ApplicationInfo.ratio + 1 // +1 to avoid subpixel holes around cardBg 0041 border.color: "#E77936" 0042 anchors.centerIn: cardBg 0043 visible: selected 0044 } 0045 0046 Rectangle { 0047 id: cardBg 0048 anchors.horizontalCenter: parent.horizontalCenter 0049 anchors.bottom: parent.bottom 0050 width: wordPic.width 0051 height: wordPic.height * 0.5 0052 radius: 10 * ApplicationInfo.ratio 0053 color: "#E0FFFFFF" 0054 0055 GCText { 0056 id: textItem 0057 text: spelling 0058 font.pointSize: NaN // need to clear font.pointSize explicitly 0059 fontSizeMode: Text.Fit 0060 minimumPixelSize: 10 0061 font.pixelSize: cardBg.width * 0.30 0062 font.bold: true 0063 style: Text.Outline 0064 width: cardBg.width 0065 height: cardBg.height 0066 wrapMode: spelling.indexOf(' ') === -1 ? Text.WrapAnywhere : Text.WordWrap 0067 verticalAlignment: Text.AlignVCenter 0068 horizontalAlignment: Text.AlignHCenter 0069 styleColor: "white" 0070 } 0071 } 0072 0073 MouseArea { 0074 id: mouseArea 0075 anchors.fill: parent 0076 hoverEnabled: ApplicationInfo.isMobile ? false : true 0077 onClicked: { 0078 select(); 0079 } 0080 } 0081 0082 SequentialAnimation { 0083 id: selectAnimation 0084 NumberAnimation { 0085 target: cardItem 0086 easing.type: Easing.InOutQuad 0087 property: "rotation" 0088 to: 20; duration: 250 0089 } 0090 NumberAnimation { 0091 target: cardItem 0092 easing.type: Easing.InOutQuad 0093 property: "rotation"; to: -20 0094 duration: 500 0095 } 0096 NumberAnimation { 0097 target: cardItem 0098 easing.type: Easing.InOutQuad 0099 property: "rotation" 0100 to: 0 0101 duration: 250 0102 } 0103 } 0104 0105 function playWord() { 0106 var locale = ApplicationInfo.getVoicesLocale(items.locale) 0107 activity.audioVoices.append( 0108 ApplicationInfo.getAudioFilePathForLocale(voice, locale)) 0109 } 0110 0111 function select() { 0112 if(mouseActive) { 0113 if(Activity.checkWord(index)) { 0114 selectAnimation.restart(); 0115 if(selected) 0116 playWord(); 0117 } 0118 } 0119 } 0120 }