/*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: itemrequired 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 && ListView.view.currentItem === item) {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: item.showIcons & !item.isSeparatoranimated: falseselected: item.iconAndLabelsShouldlookSelectedsource: item.model.decoration}PlasmaComponents3.Label {id: labelenabled: !item.isParent || (item.isParent && item.hasChildren)LayoutMirroring.enabled: (Application.layoutDirection === Qt.RightToLeft)visible: !item.isSeparatorLayout.fillWidth: trueLayout.alignment: Qt.AlignVCenterverticalAlignment: Text.AlignVCentertextFormat: Text.PlainTextwrapMode: Text.NoWrapelide: Text.ElideRightcolor: item.iconAndLabelsShouldlookSelected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColortext: item.model.display ?? ""}Loader {visible: activeactive: item.isNewlyInstalled ?? falsesourceComponent: Kirigami.Badge {text: item.hasChildren ? "" : Accessible.nametype: Kirigami.Badge.Type.PositiveAccessible.name: i18nc("Newly-installed app, badge, keep short", "New!") // qmllint disable unqualifiedAccessible.description: item.hasChildren ? i18nc("@info:whatsthis Accessible description for badge", "There is a newly-installed application in this category") // qmllint disable unqualified: i18nc("@info:whatsthis Accessible description for badge", "Newly-installed application") // qmllint disable unqualified}}Kirigami.Icon {id: arrowLayout.alignment: Qt.AlignVCenterimplicitWidth: visible ? Kirigami.Units.iconSizes.small : 0implicitHeight: implicitWidthvisible: item.hasChildren && !item.isSeparatoropacity: (item.ListView.view.currentIndex === item.index) ? 1.0 : 0.4selected: item.iconAndLabelsShouldlookSelectedsource: item.dialogDefaultRight? "go-next-symbolic": "go-next-rtl-symbolic"}Loader {id: separatorLoaderLayout.alignment: Qt.AlignVCenterLayout.fillWidth: trueactive: item.isSeparatorvisible: activeasynchronous: falsesourceComponent: separatorComponent}}DragHandler {id: dragHandlertarget: nullonActiveChanged: {if (active && item.url) {// we need dragHelper and can't use attached Drag; submenus are destroyed too soon and Plasma crashesif (!item.favoriteId) {dragHelper.startDrag(kicker, item.url, item.decoration)} else {let type = item.favoritesModel instanceof Kicker.SimpleFavoritesModel? "text/xx-kicker-simplefavorite-id": "text/xx-kicker-kastatsfavorite-id"dragHelper.startDrag(kicker, item.url, item.decoration,type, item.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 || item.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 && item.compactName.length > 1) ? item.compactName : item.textreturn label.truncated ? name ?? "" : ""}subText: item.showDescriptionInTooltip || Plasmoid.configuration.appNameFormat > 1 ? item.description ?? "" : ""}}