/*SPDX-FileCopyrightText: 2013 Sebastian KΓΌgler <sebas@kde.org>SPDX-FileCopyrightText: 2014 Martin GrΓ€Γlin <mgraesslin@kde.org>SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>SPDX-License-Identifier: LGPL-2.0-or-later*/import QtQuick 2.15import QtQuick.Layouts 1.15import QtQuick.Window 2.15import QtQml.Models 2.15import org.kde.plasma.plasmoid 2.0import org.kde.plasma.core as PlasmaCoreimport org.kde.plasma.components 3.0 as PlasmaComponents3import org.kde.kirigami 2.20 as KirigamiLoader {id: toolTipDelegateproperty Item parentTaskproperty var rootIndexproperty string appNameproperty int pidParentproperty bool isGroupproperty var windowsreadonly property bool isWin: (windows?.length ?? 0) > 0property variant iconproperty url launcherUrlproperty bool isLauncherproperty bool isMinimizedParent// Needed for generateSubtext()property string displayParentproperty string genericNameproperty var virtualDesktopParentproperty bool isOnAllVirtualDesktopsParentproperty var activitiesParent//property bool smartLauncherCountVisibleproperty int smartLauncherCountproperty bool blockingUpdates: falsereadonly property bool isVerticalPanel: Plasmoid.formFactor === PlasmaCore.Types.Vertical// This number controls the overall size of the window tooltipsreadonly property int tooltipInstanceMaximumWidth: Kirigami.Units.gridUnit * 16// These properties are required to make tooltip interactive when there is a player but no window is present.readonly property QtObject playerData: mpris2Source.playerForLauncherUrl(launcherUrl, pidParent)Layout.minimumWidth: implicitWidthLayout.maximumWidth: Layout.minimumWidthLayout.minimumHeight: implicitHeightLayout.maximumHeight: Layout.minimumHeightLayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeftLayoutMirroring.childrenInherit: trueactive: !blockingUpdates && rootIndex !== undefined && ((parentTask && parentTask.containsMouse) || Window.visibility !== Window.Hidden)asynchronous: truesourceComponent: isGroup ? groupToolTip : singleTooltipComponent {id: singleTooltipToolTipInstance {submodelIndex: toolTipDelegate.rootIndex}}Component {id: groupToolTipPlasmaComponents3.ScrollView {// 2 * Kirigami.Units.smallSpacing is for the margin of tooltipDialogimplicitWidth: leftPadding + rightPadding + Math.min(Screen.desktopAvailableWidth - 2 * Kirigami.Units.smallSpacing, Math.max(delegateModel.estimatedWidth, contentItem.contentItem.childrenRect.width))implicitHeight: bottomPadding + Math.min(Screen.desktopAvailableHeight - 2 * Kirigami.Units.smallSpacing, Math.max(delegateModel.estimatedHeight, contentItem.contentItem.childrenRect.height))ListView {id: groupToolTipListViewmodel: delegateModelorientation: isVerticalPanel ? ListView.Vertical : ListView.HorizontalreuseItems: truespacing: Kirigami.Units.gridUnit}DelegateModel {id: delegateModel// On Wayland, a tooltip has a significant resizing process, so estimate the size first.readonly property real estimatedWidth: (toolTipDelegate.isVerticalPanel ? 1 : count) * (toolTipDelegate.tooltipInstanceMaximumWidth + Kirigami.Units.gridUnit) - Kirigami.Units.gridUnitreadonly property real estimatedHeight: (toolTipDelegate.isVerticalPanel ? count : 1) * (toolTipDelegate.tooltipInstanceMaximumWidth / 2 + Kirigami.Units.gridUnit) - Kirigami.Units.gridUnitmodel: tasksModelrootIndex: toolTipDelegate.rootIndexonRootIndexChanged: groupToolTipListView.positionViewAtBeginning() // Fix a visual glitch (when the mouse moves from a tooltip with a moved scrollbar to another tooltip without a scrollbar)delegate: ToolTipInstance {submodelIndex: tasksModel.makeModelIndex(toolTipDelegate.rootIndex.row, index)}}}}}