Warning, /frameworks/kirigami/src/controls/MenuDialog.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com> 0003 SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk> 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Controls as QQC2 0009 import QtQuick.Layouts 0010 import QtQuick.Templates as T 0011 import org.kde.kirigami as Kirigami 0012 0013 /** 0014 * A dialog that prompts users with a context menu, with 0015 * list items that perform actions. 0016 * 0017 * Example usage: 0018 * @code{.qml} 0019 * Kirigami.MenuDialog { 0020 * title: i18n("Track Options") 0021 * 0022 * actions: [ 0023 * Kirigami.Action { 0024 * icon.name: "media-playback-start" 0025 * text: i18nc("Start playback of the selected track", "Play") 0026 * tooltip: i18n("Start playback of the selected track") 0027 * }, 0028 * Kirigami.Action { 0029 * enabled: false 0030 * icon.name: "document-open-folder" 0031 * text: i18nc("Show the file for this song in the file manager", "Show in folder") 0032 * tooltip: i18n("Show the file for this song in the file manager") 0033 * }, 0034 * Kirigami.Action { 0035 * icon.name: "documentinfo" 0036 * text: i18nc("Show track metadata", "View details") 0037 * tooltip: i18n("Show track metadata") 0038 * }, 0039 * Kirigami.Action { 0040 * icon.name: "list-add" 0041 * text: i18nc("Add the track to the queue, right after the current track", "Play next") 0042 * tooltip: i18n("Add the track to the queue, right after the current track") 0043 * }, 0044 * Kirigami.Action { 0045 * icon.name: "list-add" 0046 * text: i18nc("Enqueue current track", "Add to queue") 0047 * tooltip: i18n("Enqueue current track") 0048 * } 0049 * ] 0050 * } 0051 * @endcode 0052 * 0053 * @see Dialog 0054 * @see PromptDialog 0055 * @inherit org::kde::kirigami::Dialog 0056 */ 0057 Kirigami.Dialog { 0058 id: root 0059 0060 /** 0061 * @brief This property holds the actions displayed in the context menu. 0062 */ 0063 property list<T.Action> actions 0064 0065 /** 0066 * @brief This property holds the content header, which appears above the actions. 0067 * but below the header bar. 0068 */ 0069 property alias contentHeader: columnHeader.contentItem 0070 0071 /** 0072 * @brief This property holds the content header. 0073 * 0074 * This makes it possible to access its internal properties to, for example, change its padding: 0075 * ``contentHeaderControl.topPadding`` 0076 * 0077 * @property QtQuick.Controls.Control contentHeaderControl 0078 */ 0079 property alias contentHeaderControl: columnHeader 0080 0081 preferredWidth: Kirigami.Units.gridUnit * 20 0082 padding: 0 0083 0084 ColumnLayout { 0085 id: column 0086 0087 spacing: 0 0088 0089 QQC2.Control { 0090 id: columnHeader 0091 0092 topPadding: 0 0093 leftPadding: 0 0094 rightPadding: 0 0095 bottomPadding: 0 0096 } 0097 0098 Repeater { 0099 model: root.actions 0100 0101 delegate: QQC2.ItemDelegate { 0102 required property T.Action modelData 0103 0104 Layout.fillWidth: true 0105 Layout.preferredHeight: Kirigami.Units.gridUnit * 2 0106 0107 action: modelData 0108 visible: !(modelData instanceof Kirigami.Action) || modelData.visible 0109 0110 icon.width: Kirigami.Units.gridUnit 0111 icon.height: Kirigami.Units.gridUnit 0112 0113 horizontalPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing 0114 leftPadding: undefined 0115 rightPadding: undefined 0116 0117 QQC2.ToolTip.text: modelData instanceof Kirigami.Action ? modelData.tooltip : "" 0118 QQC2.ToolTip.visible: QQC2.ToolTip.text.length > 0 && (Kirigami.Settings.tabletMode ? pressed : hovered) 0119 QQC2.ToolTip.delay: Kirigami.Settings.tabletMode ? Qt.styleHints.mousePressAndHoldInterval : Kirigami.Units.toolTipDelay 0120 0121 onClicked: root.close() 0122 } 0123 } 0124 } 0125 0126 standardButtons: QQC2.DialogButtonBox.NoButton 0127 showCloseButton: true 0128 }