Warning, /plasma/qqc2-breeze-style/style/qtquickcontrols/Menu.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org> 0003 SPDX-FileCopyrightText: 2017 The Qt Company Ltd. 0004 SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com> 0005 SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later 0006 */ 0007 0008 0009 import QtQuick 0010 import QtQuick.Layouts 0011 import QtQuick.Window 0012 import QtQuick.Controls as Controls 0013 import QtQuick.Controls.impl 0014 import QtQuick.Templates as T 0015 import org.kde.kirigami as Kirigami 0016 0017 import org.kde.breeze.impl as Impl 0018 0019 T.Menu { 0020 id: control 0021 0022 readonly property bool __hasIndicators: contentItem.contentItem.visibleChildren.some(menuItem => menuItem?.indicator?.visible ?? false) 0023 readonly property bool __hasIcons: contentItem.contentItem.visibleChildren.some(menuItem => __itemHasIcon(menuItem)) 0024 readonly property bool __hasArrows: contentItem.contentItem.visibleChildren.some(menuItem => menuItem?.arrow?.visible ?? false) 0025 0026 // palette: Kirigami.Theme.palette 0027 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, 0028 contentWidth + leftPadding + rightPadding) 0029 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, 0030 contentHeight + topPadding + bottomPadding) 0031 padding: Kirigami.Units.smallSpacing 0032 margins: 0 0033 overlap: background && background.hasOwnProperty("border") ? background.border.width : 0 0034 0035 function __itemHasIcon(item) { 0036 const hasName = (item?.icon?.name ?? "") !== "" 0037 const hasSource = (item?.icon?.source.toString() ?? "") !== "" 0038 return hasName || hasSource 0039 } 0040 0041 // The default contentItem is a ListView, which has its own contentItem property, 0042 // so delegates will be created as children of control.contentItem.contentItem 0043 delegate: Controls.MenuItem {} 0044 0045 contentItem: ListView { 0046 implicitHeight: contentHeight 0047 // Cannot use `contentWidth` as this only accounts for Actions, not MenuItems or MenuSeparators 0048 implicitWidth: contentItem.visibleChildren.reduce((maxWidth, child) => Math.max(maxWidth, child.implicitWidth), 0) 0049 model: control.contentModel 0050 highlightMoveDuration: Kirigami.Units.shortDuration 0051 highlightMoveVelocity: 800 0052 highlight: Impl.ListViewHighlight { 0053 currentIndex: control.currentIndex 0054 count: control.count 0055 alwaysCurveCorners: true 0056 } 0057 // For some reason, `keyNavigationEnabled: true` isn't needed and 0058 // using it causes separators and disabled items to be highlighted 0059 keyNavigationWraps: true 0060 0061 // Makes it so you can't drag/flick the list view around unless the menu is taller than the window 0062 interactive: Window.window ? contentHeight + control.topPadding + control.bottomPadding > Window.window.height : false 0063 clip: interactive // Only needed when the ListView can be dragged/flicked 0064 currentIndex: control.currentIndex || 0 0065 0066 ScrollBar.vertical: Controls.ScrollBar {} 0067 } 0068 0069 enter: Transition { 0070 ParallelAnimation { 0071 NumberAnimation { 0072 property: "opacity" 0073 from: 0 0074 to: 1 0075 easing.type: Easing.OutCubic 0076 duration: Kirigami.Units.shortDuration 0077 } 0078 } 0079 } 0080 0081 exit: Transition { 0082 ParallelAnimation { 0083 NumberAnimation { 0084 property: "opacity" 0085 from: 1 0086 to: 0 0087 easing.type: Easing.InCubic 0088 duration: Kirigami.Units.shortDuration 0089 } 0090 } 0091 } 0092 0093 background: Rectangle { 0094 radius: Impl.Units.smallRadius 0095 implicitHeight: Impl.Units.mediumControlHeight 0096 implicitWidth: Kirigami.Units.gridUnit * 8 0097 color: Kirigami.Theme.backgroundColor 0098 0099 border { 0100 color: Impl.Theme.separatorColor() 0101 width: Impl.Units.smallBorder 0102 } 0103 0104 Impl.LargeShadow { 0105 radius: parent.radius 0106 } 0107 } 0108 }