Kirigami2

Action.qml
1/*
2 * SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
3 * SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8import QtQml
9import QtQuick
10import QtQuick.Controls as QQC2
11import QtQuick.Templates as T
12import org.kde.kirigami as Kirigami
13import org.kde.kirigami.private as P
14
15/**
16 * @brief An item that represents an abstract Action
17 * @inherit QtQuick.QQC2.Action
18 */
19QQC2.Action {
20//BEGIN properties
21 /**
22 * @brief This property holds whether the graphic representation of the action
23 * is supposed to be visible.
24 *
25 * It's up to the action representation to honor this property.
26 *
27 * default: ``true``
28 */
29 property bool visible: !fromQAction || fromQAction.visible
30
31 /**
32 * @brief This property holds the tooltip text that is shown when the cursor is hovering over the control.
33 *
34 * Leaving this undefined or setting it to an empty string means that no tooltip will be shown when
35 * the cursor is hovering over the control that triggers the tooltip.
36 * @warning Tooltips may not be supported on all platforms.
37 */
38 property string tooltip
39
40 /**
41 * @brief This property sets whether this action is a separator action.
42 *
43 * default: ``false``
44 */
45 property bool separator: false
46
47 /**
48 * @brief This property sets whether this action becomes a title displaying
49 * its child actions as sub-items in GlobalDrawers and ContextDrawers.
50 *
51 * default: ``false``
52 *
53 * @since 2.6
54 */
55 property bool expandible: false
56
57 /**
58 * @brief This property holds the parent action.
59 */
60 property T.Action parent
61
62 /**
63 * @brief This property sets this action's display type.
64 *
65 * These are provided to implementations to indicate a preference for certain display
66 * styles.
67 *
68 * default: ``Kirigami.DisplayHint.NoPreference``
69 *
70 * @note This property contains only preferences, implementations may choose to disregard them.
71 * @see org::kde::kirigami::DisplayHint
72 * @since 2.12
73 */
74 property int displayHint: Kirigami.DisplayHint.NoPreference
75
76 /**
77 * @brief This property holds the component that should be used for displaying this action.
78 * @note This can be used to display custom components in the toolbar.
79 * @since 5.65
80 * @since 2.12
81 */
82 property Component displayComponent
83
84 /**
85 * @brief This property holds a list of child actions.
86 *
87 * This is useful for tree-like menus, such as the GlobalDrawer.
88 *
89 * Example usage:
90 * @code
91 * import QtQuick.Controls as QQC2
92 * import org.kde.kirigami as Kirigami
93 *
94 * Kirigami.Action {
95 * text: "Tools"
96 *
97 * QQC2.Action {
98 * text: "Action1"
99 * }
100 * Kirigami.Action {
101 * text: "Action2"
102 * }
103 * }
104 * @endcode
105 * @property list<T.Action> children
106 */
107 default property list<T.Action> children
108
109 /**
110 * This property holds a QAction
111 *
112 * When provided Kirigami.Action will be initialized from the given QAction.
113 *
114 * @since Kirigami 6.4.0
115 */
116 property QtObject fromQAction
117//END properties
118
119 onChildrenChanged: {
120 children
121 .filter(action => action instanceof Kirigami.Action)
122 .forEach(action => {
123 action.parent = this;
124 });
125 }
126
127 /**
128 * @brief This property holds the action's visible child actions.
129 * @property list<T.Action> visibleChildren
130 */
131 readonly property list<T.Action> visibleChildren: children
132 .filter(action => !(action instanceof Kirigami.Action) || action.visible)
133
134 shortcut: fromQAction?.shortcut
135 text: fromQAction?.text ?? ''
136 icon.name: fromQAction ? P.ActionHelper.iconName(fromQAction.icon) : ''
137 onTriggered: if (fromQAction) {
138 fromQAction.trigger();
139 }
140 checkable: fromQAction?.checkable ?? false
141 checked: fromQAction?.checked ?? false
142 enabled: !fromQAction || fromQAction.enabled
143
144 readonly property Shortcut alternateShortcut : Shortcut {
145 sequences: P.ActionHelper.alternateShortcuts(fromQAction)
146 onActivated: root.trigger()
147 }
148}
KIOCORE_EXPORT QStringList list(const QString &fileClass)
const QList< QKeySequence > & shortcut(StandardShortcut id)
QStringList filter(QStringView str, Qt::CaseSensitivity cs) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:51:31 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.