7pragma ComponentBehavior: Bound
12import QtQuick.Controls as QQC2
13import QtQuick.Templates as T
14import org.kde.kirigami as Kirigami
124 property list<T.Action> actions
132 readonly
property list<T.Action> visibleActions: actions
134 .
filter(action => action instanceof Kirigami.Action
142 property real maximumContentWidth: {
143 const minDelegateWidth = Kirigami.Units.gridUnit * 5;
145 return minDelegateWidth * Math.max(visibleActions.length, 5);
154 property int currentIndex: tabGroup.checkedButton && tabGroup.buttons.
length > 0 ? tabGroup.checkedButton.tabIndex : -1
159 readonly
property int count: tabGroup.buttons.length
164 readonly
property T.ButtonGroup tabGroup: tabGroup
171 property real buttonWidth: {
173 let visibleButtonCount = 0;
174 const minWidth = contentItem.height * 0.75;
175 for (
const visibleChild of contentItem.visibleChildren) {
176 if (contentItem.width / visibleButtonCount >= minWidth &&
177 visibleChild instanceof T.AbstractButton) {
178 ++visibleButtonCount;
182 return Math.round(contentItem.width / visibleButtonCount);
186 onCurrentIndexChanged: {
187 if (currentIndex === -1) {
188 if (tabGroup.checkState !==
Qt.Unchecked) {
189 tabGroup.checkState =
Qt.Unchecked;
193 if (!tabGroup.checkedButton || tabGroup.checkedButton.tabIndex !== currentIndex) {
194 const buttonForCurrentIndex = tabGroup.buttons[currentIndex]
195 if (buttonForCurrentIndex.action) {
197 buttonForCurrentIndex.action.trigger();
202 buttonForCurrentIndex.toggle();
210 topPadding: undefined
211 leftPadding: undefined
212 rightPadding: undefined
213 bottomPadding: undefined
214 verticalPadding: undefined
216 horizontalPadding: Math.floor(Math.max(0, width - root.maximumContentWidth) / 2)
218 contentWidth: Math.ceil(Math.min(root.availableWidth, root.maximumContentWidth))
219 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, contentWidth + leftPadding + rightPadding)
220 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, contentHeight + topPadding + bottomPadding)
222 if (QQC2.ApplicationWindow.window?.footer === root) {
223 return QQC2.ToolBar.Footer
224 }
else if (parent?.footer === root) {
225 return QQC2.ToolBar.Footer
226 }
else if (parent?.parent?.footer === parent) {
227 return QQC2.ToolBar.Footer
229 return QQC2.ToolBar.Header
233 contentItem: RowLayout {
235 spacing: root.spacing
242 buttons: root.contentItem.children
244 onCheckedButtonChanged: {
245 if (!checkedButton) {
248 if (root.currentIndex !== checkedButton.tabIndex) {
249 root.currentIndex = checkedButton.tabIndex;
260 model: root.visibleActions
264 required
property T.Action modelData
266 parent: root.contentItem
269 onActionChanged: action.checkable =
true
271 Layout.minimumWidth: root.buttonWidth
272 Layout.maximumWidth: root.buttonWidth
273 Layout.fillHeight:
true
275 Kirigami.Theme.textColor: root.Kirigami.Theme.textColor
276 Kirigami.Theme.backgroundColor: root.Kirigami.Theme.backgroundColor
277 Kirigami.Theme.highlightColor: root.Kirigami.Theme.highlightColor
qsizetype length() const const
QStringList filter(QStringView str, Qt::CaseSensitivity cs) const const