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.Controls.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 the icon.name property 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.source property 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  *
50  * @warning Tooltips may not be supported on all platforms.
51  */
52  property string tooltip
53 
54  /**
55  * @brief This property sets whether this action is a separator action.
56  *
57  * default: ``false``
58  */
59  property bool separator: false
60 
61  /**
62  * @brief This property sets whether this action becomes a title displaying
63  * its child actions as sub-items in GlobalDrawers and ContextDrawers.
64  *
65  * default: ``false``
66  *
67  * @since org.kde.kirigami 2.6
68  */
69  property bool expandible: false
70 
71  /**
72  * @brief This property holds the parent action.
73  */
74  property QQC2.Action parent
75 
76  /**
77  * @brief This property sets this action's display type.
78  *
79  * These are provided to implementations to indicate a preference for certain display
80  * styles.
81  *
82  * default: ``Kirigami.DisplayHint.NoPreference``
83  *
84  * @note This property contains only preferences, implementations may choose to disregard them.
85  * @see DisplayHint
86  * @since org.kde.kirigami 2.12
87  * @property Kirigami.DisplayHint displayHint
88  */
89  property int displayHint: Kirigami.DisplayHint.NoPreference
90 
91  /**
92  * @brief This is a helper function to check if a certain display hint has been set.
93  *
94  * This function is mostly convenience to enforce the mutual exclusivity of KeepVisible and AlwaysHide.
95  *
96  * @param hint The display hint to check if it is set.
97  * @return @c true if the hint was set for this action, @c false if not.
98  * @deprecated Since 2.14, Use DisplayHint.displayHintSet(action, hint) instead.
99  * @since org.kde.kirigami 2.12
100  */
101  function displayHintSet(hint) {
102  print("Action::displayHintSet is deprecated, use Kirigami.DisplayHint.displayHintSet(action, hint)")
103  return Kirigami.DisplayHint.displayHintSet(root, hint);
104  }
105 
106  /**
107  * @brief This property holds the component that should be used for displaying this action.
108  * @note This can be used to display custom components in the toolbar.
109  * @since KDE Frameworks 5.65
110  * @since org.kde.kirigami 2.12
111  */
112  property Component displayComponent: null
113 
114  /**
115  * @brief This property holds a list of child actions.
116  *
117  * This is useful for tree-like menus, such as the GlobalDrawer.
118  *
119  * Example usage:
120  * @code{.qml}
121  * Action {
122  * text: "Tools"
123  * Action {
124  * text: "Action1"
125  * }
126  * Action {
127  * text: "Action2"
128  * }
129  * }
130  * @endcode
131  * @property list<Action> children
132  */
133  default property list<QtObject> children
134 //END properties
135 
136  onChildrenChanged: {
137  let child;
138  for (const i in children) {
139  child = children[i];
140  if (child.hasOwnProperty("parent")) {
141  child.parent = root
142  }
143  }
144  }
145 
146  /**
147  * @brief This property holds the action's visible child actions.
148  * @property list<Action> visibleChildren
149  */
150  readonly property var visibleChildren: {
151  const visible = [];
152  for (const i in children) {
153  const child = children[i];
154  if (!child.hasOwnProperty("visible") || child.visible) {
155  visible.push(child);
156  }
157  }
158  return visible;
159  }
160  /**
161  * @brief Hints for implementations using Actions indicating preferences about how to display the action.
162  * @deprecated Since 2.14, use Kirigami.DisplayHint instead.
163  */
164  enum DisplayHint {
165  NoPreference = 0,
166  IconOnly = 1,
167  KeepVisible = 2,
168  AlwaysHide = 4,
169  HideChildIndicator = 8
170  }
171 }
QObject * parent() const const
This enum contains hints on how a Kirigami.Action should be displayed.
Definition: enums.h:141
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Dec 6 2023 04:01:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.