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

0001 /* GCompris - CalcudokuCase.qml
0002  *
0003  * SPDX-FileCopyrightText: 2023 Johnny Jazeix <jazeix@gmail.com>
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 import QtQuick 2.12
0007 import "calcudoku.js" as Activity
0008 import GCompris 1.0
0009 import "../../core"
0010 
0011 
0012 Rectangle {
0013     id: mCase
0014     border.color: "#808080"
0015     border.width: 2 * Math.round(ApplicationInfo.ratio / 2)
0016     property string text
0017     property bool isInitial
0018     property string operator
0019     property string result
0020     property int gridIndex
0021 
0022     signal stop
0023 
0024     Component.onCompleted: {
0025         activity.stop.connect(stop);
0026     }
0027 
0028     onStop: {
0029         restoreColorTimer.stop();
0030     }
0031 
0032     Rectangle {
0033         id: resultOperatorBG
0034         visible: mCase.result != ""
0035         anchors.horizontalCenter: parent.horizontalCenter
0036         anchors.top: parent.top
0037         anchors.topMargin: parent.height * 0.05
0038         width: height * 3
0039         height: parent.height * 0.2
0040         color: "transparent"
0041         border.color: "#373737"
0042         border.width: Math.round(ApplicationInfo.ratio)
0043         radius: height * 0.5
0044         GCText {
0045             id: resultOperator
0046             text: mCase.result + mCase.operator
0047             anchors.fill: parent
0048             fontSizeMode: Text.Fit
0049             horizontalAlignment: Text.AlignHCenter
0050             verticalAlignment: Text.AlignVCenter
0051             color: "#373737"
0052         }
0053     }
0054 
0055     Image {
0056         id: imageId
0057         source: Activity.dataToImageSource(mCase.text)
0058         height: parent.height * 0.7
0059         width: height
0060         sourceSize.height: height
0061         sourceSize.width: width
0062         anchors.horizontalCenter: parent.horizontalCenter
0063         anchors.bottom: parent.bottom
0064         anchors.bottomMargin: 0.05 * parent.height
0065     }
0066 
0067     states: [
0068         State {
0069             name: "default"
0070             PropertyChanges {
0071                 target: mCase
0072                 color: "#D6F2FC"
0073             }
0074         },
0075         State {
0076             name: "error"
0077             PropertyChanges {
0078                 target: mCase
0079                 color: "#EB7878"
0080             }
0081             PropertyChanges {
0082                 target: restoreColorTimer
0083                 running: true
0084            }
0085         },
0086         State {
0087             name: "hovered"
0088             PropertyChanges {
0089                 target: mCase
0090                 color: "#78B4EB"
0091             }
0092         },
0093         State {
0094             name: "initial"
0095             PropertyChanges {
0096                 target: mCase
0097                 color: "#EAD9F2"
0098             }
0099         }
0100     ]
0101 
0102     Timer {
0103         id: restoreColorTimer
0104         interval: 1500
0105         repeat: false
0106         onTriggered: {
0107             Activity.restoreState(mCase)
0108         }
0109     }
0110 }