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 const s = source.toString()
32 if (s.length === 0) return ""
33 if (s.startsWith("qrc:/")) return s.substring(4)
34 if (s.startsWith("/")) return s
35 return "/" + s
36 }
37 // QColor in C++ parses "#" prefixes as URL fragments, so strip it.
38 readonly property string _hex: color.toString().replace("#", "")
39
40 Image {
41 id: image
42 smooth: true
43 mipmap: true
44 antialiasing: true
45 asynchronous: true
46 fillMode: Image.PreserveAspectFit
47 anchors.fill: parent
48 sourceSize.height: height
49 source: root._path.length > 0
50 ? "image://coloredsvg" + root._path + "?color=" + root._hex
51 : ""
52 }
53}