// SPDX-FileCopyrightText: 2021 Claudio Cambra // SPDX-FileCopyrightText: 2024 Carl Schwan // SPDX-License-Identifier: LGPL-2.0-or-later import QtQuick import Qt.labs.platform import org.kde.kirigamiaddons.statefulapp.private as Private import org.kde.kirigamiaddons.statefulapp as StatefulApp /** * A Labs.MenuItem defined by a QAction. * * @code{qml} * import Qt.labs.platform as Labs * import org.kde.kirigamiaddons.statefulapp as StatefulApp * import org.kde.kirigamiaddons.statefulapp.labs as StatefulAppLabs * * StatefulApp.StatefulWindow { * application: MyKoolApp * * Labs.MenuBar { * Labs.Menu { * StatefulAppLabs.MenuItem { * actionName: 'add_notebook' * application: MyKoolApp * } * } * } * } * @endcode{} * @since KirigamiAddons 1.4.0 */ MenuItem { /** * This property holds the action name defined in your AbstractKirigamiApplication implementation. */ required property string actionName /** * This property holds the AbstractKirigamiApplication where the action is defined. */ required property StatefulApp.AbstractKirigamiApplication application readonly property QtObject _action: application.action(actionName) text: _action?.text ?? '' shortcut: _action?.shortcut icon.name: _action ? Private.Helper.iconName(_action.icon) : '' onTriggered: if (_action) { _action.trigger(); } visible: _action && _action.text.length > 0 checkable: _action?.checkable checked: _action?.checked enabled: _action && _action.enabled && parent.enabled readonly property Shortcut alternateShortcut : Shortcut { sequences: Private.Helper.alternateShortcuts(_action) onActivated: root.trigger() } }