/*SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuick 2.15import org.kde.plasma.core 2.0 as PlasmaCoreItem {readonly property int iconWidthDelta: (icon.width - icon.paintedWidth) / 2readonly property bool shiftBadgeDown: (plasmoid.pluginName === "org.kde.plasma.icontasks") && task.audioStreamIconLoaderItem.shownItem {id: badgeMaskanchors.fill: parentRectangle {readonly property int offset: Math.round(Math.max(PlasmaCore.Units.smallSpacing / 2, badgeMask.width / 32))anchors.right: Qt.application.layoutDirection === Qt.RightToLeft ? undefined : parent.rightanchors.left: Qt.application.layoutDirection === Qt.RightToLeft ? parent.left : undefinedanchors.rightMargin: Qt.application.layoutDirection === Qt.RightToLeft ? 0 : -offsetanchors.leftMargin: Qt.application.layoutDirection === Qt.RightToLeft ? -offset : 0y: shiftBadgeDown ? (icon.height/2) : 0Behavior on y {NumberAnimation { duration: Kirigami.Durations.longDuration }}visible: task.smartLauncherItem.countVisiblewidth: badgeRect.width + offset * 2height: badgeRect.height + offset * 2radius: badgeRect.radius + offset * 2// Badge changes width based on number.onWidthChanged: maskShaderSource.scheduleUpdate()onVisibleChanged: maskShaderSource.scheduleUpdate()onYChanged: maskShaderSource.scheduleUpdate()}}ShaderEffectSource {id: iconShaderSourcesourceItem: iconhideSource: GraphicsInfo.api !== GraphicsInfo.Software}ShaderEffectSource {id: maskShaderSourcesourceItem: badgeMaskhideSource: truelive: false}ShaderEffect {id: shaderanchors.fill: parentproperty var source: iconShaderSourceproperty var mask: maskShaderSourceonWidthChanged: maskShaderSource.scheduleUpdate()onHeightChanged: maskShaderSource.scheduleUpdate()supportsAtlasTextures: truefragmentShader: `varying highp vec2 qt_TexCoord0;uniform highp float qt_Opacity;uniform lowp sampler2D source;uniform lowp sampler2D mask;void main() {gl_FragColor = texture2D(source, qt_TexCoord0.st) * (1.0 - (texture2D(mask, qt_TexCoord0.st).a)) * qt_Opacity;}`}Badge {readonly property int offset: Math.round(Math.max(PlasmaCore.Units.smallSpacing / 2, badgeMask.width / 32))id: badgeRectanchors.right: Qt.application.layoutDirection === Qt.RightToLeft ? undefined : parent.rightanchors.left: Qt.application.layoutDirection === Qt.RightToLeft ? parent.left : undefinedy: offset + (shiftBadgeDown ? (icon.height/2) : 0)Behavior on y {NumberAnimation { duration: Kirigami.Durations.longDuration }}height: Math.round(parent.height * 0.4)visible: task.smartLauncherItem.countVisiblenumber: task.smartLauncherItem.count}}