Warning, /frameworks/kirigami/src/controls/ActionToolBar.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQml 0009 import QtQuick.Layouts 0010 import QtQuick.Controls as QQC2 0011 import QtQuick.Templates as T 0012 import org.kde.kirigami as Kirigami 0013 import "private" as P 0014 0015 /** 0016 * @brief A toolbar built out of a list of actions. 0017 * 0018 * The default representation for visible actions is a QtQuick.Controls.ToolButton, but 0019 * it can be changed by setting the `Action.displayComponent` for an action. 0020 * The default behavior of ActionToolBar is to display as many actions as possible, 0021 * placing those that will not fit into an overflow menu. This can be changed by 0022 * setting the `displayHint` property on an Action. For example, when setting the 0023 * `DisplayHint.KeepVisible` display hint, ActionToolBar will try to keep that action 0024 * in view as long as possible, using an icon-only button if a button with text 0025 * does not fit. 0026 * 0027 * @inherit QtQuick.Controls.Control 0028 * @since 2.5 0029 */ 0030 QQC2.Control { 0031 id: root 0032 0033 //BEGIN properties 0034 /** 0035 * @brief This property holds a list of visible actions. 0036 * 0037 * The ActionToolBar will try to display as many actions as possible. 0038 * Those that won't fit will go into an overflow menu. 0039 * 0040 * @property list<Action> actions 0041 */ 0042 readonly property alias actions: layout.actions 0043 0044 /** 0045 * @brief This property holds whether the buttons will have a flat appearance. 0046 * 0047 * default: ``true`` 0048 */ 0049 property bool flat: true 0050 0051 /** 0052 * @brief This property determines how the icon and text are displayed within the button. 0053 * 0054 * Permitted values are: 0055 * * ``Button.IconOnly`` 0056 * * ``Button.TextOnly`` 0057 * * ``Button.TextBesideIcon`` 0058 * * ``Button.TextUnderIcon`` 0059 * 0060 * default: ``Controls.Button.TextBesideIcon`` 0061 * 0062 * @see QtQuick.Controls.AbstractButton 0063 * @property int display 0064 */ 0065 property int display: QQC2.Button.TextBesideIcon 0066 0067 /** 0068 * @brief This property holds the alignment of the buttons. 0069 * 0070 * When there is more space available than required by the visible delegates, 0071 * we need to determine how to place the delegates. 0072 * 0073 * When there is more space available than required by the visible action delegates, 0074 * we need to determine where to position them. 0075 * 0076 * default: ``Qt.AlignRight`` 0077 * 0078 * @see Qt::AlignmentFlag 0079 * @property int alignment 0080 */ 0081 property alias alignment: layout.alignment 0082 0083 /** 0084 * @brief This property holds the position of the toolbar. 0085 * 0086 * If this ActionToolBar is the contentItem of a QQC2 Toolbar, the position is bound to the ToolBar's position 0087 * 0088 * Permitted values are: 0089 * * ``ToolBar.Header``: The toolbar is at the top, as a window or page header. 0090 * * ``ToolBar.Footer``: The toolbar is at the bottom, as a window or page footer. 0091 * 0092 * @property int position 0093 */ 0094 property int position: parent instanceof T.ToolBar ? parent.position : QQC2.ToolBar.Header 0095 0096 /** 0097 * @brief This property holds the maximum width of the content of this ToolBar. 0098 * 0099 * If the toolbar's width is larger than this value, empty space will 0100 * be added on the sides, according to the Alignment property. 0101 * 0102 * The value of this property is derived from the ToolBar's actions and their properties. 0103 * 0104 * @property int maximumContentWidth 0105 */ 0106 readonly property alias maximumContentWidth: layout.implicitWidth 0107 0108 /** 0109 * @brief This property holds the name of the icon to use for the overflow menu button. 0110 * 0111 * default: ``"overflow-menu"`` 0112 * 0113 * @since 5.65 0114 * @since 2.12 0115 */ 0116 property string overflowIconName: "overflow-menu" 0117 0118 /** 0119 * @brief This property holds the combined width of all visible delegates. 0120 * @property int visibleWidth 0121 */ 0122 readonly property alias visibleWidth: layout.visibleWidth 0123 0124 /** 0125 * @brief This property sets the handling method for items that do not match the toolbar's height. 0126 * 0127 * When toolbar items do not match the height of the toolbar, there are 0128 * several ways we can deal with this. This property sets the preferred way. 0129 * 0130 * Permitted values are: 0131 * * ``HeightMode.AlwaysCenter`` 0132 * * ``HeightMode.AlwaysFill`` 0133 * * ``AlwaysFill.ConstrainIfLarger`` 0134 * 0135 * default: ``HeightMode::ConstrainIfLarger`` 0136 * 0137 * @see ToolBarLayout::heightMode 0138 * @see ToolBarLayout::HeightMode 0139 * @property ToolBarLayout::HeightMode heightMode 0140 */ 0141 property alias heightMode: layout.heightMode 0142 //END properties 0143 0144 implicitHeight: layout.implicitHeight 0145 implicitWidth: layout.implicitWidth 0146 0147 Layout.minimumWidth: layout.minimumWidth 0148 Layout.preferredWidth: 0 0149 Layout.fillWidth: true 0150 0151 leftPadding: 0 0152 rightPadding: 0 0153 topPadding: 0 0154 bottomPadding: 0 0155 0156 contentItem: Kirigami.ToolBarLayout { 0157 id: layout 0158 spacing: Kirigami.Units.smallSpacing 0159 layoutDirection: root.mirrored ? Qt.RightToLeft : Qt.LeftToRight 0160 0161 fullDelegate: P.PrivateActionToolButton { 0162 flat: root.flat 0163 display: root.display 0164 action: Kirigami.ToolBarLayout.action 0165 } 0166 0167 iconDelegate: P.PrivateActionToolButton { 0168 flat: root.flat 0169 display: QQC2.Button.IconOnly 0170 action: Kirigami.ToolBarLayout.action 0171 0172 showMenuArrow: false 0173 0174 menuActions: { 0175 if (action.displayComponent) { 0176 return [action] 0177 } 0178 0179 if (action instanceof Kirigami.Action) { 0180 return action.children; 0181 } 0182 0183 return [] 0184 } 0185 } 0186 0187 moreButton: P.PrivateActionToolButton { 0188 flat: root.flat 0189 0190 action: Kirigami.Action { 0191 tooltip: qsTr("More Actions") 0192 icon.name: root.overflowIconName 0193 displayHint: Kirigami.DisplayHint.IconOnly | Kirigami.DisplayHint.HideChildIndicator 0194 } 0195 0196 Accessible.name: action.tooltip 0197 0198 menuActions: root.actions 0199 0200 menuComponent: P.ActionsMenu { 0201 submenuComponent: P.ActionsMenu { 0202 Binding { 0203 target: parentItem 0204 property: "visible" 0205 value: layout.hiddenActions.includes(parentAction) 0206 && (!(parentAction instanceof Kirigami.Action) || parentAction.visible) 0207 restoreMode: Binding.RestoreBinding 0208 } 0209 } 0210 0211 itemDelegate: P.ActionMenuItem { 0212 visible: layout.hiddenActions.includes(action) 0213 && (!(action instanceof Kirigami.Action) || action.visible) 0214 } 0215 0216 loaderDelegate: Loader { 0217 property T.Action action 0218 height: visible ? implicitHeight : 0 0219 visible: layout.hiddenActions.includes(action) 0220 && (!(action instanceof Kirigami.Action) || action.visible) 0221 } 0222 0223 separatorDelegate: QQC2.MenuSeparator { 0224 property T.Action action 0225 visible: layout.hiddenActions.includes(action) 0226 && (!(action instanceof Kirigami.Action) || action.visible) 0227 } 0228 } 0229 } 0230 } 0231 }