/*SPDX-FileCopyrightText: 2013-2015 Eike Hein <hein@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/pragma ComponentBehavior: Boundimport QtQuickimport QtQuick.Layoutsimport org.kde.kirigami as Kirigamiimport org.kde.ksvg as KSvgimport org.kde.plasma.components as PlasmaComponents3import org.kde.plasma.private.kicker as Kickerimport org.kde.plasma.core as PlasmaCoreimport org.kde.plasma.plasmoidItemAbstractDelegate {id: rootrequired property bool showIconsproperty bool showDescriptionInTooltip: falseproperty alias containsMouse: toolTipArea.containsMousereadonly property bool iconAndLabelsShouldlookSelected: pressed && !hasChildrenwidth: ListView.view.widthheight: implicitHeight// if it's not disabled and is either a leaf node or a node with childrenenabled: !isSeparator && !disabled && (!isParent || (isParent && hasChildren))hoverEnabled: false // containsMouse is more robust if the tooltip covers delegatesfavoritesModel: ListView.view.model.favoritesModelbaseModel: ListView.view.modeldragActive: dragHandler.activeAccessible.role: isSeparator ? Accessible.Separator : Accessible.ListItemAccessible.description: isParent? i18nc("@action:inmenu accessible description for opening submenu", "Open category"): i18nc("@action:inmenu accessible description for opening app or file", "Launch")onHasChildrenChanged: {if (!hasChildren && root.ListView.isCurrentItem) {root.ListView.view.currentIndex = -1;}}contentItem: RowLayout {id: rowspacing: Kirigami.Units.smallSpacing * 2LayoutMirroring.enabled: (Application.layoutDirection === Qt.RightToLeft)Kirigami.Icon {id: iconLayout.alignment: Qt.AlignVCenterimplicitWidth: Kirigami.Units.iconSizes.smallimplicitHeight: implicitWidthvisible: root.showIcons & !root.isSeparatoranimated: falseselected: root.iconAndLabelsShouldlookSelectedsource: root.model.decoration}PlasmaComponents3.Label {id: labelenabled: !root.isParent || (root.isParent && root.hasChildren)LayoutMirroring.enabled: (Application.layoutDirection === Qt.RightToLeft)visible: !root.isSeparatorLayout.fillWidth: trueLayout.alignment: Qt.AlignVCenterverticalAlignment: Text.AlignVCentertextFormat: Text.PlainTextwrapMode: Text.NoWrapelide: Text.ElideRightcolor: root.iconAndLabelsShouldlookSelected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColortext: root.model.display ?? ""}Loader {visible: activeactive: root.isNewlyInstalled ?? falsesourceComponent: Kirigami.Badge {text: root.hasChildren ? "" : Accessible.nametype: Kirigami.Badge.Type.PositiveAccessible.name: i18nc("Newly-installed app, badge, keep short", "New!")Accessible.description: root.hasChildren ? i18nc("@info:whatsthis Accessible description for badge", "There is a newly-installed application in this category"): i18nc("@info:whatsthis Accessible description for badge", "Newly-installed application")}}Kirigami.Icon {id: arrowLayout.alignment: Qt.AlignVCenterimplicitWidth: visible ? Kirigami.Units.iconSizes.small : 0implicitHeight: implicitWidthvisible: root.hasChildren && !root.isSeparatoropacity: (root.ListView.view.currentIndex === root.index) ? 1.0 : 0.4selected: root.iconAndLabelsShouldlookSelectedsource: root.dialogDefaultRight? "go-next-symbolic": "go-next-rtl-symbolic"}Loader {id: separatorLoaderLayout.alignment: Qt.AlignVCenterLayout.fillWidth: trueactive: root.isSeparatorvisible: activeasynchronous: falsesourceComponent: separatorComponent}}DragHandler {id: dragHandlertarget: nullenabled: (root.url && root.url.toString() !== "") || (root.favoriteId != "")onActiveChanged: {if (active) {// we need dragHelper and can't use attached Drag; submenus are destroyed too soon and Plasma crashesif (!root.favoriteId) {dragHelper.startDrag(kicker, root.url, root.decoration)} else {let type = root.favoritesModel instanceof Kicker.SimpleFavoritesModel? "text/xx-kicker-simplefavorite-id": "text/xx-kicker-kastatsfavorite-id"dragHelper.startDrag(kicker, root.url, root.decoration,type, root.favoriteId)}}}}Component {id: separatorComponentKSvg.SvgItem {width: parent.widthimagePath: "widgets/line"elementId: "horizontal-line"}}PlasmaCore.ToolTipArea {id: toolTipArea// needs to be ToolTipArea, as ItemListDialog will clip (attached) ToolTip if the submenu// has very few entries (and makes it feel glitchy then)anchors.fill: parentactive: label.truncated || root.showDescriptionInTooltipmainText: {// if it's name (description) or description (name), we split them on separate lines// but only if the compactName is available (e.g. for search results it's not)let name = (Plasmoid.configuration.appNameFormat > 1 && root.compactName.length > 1) ? root.compactName : root.textreturn label.truncated ? name ?? "" : ""}subText: root.showDescriptionInTooltip || Plasmoid.configuration.appNameFormat > 1 ? root.description ?? "" : ""}}