Kirigami-addons

NativeMenuItem.qml
1// SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com>
2// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
3// SPDX-License-Identifier: LGPL-2.0-or-later
4
5import QtQuick
6import Qt.labs.platform
7import org.kde.kirigamiaddons.statefulapp.private as Private
8import org.kde.kirigamiaddons.statefulapp as StatefulApp
9
10/**
11 * A Labs.MenuItem defined by a QAction.
12 *
13 * @code{qml}
14 * import Qt.labs.platform as Labs
15 * import org.kde.kirigamiaddons.statefulapp as StatefulApp
16 * import org.kde.kirigamiaddons.statefulapp.labs as StatefulAppLabs
17 *
18 * StatefulApp.StatefulWindow {
19 * application: MyKoolApp
20 *
21 * Labs.MenuBar {
22 * Labs.Menu {
23 * StatefulAppLabs.MenuItem {
24 * actionName: 'add_notebook'
25 * application: MyKoolApp
26 * }
27 * }
28 * }
29 * }
30 * @endcode{}
31 * @since KirigamiAddons 1.4.0
32 */
33MenuItem {
34 /**
35 * This property holds the action name defined in your AbstractKirigamiApplication implementation.
36 */
37 required property string actionName
38
39 /**
40 * This property holds the AbstractKirigamiApplication where the action is defined.
41 */
42 required property StatefulApp.AbstractKirigamiApplication application
43
44 readonly property QtObject _action: application.action(actionName)
45
46 text: _action?.text ?? ''
47 shortcut: _action?.shortcut
48 icon.name: _action ? Private.Helper.iconName(_action.icon) : ''
49 onTriggered: if (_action) {
50 _action.trigger();
51 }
52 visible: _action && _action.text.length > 0
53 checkable: _action?.checkable
54 checked: _action?.checked
55 enabled: _action && _action.enabled && parent.enabled
56
57 readonly property Shortcut alternateShortcut : Shortcut {
58 sequences: Private.Helper.alternateShortcuts(_action)
59 onActivated: root.trigger()
60 }
61}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.