Kirigami2

Action.qml
1 /*
2  * SPDX-FileCopyrightText: 2016 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.7
8 import QtQuick.Controls 2.4 as QQC2
9 import org.kde.kirigami 2.14 as Kirigami
10 
11 /**
12  * @brief An item that represents an abstract Action
13  * @inherit QtQuick.QQC2.Action
14  */
15 QQC2.Action {
16  id: root
17 
18 //BEGIN properties
19  /**
20  * @brief This property holds whether the graphic representation of the action
21  * is supposed to be visible.
22  *
23  * It's up to the action representation to honor this property.
24  *
25  * default: ``true``
26  */
27  property bool visible: true
28 
29  /**
30  * @brief This property holds the icon name for the action. This will pick the icon with the given name from the current theme.
31  * @deprecated Use icon.name instead.
32  * @property string iconName
33  */
34  property alias iconName: root.icon.name
35 
36  /**
37  * @brief This property holds an url to an icon file or resource url for the action.
38  * @note Use this if you want a specific file rather than an icon from the theme.
39  * @deprecated Use icon.name instead.
40  * @property url iconSource
41  */
42  property alias iconSource: root.icon.source
43 
44  /**
45  * @brief This property holds the tooltip text that is shown when the cursor is hovering over the control.
46  *
47  * Leaving this undefined or setting it to an empty string means that no tooltip will be shown when
48  * the cursor is hovering over the control that triggers the tooltip.
49  * @warning Tooltips may not be supported on all platforms.
50  */
51  property string tooltip
52 
53  /**
54  * @brief This property sets whether this action is a separator action.
55  *
56  * default: ``false``
57  */
58  property bool separator: false
59 
60  /**
61  * @brief This property sets whether this action becomes a title displaying
62  * its child actions as sub-items in GlobalDrawers and ContextDrawers.
63  *
64  * default: ``false``
65  *
66  * @since 2.6
67  */
68  property bool expandible: false
69 
70  /**
71  * @brief This property holds the parent action.
72  */
73  property QQC2.Action parent
74 
75  /**
76  * @brief This property sets this action's display type.
77  *
78  * These are provided to implementations to indicate a preference for certain display
79  * styles.
80  *
81  * default: ``Kirigami.DisplayHint.NoPreference``
82  *
83  * @note This property contains only preferences, implementations may choose to disregard them.
84  * @see org::kde::kirigami::DisplayHint
85  * @since 2.12
86  */
87  property int displayHint: Kirigami.DisplayHint.NoPreference
88 
89  /**
90  * @brief This is a helper function to check if a certain display hint has been set.
91  *
92  * This function is mostly convenience to enforce the mutual exclusivity of KeepVisible and AlwaysHide.
93  *
94  * @param hint The display hint to check if it is set.
95  * @see org::kde::kirigami::DisplayHint
96  * @deprecated since 2.14, Use DisplayHint.displayHintSet(action, hint) instead.
97  * @return true if the hint was set for this action, false if not.
98  * @since 2.12
99  */
100  function displayHintSet(hint) {
101  print("Action::displayHintSet is deprecated, use DisplayHint.displayHintSet(action, hint)")
102  return Kirigami.DisplayHint.displayHintSet(root, hint);
103  }
104 
105  /**
106  * @brief This property holds the component that should be used for displaying this action.
107  * @note This can be used to display custom components in the toolbar.
108  * @since 5.65
109  * @since 2.12
110  */
111  property Component displayComponent: null
112 
113  /**
114  * @brief This property holds a list of child actions.
115  *
116  * This is useful for tree-like menus, such as the GlobalDrawer.
117  *
118  * Example usage:
119  * @code
120  * Action {
121  * text: "Tools"
122  * Action {
123  * text: "Action1"
124  * }
125  * Action {
126  * text: "Action2"
127  * }
128  * }
129  * @endcode
130  * @property list<Action> children
131  */
132  default property list<QtObject> children
133 //END properties
134 
135  onChildrenChanged: {
136  let child;
137  for (const i in children) {
138  child = children[i];
139  if (child.hasOwnProperty("parent")) {
140  child.parent = root
141  }
142  }
143  }
144 
145  /**
146  * @brief This property holds the action's visible child actions.
147  * @property list<Action> visibleChildren
148  */
149  readonly property var visibleChildren: {
150  const visible = [];
151  for (const i in children) {
152  const child = children[i];
153  if (!child.hasOwnProperty("visible") || child.visible) {
154  visible.push(child);
155  }
156  }
157  return visible;
158  }
159 
160  /**
161  * @brief Hints for implementations using Actions indicating preferences about how to display the action.
162  * @see org::kde::kirigami::DisplayHint
163  * @deprecated since 2.14, use Kirigami.DisplayHint instead.
164  */
165  enum DisplayHint {
166  /**
167  * Indicates there is no specific preference.
168  */
169  NoPreference = 0,
170  /**
171  * Only display an icon for this Action.
172  */
173  IconOnly = 1,
174  /**
175  * Try to keep the action visible even when space constrained.
176  * Mutually exclusive with AlwaysHide, KeepVisible has priority.
177  */
178  KeepVisible = 2,
179  /**
180  * If possible, hide the action in an overflow menu or similar location.
181  * Mutually exclusive with KeepVisible, KeepVisible has priority.
182  */
183  AlwaysHide = 4,
184  /**
185  * When this action has children, do not display any indicator (like a
186  * menu arrow) for this action.
187  */
188  HideChildIndicator = 8
189  }
190 }
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:14:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.