8import QtQuick.Controls as QQC2
9import QtQuick.Templates as T
10import org.kde.kirigami as Kirigami
76 readonly property int tabIndex: {
78 for (const child of parent.children) {
83 if (child instanceof T.AbstractButton) {
92 readonly property color __foregroundColor: Kirigami.Theme.textColor
93 readonly property color __highlightForegroundColor: Kirigami.Theme.textColor
95 readonly property color __pressedColor: Qt.alpha(Kirigami.Theme.highlightColor, 0.3)
96 readonly property color __hoverSelectColor: Qt.alpha(Kirigami.Theme.highlightColor, 0.2)
97 readonly property color __checkedBorderColor: Qt.alpha(Kirigami.Theme.highlightColor, 0.7)
98 readonly property color __pressedBorderColor: Qt.alpha(Kirigami.Theme.highlightColor, 0.9)
100 readonly property real __verticalMargins: (display === T.AbstractButton.TextBesideIcon) ? Kirigami.Units.largeSpacing : 0
102 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
103 implicitContentWidth + leftPadding + rightPadding)
104 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
105 implicitContentHeight + topPadding + bottomPadding)
107 display: T.AbstractButton.TextUnderIcon
109 Kirigami.Theme.colorSet: Kirigami.Theme.Window
110 Kirigami.Theme.inherit: false
114 padding: Kirigami.Units.smallSpacing
115 spacing: Kirigami.Units.smallSpacing
117 icon.height: display === T.AbstractButton.TextBesideIcon ? Kirigami.Units.iconSizes.small : Kirigami.Units.iconSizes.smallMedium
118 icon.width: display === T.AbstractButton.TextBesideIcon ? Kirigami.Units.iconSizes.small : Kirigami.Units.iconSizes.smallMedium
119 icon.color: checked ? __highlightForegroundColor : __foregroundColor
121 Kirigami.MnemonicData.enabled: enabled && visible
122 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.MenuItem
123 Kirigami.MnemonicData.label: text
125 Accessible.onPressAction: control.action.trigger()
127 background: Rectangle {
128 Kirigami.Theme.colorSet: Kirigami.Theme.Button
129 Kirigami.Theme.inherit: false
131 implicitHeight: (control.display === T.AbstractButton.TextBesideIcon) ? 0 : (Kirigami.Units.gridUnit * 3 + Kirigami.Units.smallSpacing * 2)
136 width: parent.width - Kirigami.Units.largeSpacing
137 height: parent.height - Kirigami.Units.largeSpacing
138 anchors.centerIn: parent
140 radius: Kirigami.Units.cornerRadius
141 color: control.down ? control.__pressedColor : (control.checked || control.hovered ? control.__hoverSelectColor :
"transparent")
143 border.color: control.visualFocus ? control.__checkedBorderColor : (control.down ? control.__pressedBorderColor : color)
146 Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration } }
147 Behavior on border.color { ColorAnimation { duration: Kirigami.Units.shortDuration } }
151 contentItem: GridLayout {
153 rowSpacing: (
label.visible &&
label.lineCount > 1) ? 0 : control.spacing
156 columns: control.display !== T.AbstractButton.TextBesideIcon ? 1 : 2
160 source: control.icon.
name || control.icon.source
161 visible: (control.icon.
name.length > 0 || control.icon.source.
toString().length > 0) && control.display !== T.AbstractButton.TextOnly
162 color: control.icon.color
164 Layout.topMargin: control.__verticalMargins
165 Layout.bottomMargin: control.__verticalMargins
166 Layout.leftMargin: (control.display === T.AbstractButton.TextBesideIcon) ? Kirigami.
Units.gridUnit : 0
167 Layout.rightMargin: (control.display === T.AbstractButton.TextBesideIcon) ? Kirigami.
Units.gridUnit : 0
170 if (control.display === T.AbstractButton.TextBesideIcon) {
172 return Qt.AlignVCenter | Qt.AlignRight;
175 return Qt.AlignHCenter | ((!label.visible || label.lineCount > 1) ? Qt.AlignVCenter : Qt.AlignBottom);
178 implicitHeight: source ? control.icon.height : 0
179 implicitWidth: source ? control.icon.width : 0
181 Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration } }
186 text: control.Kirigami.MnemonicData.richTextLabel
187 horizontalAlignment: (control.display === T.AbstractButton.TextBesideIcon) ? Text.AlignLeft : Text.
AlignHCenter
189 visible: control.display !== T.AbstractButton.IconOnly
192 color: control.checked ? control.__highlightForegroundColor : control.__foregroundColor
194 font.bold: control.checked
195 font.pointSize: !icon.visible && control.display === T.AbstractButton.TextBelowIcon
196 ? Kirigami.Theme.defaultFont.pointSize * 1.20
197 : Kirigami.Theme.defaultFont.pointSize
199 Behavior on color { ColorAnimation { duration: Kirigami.
Units.shortDuration } }
201 Layout.topMargin: control.__verticalMargins
202 Layout.bottomMargin: control.__verticalMargins
205 if (control.display === T.AbstractButton.TextBesideIcon) {
207 return Qt.AlignVCenter |
Qt.AlignLeft;
210 return icon.visible ?
Qt.AlignHCenter |
Qt.AlignTop :
Qt.AlignCenter;
214 Layout.fillWidth:
true
216 Accessible.ignored:
true
Class for rendering an icon in UI.
char * toString(const EngineQuery &query)
QString name(StandardAction id)
QString label(StandardShortcut id)