/*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.core 2.0 as PlasmaCoreimport org.kde.plasma.components 3.0 as PlasmaComponents3Loader {id: toolTipDelegateproperty Item parentTaskproperty var rootIndexproperty string appNameproperty int pidParentproperty bool isGroupproperty var windowsreadonly property bool isWin: windows !== undefinedproperty 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: PlasmaCore.Units.gridUnit * 16// These properties are required to make tooltip interactive when there is a player but no window is present.readonly property string mprisSourceName: mpris2Source.sourceNameForLauncherUrl(launcherUrl, pidParent)readonly property var playerData: mprisSourceName != "" ? mpris2Source.data[mprisSourceName] : 0readonly property bool hasPlayer: !!mprisSourceName && !!playerDataBinding on Layout.minimumWidth {value: implicitWidthdelayed: true // Prevent early hide of tooltip (BUG439522)}Layout.maximumWidth: Layout.minimumWidthBinding on Layout.minimumHeight {value: implicitHeightdelayed: true // Prevent early hide of tooltip (BUG439522)}Layout.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 * PlasmaCore.Units.smallSpacing is for the margin of tooltipDialogimplicitWidth: leftPadding + rightPadding + Math.min(Screen.desktopAvailableWidth - 2 * PlasmaCore.Units.smallSpacing, Math.max(delegateModel.estimatedWidth, contentItem.contentItem.childrenRect.width))implicitHeight: bottomPadding + Math.min(Screen.desktopAvailableHeight - 2 * PlasmaCore.Units.smallSpacing, Math.max(delegateModel.estimatedHeight, contentItem.contentItem.childrenRect.height))// HACK: workaround for https://bugreports.qt.io/browse/QTBUG-83890PlasmaComponents3.ScrollBar.horizontal.policy: isVerticalPanel ? PlasmaComponents3.ScrollBar.AlwaysOff : PlasmaComponents3.ScrollBar.AsNeededPlasmaComponents3.ScrollBar.vertical.policy: isVerticalPanel ? PlasmaComponents3.ScrollBar.AsNeeded : PlasmaComponents3.ScrollBar.AlwaysOffListView {id: groupToolTipListView// HACK: workaround for https://bugreports.qt.io/browse/QTBUG-102811model: delegateModel.count > 0 ? delegateModel : nullorientation: isVerticalPanel ? ListView.Vertical : ListView.HorizontalreuseItems: truespacing: PlasmaCore.Units.largeSpacing}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 + PlasmaCore.Units.largeSpacing) - PlasmaCore.Units.largeSpacingreadonly property real estimatedHeight: (toolTipDelegate.isVerticalPanel ? count : 1) * (toolTipDelegate.tooltipInstanceMaximumWidth / 2 + PlasmaCore.Units.largeSpacing) - PlasmaCore.Units.largeSpacingmodel: 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)}}}}}