QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCColoredImage.qml
Go to the documentation of this file.
1import QtQuick
2
3import QGroundControl
4
5// Tints an SVG (or raster) by routing through the `coloredsvg` C++ image provider,
6// which rasterizes the source and composites the tint over its alpha mask.
7Item {
8 id: root
9
10 property color color: "white"
11 property url source
12
13 property alias asynchronous: image.asynchronous
14 property alias cache: image.cache
15 property alias fillMode: image.fillMode
16 property alias horizontalAlignment: image.horizontalAlignment
17 property alias mirror: image.mirror
18 property alias paintedHeight: image.paintedHeight
19 property alias paintedWidth: image.paintedWidth
20 property alias progress: image.progress
21 property alias mipmap: image.mipmap
22 property alias sourceSize: image.sourceSize
23 property alias status: image.status
24 property alias verticalAlignment: image.verticalAlignment
25
26 width: image.width
27 height: image.height
28
29 // Strip qrc: scheme and ensure leading '/' so the provider URL stays well-formed.
30 readonly property string _path: {
31 let s = source.toString()
32 if (s.length === 0) return ""
33 s = Qt.resolvedUrl(s).toString()
34 if (s.startsWith("qrc:/")) return s.substring(4)
35 if (s.startsWith("/")) return s
36 return "/" + s
37 }
38 // QColor in C++ parses "#" prefixes as URL fragments, so strip it.
39 readonly property string _hex: color.toString().replace("#", "")
40
41 Image {
42 id: image
43 smooth: true
44 mipmap: true
45 antialiasing: true
46 asynchronous: true
47 fillMode: Image.PreserveAspectFit
48 anchors.fill: parent
49 sourceSize.height: height
50 source: root._path.length > 0
51 ? "image://coloredsvg" + root._path + "?color=" + root._hex
52 : ""
53 }
54}