Warning, /sdk/cutehmi/extensions/CuteHMI/Symbols/HVAC.1/AirFilter.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.5 0002 0003 import CuteHMI.GUI 1.0 0004 0005 /** 0006 Air filter. 0007 */ 0008 Element { 0009 id: root 0010 0011 implicitWidth: units.quadrat * 0.5 0012 implicitHeight: units.quadrat * 1.5 0013 active: true 0014 warning: fill >= dirtyWarning 0015 alarm: fill >= dirtyAlarm 0016 0017 property bool mirror: false 0018 0019 // Number of filter pockets. 0020 property int pockets: 5 0021 0022 // Fill level (0.0 - 1.0). 0023 property real fill: 0.0 0024 0025 property real dirtyWarning: 0.75 0026 0027 property real dirtyAlarm: 0.9 0028 0029 property Component frame: Component { 0030 SymbolCanvas { 0031 transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } 0032 0033 element: root 0034 0035 onPaint: { 0036 var ctx = getContext('2d') 0037 ctx.save() 0038 ctx.reset() 0039 0040 ctx.strokeStyle = root.color.stroke 0041 ctx.fillStyle = root.color.fill 0042 ctx.lineWidth = units.strokeWidth 0043 0044 var offset = units.strokeWidth / 2.0 0045 0046 // Draw case. 0047 ctx.rect(offset, offset, width - units.strokeWidth, height - units.strokeWidth) 0048 ctx.fill() 0049 ctx.stroke() 0050 0051 // Draw dirt. 0052 ctx.fillStyle = root.color.shade 0053 ctx.beginPath() 0054 var dirtWidth = (width - 2 * units.strokeWidth) * fill 0055 ctx.fillRect(width - units.strokeWidth - dirtWidth, units.strokeWidth, dirtWidth, height - 2 * units.strokeWidth) 0056 ctx.fill() 0057 0058 ctx.restore() 0059 } 0060 0061 Connections { 0062 target: root 0063 0064 function onFillChanged() { 0065 requestPaint() 0066 } 0067 } 0068 } 0069 } 0070 0071 property Component content: Component { 0072 SymbolCanvas { 0073 transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } 0074 0075 element: root 0076 0077 onPaint: { 0078 var ctx = getContext('2d') 0079 ctx.save() 0080 ctx.reset() 0081 0082 ctx.strokeStyle = root.color.stroke 0083 ctx.fillStyle = root.color.tint 0084 ctx.lineWidth = units.strokeWidth 0085 0086 // Draw pockets. 0087 var offset = units.strokeWidth / 2.0 0088 var pocketHeight = (height - units.strokeWidth) / pockets 0089 0090 ctx.beginPath() 0091 var y = pocketHeight / 2.0 0092 ctx.moveTo(width - units.strokeWidth, offset) 0093 ctx.lineTo(offset, offset) 0094 ctx.lineTo(width - units.strokeWidth, y) 0095 for (var i = 1; i < pockets; i++) { 0096 y += pocketHeight / 2.0 0097 ctx.lineTo(offset, y) 0098 y += pocketHeight / 2.0 0099 ctx.lineTo(width - units.strokeWidth, y) 0100 } 0101 ctx.lineTo(offset, height - offset) 0102 ctx.lineTo(width - units.strokeWidth, height - offset) 0103 ctx.fill() 0104 ctx.stroke() 0105 0106 ctx.restore() 0107 } 0108 0109 Connections { 0110 target: root 0111 0112 function onPocketsChanged() { 0113 requestPaint() 0114 } 0115 } 0116 } 0117 } 0118 0119 Loader { 0120 width: root.width 0121 height: root.height 0122 sourceComponent: frame 0123 } 0124 0125 Loader { 0126 width: root.width 0127 height: root.height 0128 sourceComponent: content 0129 } 0130 } 0131 0132 //(c)C: Copyright © 2020-2021, Michał Policht <michal@policht.pl>. All rights reserved. 0133 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT 0134 //(c)C: This file is a part of CuteHMI. 0135 //(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. 0136 //(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. 0137 //(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/>. 0138 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below. 0139 //(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 0140 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 0141 //(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.