Warning, /education/gcompris/src/activities/renewable_energy/Solar.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - solar.qml
0002 *
0003 * SPDX-FileCopyrightText: 2015 Sagar Chand Agarwal <atomsagar@gmail.com>
0004 * SPDX-FileCopyrightText: 2022 Timothée Giet <animtim@gmail.com>
0005 *
0006 * Authors:
0007 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version)
0008 * Sagar Chand Agarwal <atomsagar@gmail.com> (Qt Quick port)
0009 * Timothée Giet <animtim@gmail.com> (Big refactoring)
0010 *
0011 * SPDX-License-Identifier: GPL-3.0-or-later
0012 */
0013 import QtQuick 2.12
0014 import GCompris 1.0
0015 import "../../core"
0016
0017 Item {
0018 id: solar
0019 property alias power: solarTransformer.power
0020
0021 function stop() {
0022 solarTransformer.started = false
0023 solarPanel.started = false
0024 }
0025
0026 Image {
0027 id: panelPower
0028 source: activity.url + "solar/" + (solarPanel.power ? "solar_wire_on.svg" : "solar_wire_off.svg")
0029 width: parent.width * 0.103
0030 sourceSize.width: width
0031 fillMode: Image.PreserveAspectFit
0032 anchors {
0033 top: parent.top
0034 left: parent.left
0035 topMargin: parent.width * 0.346
0036 leftMargin: parent.width * 0.783
0037 }
0038 }
0039
0040 Image {
0041 id: solarPower
0042 source: activity.url + "solar/" + (solarTransformer.power ? "solar_power_on.svg" : "solar_power_off.svg")
0043 width: parent.width * 0.098
0044 sourceSize.width: width
0045 fillMode: Image.PreserveAspectFit
0046 anchors {
0047 top: parent.top
0048 left: parent.left
0049 topMargin: parent.width * 0.448
0050 leftMargin: parent.width * 0.78
0051 }
0052 }
0053
0054 Image {
0055 id: solarTransformer
0056 source: activity.url + "transformer_off.svg"
0057 width: parent.width * 0.05
0058 sourceSize.width: width
0059 fillMode: Image.PreserveAspectFit
0060 anchors {
0061 top: parent.top
0062 left: parent.left
0063 topMargin: parent.width * 0.417
0064 leftMargin: parent.width * 0.866
0065 }
0066 property bool started: false
0067 property int power: started ? solarPanel.power : 0
0068 MouseArea {
0069 anchors.centerIn: parent
0070 // Size the area for a touch screen
0071 width: parent.width * 1.2
0072 height: parent.height * 1.2
0073 onClicked: parent.started = !parent.started
0074 }
0075 }
0076
0077 Image {
0078 id: solarTransformerOn
0079 visible: solarTransformer.started
0080 source: activity.url + "transformer_on.svg"
0081 anchors.fill: solarTransformer
0082 sourceSize.width: width
0083 fillMode: Image.PreserveAspectFit
0084 }
0085
0086 Rectangle {
0087 width: solar_info.width * 1.1
0088 height: solar_info.height * 1.1
0089 border.color: items.produceColorBorder
0090 radius: 5
0091 color: items.produceColor
0092 anchors {
0093 left: solarTransformer.horizontalCenter
0094 bottom: solarTransformer.top
0095 }
0096 GCText {
0097 id: solar_info
0098 fontSize: smallSize * 0.5
0099 anchors.centerIn: parent
0100 text: solar.power.toString() + "W"
0101 }
0102 }
0103
0104 Image {
0105 id: solarPanel
0106 source: activity.url + "solar/solar_panel_off.svg"
0107 width: parent.width * 0.093
0108 sourceSize.width: width
0109 fillMode: Image.PreserveAspectFit
0110 anchors {
0111 top: parent.top
0112 left: parent.left
0113 topMargin: parent.height * 0.326
0114 leftMargin: parent.width * 0.771
0115 }
0116 property bool started: false
0117 property int power: started && items.sunIsUp ? 1000 : 0
0118 MouseArea {
0119 anchors.fill: parent
0120 onClicked: parent.started = !parent.started
0121 }
0122 }
0123
0124 Image {
0125 id: solarPanelOn
0126 visible: solarPanel.power
0127 source: activity.url + "solar/solar_panel_on.svg"
0128 anchors.fill: solarPanel
0129 sourceSize.width: width
0130 fillMode: Image.PreserveAspectFit
0131 }
0132 }