Warning, /plasma/plasma-desktop/applets/taskmanager/package/contents/ui/TaskBadgeOverlay.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.15
0008 import org.kde.kirigami 2.20 as Kirigami
0009 import org.kde.graphicaleffects as KGraphicalEffects
0010 import org.kde.plasma.plasmoid 2.0
0011 
0012 Item {
0013     readonly property int iconWidthDelta: (icon.width - icon.paintedWidth) / 2
0014     readonly property bool shiftBadgeDown: (Plasmoid.pluginName === "org.kde.plasma.icontasks") && task.audioStreamIcon !== null
0015 
0016     Item {
0017         id: badgeMask
0018         anchors.fill: parent
0019 
0020         Rectangle {
0021             readonly property int offset: Math.round(Math.max(Kirigami.Units.smallSpacing / 2, badgeMask.width / 32))
0022             anchors.right: Qt.application.layoutDirection === Qt.RightToLeft ? undefined : parent.right
0023             anchors.left: Qt.application.layoutDirection === Qt.RightToLeft ? parent.left : undefined
0024             anchors.rightMargin: Qt.application.layoutDirection === Qt.RightToLeft ? 0 : -offset
0025             anchors.leftMargin: Qt.application.layoutDirection === Qt.RightToLeft ? -offset : 0
0026             y: shiftBadgeDown ? (icon.height/2) : 0
0027             Behavior on y {
0028                 NumberAnimation { duration: Kirigami.Units.longDuration }
0029             }
0030 
0031             visible: task.smartLauncherItem.countVisible
0032             width: badgeRect.width + offset * 2
0033             height: badgeRect.height + offset * 2
0034             radius: badgeRect.radius + offset * 2
0035 
0036             // Badge changes width based on number.
0037             onWidthChanged: maskShaderSource.scheduleUpdate()
0038             onVisibleChanged: maskShaderSource.scheduleUpdate()
0039             onYChanged: maskShaderSource.scheduleUpdate()
0040         }
0041     }
0042 
0043     ShaderEffectSource {
0044         id: iconShaderSource
0045         sourceItem: icon
0046         hideSource: GraphicsInfo.api !== GraphicsInfo.Software
0047     }
0048 
0049     ShaderEffectSource {
0050         id: maskShaderSource
0051         sourceItem: badgeMask
0052         hideSource: true
0053         live: false
0054     }
0055 
0056     KGraphicalEffects.BadgeEffect {
0057         id: shader
0058 
0059         anchors.fill: parent
0060         source: iconShaderSource
0061         mask: maskShaderSource
0062 
0063         onWidthChanged: maskShaderSource.scheduleUpdate()
0064         onHeightChanged: maskShaderSource.scheduleUpdate()
0065     }
0066 
0067     Badge {
0068         readonly property int offset: Math.round(Math.max(Kirigami.Units.smallSpacing / 2, badgeMask.width / 32))
0069         id: badgeRect
0070         anchors.right: Qt.application.layoutDirection === Qt.RightToLeft ? undefined : parent.right
0071         anchors.left: Qt.application.layoutDirection === Qt.RightToLeft ? parent.left : undefined
0072         y: offset + (shiftBadgeDown ? (icon.height/2) : 0)
0073         Behavior on y {
0074             NumberAnimation { duration: Kirigami.Units.longDuration }
0075         }
0076         height: Math.round(parent.height * 0.4)
0077         visible: task.smartLauncherItem.countVisible
0078         number: task.smartLauncherItem.count
0079     }
0080 }