| 1 |
/* GCompris - DigitalLight.qml |
| 2 |
* |
| 3 |
* SPDX-FileCopyrightText: 2016 Pulkit Gupta <[email protected]> |
| 4 |
* |
| 5 |
* Authors: |
| 6 |
* Bruno Coudoin <[email protected]> (GTK+ version) |
| 7 |
* Pulkit Gupta <[email protected]> (Qt Quick port) |
| 8 |
* |
| 9 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 10 |
*/ |
| 11 |
import QtQuick |
| 12 |
import core 1.0 |
| 13 |
|
| 14 |
ElectricalComponent { |
| 15 |
id: digitalLight |
| 16 |
terminalSize: 0.25 |
| 17 |
noOfInputs: 1 |
| 18 |
noOfOutputs: 0 |
| 19 |
|
| 20 |
information: qsTr("A digital light is used to check the output of other digital components. It turns " + |
| 21 |
"green if the input is 1, and turns red if the input is 0.") |
| 22 |
|
| 23 |
truthTable: [] |
| 24 |
|
| 25 |
property alias inputTerminals: inputTerminals |
| 26 |
|
| 27 |
Repeater { |
| 28 |
id: inputTerminals |
| 29 |
model: 1 |
| 30 |
delegate: inputTerminal |
| 31 |
Component { |
| 32 |
id: inputTerminal |
| 33 |
TerminalPoint { |
| 34 |
posX: 0.1 |
| 35 |
posY: 0.5 |
| 36 |
type: "In" |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
function updateOutput(wireVisited) { |
| 42 |
if(inputTerminals.itemAt(0).value == 1) |
| 43 |
imgSrc = "DigitalLightOn.svg" |
| 44 |
else |
| 45 |
imgSrc = "DigitalLightOff.svg" |
| 46 |
} |
| 47 |
} |