Kirigami2

ActionToolBar.qml
1 /*
2  * SPDX-FileCopyrightText: 2018 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.7
8 import QtQuick.Layouts 1.2
9 import QtQuick.Controls 2.4 as Controls
10 import org.kde.kirigami 2.14 as Kirigami
11 import "private"
12 
21 Controls.Control {
22  id: root
29  property alias actions: layout.actions
30 
38  property list<QtObject> hiddenActions
39  onHiddenActionsChanged: print("ActionToolBar::hiddenActions is deprecated, use the AlwaysHide hint on your actions instead")
40 
41 
45  property bool flat: true
46 
56  property int display: Controls.Button.TextBesideIcon
57 
58  property alias alignment: layout.alignment
59 
69  property int position: parent && parent.hasOwnProperty("position")
70  ? parent.position
71  : Controls.ToolBar.Header
72 
79  readonly property alias maximumContentWidth: layout.implicitWidth
80 
87  property string overflowIconName: "overflow-menu"
88 
89  property alias visibleWidth: layout.visibleWidth
90 
96  property alias heightMode: layout.heightMode
97 
98  implicitHeight: layout.implicitHeight
99  implicitWidth: layout.implicitWidth
100 
101  Layout.minimumWidth: layout.minimumWidth
102  Layout.preferredWidth: 0
103  Layout.fillWidth: true
104 
105  leftPadding: 0
106  rightPadding: 0
107  topPadding: 0
108  bottomPadding: 0
109 
110  contentItem: Kirigami.ToolBarLayout {
111  id: layout
112  spacing: Kirigami.Units.smallSpacing
113  layoutDirection: root.LayoutMirroring.enabled ? Qt.RightToLeft : Qt.LeftToRight
114 
115  fullDelegate: PrivateActionToolButton {
116  flat: root.flat
117  display: root.display
118  action: Kirigami.ToolBarLayout.action
119  }
120 
121  iconDelegate: PrivateActionToolButton {
122  flat: root.flat
123  display: Controls.Button.IconOnly
124  action: Kirigami.ToolBarLayout.action
125 
126  showMenuArrow: false
127 
128  menuActions: {
129  if (action.displayComponent) {
130  return [action]
131  }
132 
133  if (action.children) {
134  return Array.prototype.map.call(action.children, i => i)
135  }
136 
137  return []
138  }
139  }
140 
141  moreButton: PrivateActionToolButton {
142  flat: root.flat
143 
144  action: Kirigami.Action {
145  tooltip: qsTr("More Actions")
146  icon.name: root.overflowIconName
147  displayHint: Kirigami.DisplayHint.IconOnly | Kirigami.DisplayHint.HideChildIndicator
148  }
149 
150  menuActions: {
151  if (root.hiddenActions.length == 0) {
152  return root.actions
153  } else {
154  result = []
155  result.concat(Array.prototype.map.call(root.actions, (i) => i))
156  result.concat(Array.prototype.map.call(hiddenActions, (i) => i))
157  return result
158  }
159  }
160 
161  menuComponent: ActionsMenu {
162  submenuComponent: ActionsMenu {
163  Binding {
164  target: parentItem
165  property: "visible"
166  value: layout.hiddenActions.includes(parentAction)
167  && (parentAction.visible === undefined || parentAction.visible)
168  }
169  }
170 
171  itemDelegate: ActionMenuItem {
172  visible: layout.hiddenActions.includes(action)
173  && (action.visible === undefined || action.visible)
174  }
175 
176  loaderDelegate: Loader {
177  property var action
178  height: visible ? implicitHeight : 0
179  visible: layout.hiddenActions.includes(action)
180  && (action.visible === undefined || action.visible)
181  }
182 
183  separatorDelegate: Controls.MenuSeparator {
184  property var action
185  visible: layout.hiddenActions.includes(action)
186  && (action.visible === undefined || action.visible)
187  }
188  }
189  }
190  }
191 }
Definition: icon.h:18
An item that creates delegates for actions and lays them out in a row.
Definition: toolbarlayout.h:46
const QList< QKeySequence > & print()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 16 2021 22:39:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.