20 Accessible.ignored: true
32 component IconData: QtObject {
34 property real width: -1
35 property real height: -1
40 property IconData icon: IconData {}
43 property alias text: label.text
46 property alias typescale: label.typescale
49 property alias lineHeight: label.lineHeight
52 property alias color: label.color
55 property bool mirrored: false
60 readonly property bool hasIcon: icon.name.length > 0
65 readonly property bool showIcon: hasIcon && display !== IconLabel.TextOnly
70 readonly property bool showText: display !== IconLabel.IconOnly
75 property int display: IconLabel.TextBesideIcon
80 readonly property int effectiveDisplay: {
82 case IconLabel.TextBesideIcon:
83 return showIcon ? display : IconLabel.TextOnly;
85 return showIcon ? display :
IconLabel.TextOnly;
94 property real spacing: MD.Tokens.measurement.space100
99 readonly
property real effectiveSpacing: showIcon && showText ? spacing : 0
102 switch (effectiveDisplay) {
104 return iconItem.implicitWidth;
106 return label.implicitWidth;
108 return iconItem.implicitWidth + label.implicitWidth + effectiveSpacing;
110 return Math.max(iconItem.implicitWidth, label.implicitWidth);
114 switch (effectiveDisplay) {
116 return iconItem.implicitHeight;
118 return label.implicitHeight;
120 return Math.max(iconItem.implicitHeight, label.implicitHeight);
122 return iconItem.implicitHeight + label.implicitHeight + effectiveSpacing;
126 LayoutMirroring.enabled: mirrored
127 LayoutMirroring.childrenInherit:
true
133 iconWidth: root.icon.width
134 iconHeight: root.icon.height
135 color: root.icon.color.a > 0 ? root.icon.color : label.color
136 visible: root.showIcon
142 font.pixelSize: typescale.fontSize
143 font.weight: typescale.fontWeight
146 wrapMode: MD.Label.NoWrap
147 elide: MD.Label.ElideRight
148 visible: root.showText
154 when: root.effectiveDisplay ===
IconLabel.IconOnly
158 anchors.left: undefined
159 anchors.right: undefined
160 anchors.top: undefined
161 anchors.bottom: undefined
162 anchors.horizontalCenter: root.horizontalCenter
163 anchors.verticalCenter: root.verticalCenter
168 anchors.left: undefined
169 anchors.right: undefined
170 anchors.top: undefined
171 anchors.bottom: undefined
172 anchors.horizontalCenter: undefined
173 anchors.verticalCenter: undefined
178 when: root.effectiveDisplay ===
IconLabel.TextOnly
182 anchors.left: undefined
183 anchors.right: undefined
184 anchors.top: undefined
185 anchors.bottom: undefined
186 anchors.horizontalCenter: root.horizontalCenter
187 anchors.verticalCenter: root.verticalCenter
192 anchors.left: undefined
193 anchors.right: undefined
194 anchors.top: undefined
195 anchors.bottom: undefined
196 anchors.horizontalCenter: undefined
197 anchors.verticalCenter: undefined
201 name:
"textBesideIcon"
202 when: root.effectiveDisplay ===
IconLabel.TextBesideIcon && !root.mirrored
206 anchors.left: root.left
207 anchors.right: undefined
208 anchors.top: undefined
209 anchors.bottom: undefined
210 anchors.horizontalCenter: undefined
211 anchors.verticalCenter: root.verticalCenter
216 anchors.left: iconItem.right
217 anchors.right: undefined
218 anchors.top: undefined
219 anchors.bottom: undefined
220 anchors.horizontalCenter: undefined
221 anchors.verticalCenter: root.verticalCenter
226 anchors.leftMargin: root.effectiveSpacing
227 anchors.rightMargin: 0
229 anchors.bottomMargin: 0
233 name:
"textBesideIconMirrored"
234 when: root.effectiveDisplay ===
IconLabel.TextBesideIcon && root.mirrored
238 anchors.left: undefined
239 anchors.right: root.right
240 anchors.top: undefined
241 anchors.bottom: undefined
242 anchors.horizontalCenter: undefined
243 anchors.verticalCenter: root.verticalCenter
248 anchors.left: undefined
249 anchors.right: iconItem.left
250 anchors.top: undefined
251 anchors.bottom: undefined
252 anchors.horizontalCenter: undefined
253 anchors.verticalCenter: root.verticalCenter
258 anchors.leftMargin: 0
259 anchors.rightMargin: root.effectiveSpacing
261 anchors.bottomMargin: 0
265 name:
"textUnderIcon"
266 when: root.effectiveDisplay ===
IconLabel.TextUnderIcon
270 anchors.left: undefined
271 anchors.right: undefined
272 anchors.top: root.top
273 anchors.bottom: undefined
274 anchors.horizontalCenter: root.horizontalCenter
275 anchors.verticalCenter: undefined
280 anchors.left: undefined
281 anchors.right: undefined
282 anchors.top: iconItem.bottom
283 anchors.bottom: undefined
284 anchors.horizontalCenter: root.horizontalCenter
285 anchors.verticalCenter: undefined
290 anchors.leftMargin: 0
291 anchors.rightMargin: 0
292 anchors.topMargin: root.effectiveSpacing
293 anchors.bottomMargin: 0
Lays out an icon and text as a single reusable visual.