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 !== MD.IconLabel.TextOnly
77 readonly property bool showText: text.length > 0 && display !== MD.IconLabel.IconOnly
82 property int display: MD.IconLabel.TextBesideIcon
87 readonly property int effectiveDisplay: {
89 case MD.IconLabel.TextBesideIcon:
90 case MD.IconLabel.TextUnderIcon:
91 if (showIcon && showText)
93 return showIcon ? MD.IconLabel.IconOnly : MD.IconLabel.TextOnly;
102 property real spacing: MD.Tokens.measurement.space100
107 readonly
property real effectiveSpacing: showIcon && showText ? spacing : 0
110 switch (effectiveDisplay) {
111 case MD.IconLabel.IconOnly:
112 return iconItem.implicitWidth;
113 case MD.IconLabel.TextOnly:
114 return label.implicitWidth;
115 case MD.IconLabel.TextBesideIcon:
116 return iconItem.implicitWidth + label.implicitWidth + effectiveSpacing;
117 case MD.IconLabel.TextUnderIcon:
118 return Math.max(iconItem.implicitWidth, label.implicitWidth);
122 switch (effectiveDisplay) {
123 case MD.IconLabel.IconOnly:
124 return iconItem.implicitHeight;
125 case MD.IconLabel.TextOnly:
126 return label.implicitHeight;
127 case MD.IconLabel.TextBesideIcon:
128 return Math.max(iconItem.implicitHeight, label.implicitHeight);
129 case MD.IconLabel.TextUnderIcon:
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 === MD.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 === MD.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 === MD.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
257 label.anchors.leftMargin: root.effectiveSpacing
258 label.anchors.rightMargin: 0
259 label.anchors.topMargin: 0
260 label.anchors.bottomMargin: 0
264 name:
"textBesideIconMirrored"
265 when: root.effectiveDisplay === MD.IconLabel.TextBesideIcon && root.mirrored
269 anchors.left: undefined
270 anchors.right: root.right
271 anchors.top: undefined
272 anchors.bottom: undefined
273 anchors.horizontalCenter: undefined
274 anchors.verticalCenter: root.verticalCenter
279 anchors.left: undefined
280 anchors.right: iconItem.left
281 anchors.top: undefined
282 anchors.bottom: undefined
283 anchors.horizontalCenter: undefined
284 anchors.verticalCenter: root.verticalCenter
288 label.anchors.leftMargin: 0
289 label.anchors.rightMargin: root.effectiveSpacing
290 label.anchors.topMargin: 0
291 label.anchors.bottomMargin: 0
295 name:
"textUnderIcon"
296 when: root.effectiveDisplay === MD.IconLabel.TextUnderIcon
300 anchors.left: undefined
301 anchors.right: undefined
302 anchors.top: root.top
303 anchors.bottom: undefined
304 anchors.horizontalCenter: root.horizontalCenter
305 anchors.verticalCenter: undefined
310 anchors.left: undefined
311 anchors.right: undefined
312 anchors.top: iconItem.bottom
313 anchors.bottom: undefined
314 anchors.horizontalCenter: root.horizontalCenter
315 anchors.verticalCenter: undefined
319 label.anchors.leftMargin: 0
320 label.anchors.rightMargin: 0
321 label.anchors.topMargin: root.effectiveSpacing
322 label.anchors.bottomMargin: 0