Commit dd998f19 authored by Michal Policht's avatar Michal Policht

Add valve symbol.

parent fba5707a
Pipeline #15383 passed with stages
in 14 minutes and 15 seconds
......@@ -21,7 +21,7 @@ Project {
"BasicDiscreteInstrumentSettings.qml",
"BladeDamperSettings.qml",
"CentrifugalFanSettings.qml",
"ElementSettings.qml",
"ElementSettings.qml",
"HeatRecoveryWheelSettings.qml",
"LICENSE",
"Main.qml",
......@@ -29,6 +29,7 @@ Project {
"PumpSettings.qml",
"README.md",
"TankSettings.qml",
"ValveSettings.qml",
]
Depends { name: "cutehmi.doxygen" }
......
......@@ -285,6 +285,24 @@ Rectangle {
tank: tank
}
Label {
Layout.alignment: Qt.AlignCenter
text: qsTr("Valve")
}
Valve {
id: valve
Layout.alignment: Qt.AlignCenter
}
ValveSettings {
Layout.alignment: Qt.AlignTop
valve: valve
}
}
}
}
......
import QtQml 2.2
import QtQuick 2.11
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import CuteHMI.Symbols.HVAC 0.0
ElementSettings {
element: valve
property Valve valve
GroupBox {
title: qsTr("Custom properties")
Layout.fillWidth: true
GridLayout {
columns: 2
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Left way:")
}
CheckBox {
checked: valve.leftWay
onCheckedChanged: valve.leftWay = checked
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Right way:")
}
CheckBox {
checked: valve.rightWay
onCheckedChanged: valve.rightWay = checked
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Top way:")
}
CheckBox {
checked: valve.topWay
onCheckedChanged: valve.topWay = checked
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Bottom way:")
}
CheckBox {
checked: valve.bottomWay
onCheckedChanged: valve.bottomWay = checked
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Left closed:")
}
CheckBox {
checked: valve.leftClosed
onCheckedChanged: valve.leftClosed = checked
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Right closed:")
}
CheckBox {
checked: valve.rightClosed
onCheckedChanged: valve.rightClosed = checked
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Top closed:")
}
CheckBox {
checked: valve.topClosed
onCheckedChanged: valve.topClosed = checked
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Bottom closed:")
}
CheckBox {
checked: valve.bottomClosed
onCheckedChanged: valve.bottomClosed = checked
}
}
}
}
//(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
//(c)C: This file is a part of CuteHMI.
//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
......@@ -33,6 +33,7 @@ Project {
"README.md",
"SymbolCanvas.qml",
"Tank.qml",
"Valve.qml",
"designer/HVAC.metainfo",
]
......
import QtQuick 2.5
import CuteHMI.GUI 0.0
/**
Valve.
*/
Element {
id: root
implicitWidth: childrenRect.width
implicitHeight: childrenRect.height
active: true
property bool leftWay: true
property bool rightWay: true
property bool topWay: false
property bool bottomWay: false
property bool leftClosed: false
property bool rightClosed: false
property bool topClosed: false
property bool bottomClosed: false
property Component way: Component {
SymbolCanvas {
id: canvas
implicitWidth: units.quadrat * 0.25
implicitHeight: units.quadrat * 0.25
element: root
onPaint: {
var ctx = getContext('2d')
ctx.save()
ctx.reset()
ctx.strokeStyle = root.color.stroke
if (closed)
ctx.fillStyle = root.color.stroke
else
ctx.fillStyle = root.color.fill
ctx.lineWidth = units.strokeWidth
var offset = units.strokeWidth / 2.0
ctx.moveTo(offset, offset)
ctx.lineTo(width - offset, height * 0.5)
ctx.lineTo(offset, height - offset)
ctx.closePath()
ctx.fill()
ctx.stroke()
ctx.restore()
}
Connections {
target: parent
onClosedChanged: requestPaint()
}
}
}
Loader {
y: topWay ? 0.5 * height : 0
width: item ? item.implicitWidth : 0
height: item ? item.implicitHeight : 0
sourceComponent: leftWay ? way : undefined
property bool closed: leftClosed
}
Loader {
x: leftWay ? width : (topWay || bottomWay) ? width * 0.5 : 0
y: topWay ? 0.5 * height : 0
width: item ? item.implicitWidth : 0
height: item ? item.implicitHeight : 0
rotation: 180
sourceComponent: rightWay ? way : undefined
property bool closed: rightClosed
}
Loader {
x: leftWay ? width * 0.5 : 0
width: item ? item.implicitWidth : 0
height: item ? item.implicitHeight : 0
rotation: 90
sourceComponent: topWay ? way : undefined
property bool closed: topClosed
}
Loader {
x: leftWay ? width * 0.5 : 0
y: topWay ? height : (leftWay || rightWay) ? height * 0.5 : 0
width: item ? item.implicitWidth : 0
height: item ? item.implicitHeight : 0
rotation: -90
sourceComponent: bottomWay ? way : undefined
property bool closed: bottomClosed
}
}
//(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
//(c)C: This file is a part of CuteHMI.
//(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
//(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
......@@ -193,4 +193,17 @@ MetaInfo {
requiredImport: "CuteHMI.Symbols.HVAC"
}
}
Type {
name: "CuteHMI.Symbols.HVAC.Valve"
icon: ":/qtquickplugin/images/item-icon16.png"
ItemLibraryEntry {
name: "Valve"
category: "CuteHMI - Symbols - HVAC 0"
libraryIcon: ":/qtquickplugin/images/item-icon.png"
version: "0.0"
requiredImport: "CuteHMI.Symbols.HVAC"
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment