Warning, /education/gcompris/src/activities/binary_bulb/LightBulb.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - LightBulb.qml 0002 * 0003 * SPDX-FileCopyrightText: 2018 Rajat Asthana <rajatasthana4@gmail.com> 0004 * 0005 * Authors: 0006 * RAJAT ASTHANA <rajatasthana4@gmail.com> 0007 * 0008 * SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 import QtQuick 2.12 0011 import "../../core" 0012 import GCompris 1.0 0013 import "binary_bulb.js" as Activity 0014 0015 Item { 0016 id: bulb 0017 anchors.verticalCenter: parent.verticalCenter 0018 state: "off" 0019 focus: true 0020 0021 property alias valueVisible: valueText.visible 0022 0023 Rectangle { 0024 color: "transparent" 0025 width: parent.width + 10 0026 height: parent.height + 10 0027 border.color: "red" 0028 border.width: 3 0029 anchors.centerIn: bulbImage 0030 radius: 5 0031 visible: index == items.currentSelectedBulb 0032 } 0033 Image { 0034 id: bulbImage 0035 width: parent.width 0036 sourceSize.width: parent.width 0037 fillMode: Image.PreserveAspectFit 0038 source: "resource/bulb_off.svg" 0039 } 0040 property string bit: "" 0041 readonly property int value: Math.pow(2, items.numberOfBulbs - index - 1) 0042 0043 GCText { 0044 id: valueText 0045 anchors.bottom: parent.top 0046 anchors.horizontalCenter: parent.horizontalCenter 0047 text: value 0048 color: "white" 0049 } 0050 0051 MouseArea { 0052 anchors.fill: parent 0053 enabled: !items.buttonsBlocked 0054 onClicked: Activity.changeState(index) 0055 } 0056 0057 GCText { 0058 anchors.top: bulb.bottom 0059 anchors.horizontalCenter: parent.horizontalCenter 0060 text: bit 0061 color: "white" 0062 } 0063 0064 states: [ 0065 State { 0066 name: "off" 0067 PropertyChanges { 0068 target: bulb 0069 bit: "0" 0070 } 0071 PropertyChanges { 0072 target: bulbImage 0073 source: "resource/bulb_off.svg" 0074 } 0075 }, 0076 State { 0077 name: "on" 0078 PropertyChanges { 0079 target: bulb 0080 bit: "1" 0081 } 0082 PropertyChanges { 0083 target: bulbImage 0084 source: "resource/bulb_on.svg" 0085 } 0086 } 0087 ] 0088 }