20 Accessible.ignored: true
32 component IconData: QtObject {
35 property real width: -1
36 property real height: -1
41 property IconData icon: IconData {}
44 property alias text: label.text
47 property alias typescale: label.typescale
50 property alias lineHeight: label.lineHeight
53 property alias color: label.color
56 property real textOpacity: 1.0
59 property bool mirrored: false
62 property bool mirrorIconInRtl: false
67 readonly property bool hasIcon: icon.name.length > 0 || icon.source.toString().length > 0
72 readonly property bool showIcon: hasIcon && display !== IconLabel.TextOnly
77 readonly property bool showText: text.length > 0 && display !== IconLabel.IconOnly
82 property int display: IconLabel.TextBesideIcon
87 readonly property int effectiveDisplay: {
89 case IconLabel.TextBesideIcon:
90 case IconLabel.TextUnderIcon:
91 if (showIcon && showText)
102 property real spacing: MD.Tokens.measurement.space100
107 readonly
property real effectiveSpacing: showIcon && showText ? spacing : 0
110 switch (effectiveDisplay) {
112 return iconItem.implicitWidth;
114 return label.implicitWidth;
116 return iconItem.implicitWidth + label.implicitWidth + effectiveSpacing;
118 return Math.max(iconItem.implicitWidth, label.implicitWidth);
122 switch (effectiveDisplay) {
124 return iconItem.implicitHeight;
126 return label.implicitHeight;
128 return Math.max(iconItem.implicitHeight, label.implicitHeight);
130 return iconItem.implicitHeight + label.implicitHeight + effectiveSpacing;
136 objectName:
"iconLabelIcon"
138 implicitWidth: root.icon.width
139 implicitHeight: root.icon.height
140 visible: root.showIcon
143 objectName:
"iconLabelMirrorTransform"
144 origin.x: iconItem.width / 2
145 origin.y: iconItem.height / 2
146 xScale: root.mirrorIconInRtl && root.mirrored ? -1 : 1
150 objectName:
"iconLabelSourceImage"
152 source: root.icon.source
153 sourceSize: Qt.size(root.icon.width, root.icon.height)
154 fillMode: Image.PreserveAspectFit
155 visible: root.icon.source.toString().length > 0
159 objectName:
"iconLabelSymbol"
162 iconWidth: root.icon.width
163 iconHeight: root.icon.height
164 color: root.icon.color.a > 0 ? root.icon.color : label.color
165 visible: root.icon.source.toString().length === 0 && name.length > 0
171 objectName:
"iconLabelText"
173 font.pixelSize: typescale.fontSize
174 font.weight: typescale.fontWeight
177 wrapMode: MD.Label.NoWrap
178 elide: MD.Label.ElideRight
179 opacity: root.textOpacity
180 visible: root.showText && opacity > 0
186 when: root.effectiveDisplay ===
IconLabel.IconOnly
190 anchors.left: undefined
191 anchors.right: undefined
192 anchors.top: undefined
193 anchors.bottom: undefined
194 anchors.horizontalCenter: root.horizontalCenter
195 anchors.verticalCenter: root.verticalCenter
200 anchors.left: undefined
201 anchors.right: undefined
202 anchors.top: undefined
203 anchors.bottom: undefined
204 anchors.horizontalCenter: undefined
205 anchors.verticalCenter: undefined
210 when: root.effectiveDisplay ===
IconLabel.TextOnly
214 anchors.left: undefined
215 anchors.right: undefined
216 anchors.top: undefined
217 anchors.bottom: undefined
218 anchors.horizontalCenter: root.horizontalCenter
219 anchors.verticalCenter: root.verticalCenter
224 anchors.left: undefined
225 anchors.right: undefined
226 anchors.top: undefined
227 anchors.bottom: undefined
228 anchors.horizontalCenter: undefined
229 anchors.verticalCenter: undefined
233 name:
"textBesideIcon"
234 when: root.effectiveDisplay ===
IconLabel.TextBesideIcon && !root.mirrored
238 anchors.left: root.left
239 anchors.right: undefined
240 anchors.top: undefined
241 anchors.bottom: undefined
242 anchors.horizontalCenter: undefined
243 anchors.verticalCenter: root.verticalCenter
248 anchors.left: iconItem.right
249 anchors.right: undefined
250 anchors.top: undefined
251 anchors.bottom: undefined
252 anchors.horizontalCenter: undefined
253 anchors.verticalCenter: root.verticalCenter
258 anchors.leftMargin: root.effectiveSpacing
259 anchors.rightMargin: 0
261 anchors.bottomMargin: 0
265 name:
"textBesideIconMirrored"
266 when: root.effectiveDisplay ===
IconLabel.TextBesideIcon && root.mirrored
270 anchors.left: undefined
271 anchors.right: root.right
272 anchors.top: undefined
273 anchors.bottom: undefined
274 anchors.horizontalCenter: undefined
275 anchors.verticalCenter: root.verticalCenter
280 anchors.left: undefined
281 anchors.right: iconItem.left
282 anchors.top: undefined
283 anchors.bottom: undefined
284 anchors.horizontalCenter: undefined
285 anchors.verticalCenter: root.verticalCenter
290 anchors.leftMargin: 0
291 anchors.rightMargin: root.effectiveSpacing
293 anchors.bottomMargin: 0
297 name:
"textUnderIcon"
298 when: root.effectiveDisplay ===
IconLabel.TextUnderIcon
302 anchors.left: undefined
303 anchors.right: undefined
304 anchors.top: root.top
305 anchors.bottom: undefined
306 anchors.horizontalCenter: root.horizontalCenter
307 anchors.verticalCenter: undefined
312 anchors.left: undefined
313 anchors.right: undefined
314 anchors.top: iconItem.bottom
315 anchors.bottom: undefined
316 anchors.horizontalCenter: root.horizontalCenter
317 anchors.verticalCenter: undefined
322 anchors.leftMargin: 0
323 anchors.rightMargin: 0
324 anchors.topMargin: root.effectiveSpacing
325 anchors.bottomMargin: 0
Lays out an icon and text as a single reusable visual.