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
134 .filter(action => action instanceof Kirigami.Action
143 const minDelegateWidth = Kirigami.Units.gridUnit * 5;
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.filter((child) => child !== instantiator)
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
int currentIndex
This property holds the index of currently checked tab.
listTAction visibleActions
This property holds a subset of visible actions of the list of actions.
real buttonWidth
This property holds the calculated width that buttons on the tab bar use.
listTAction actions
This property holds the list of actions to be displayed in the toolbar.
TButtonGroup tabGroup
This property holds the ButtonGroup used to manage the tabs.
int count
This property holds the number of tab buttons.
real maximumContentWidth
The property holds the maximum width of the toolbar actions, before margins are added.