Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/ui/TaskBadgeOverlay.qml
Show All 28 Lines | 27 | Item { | |||
---|---|---|---|---|---|
29 | anchors.fill: parent | 29 | anchors.fill: parent | ||
30 | 30 | | |||
31 | Rectangle { | 31 | Rectangle { | ||
32 | readonly property int offset: Math.round(Math.max(units.smallSpacing / 2, badgeMask.width / 32)) | 32 | readonly property int offset: Math.round(Math.max(units.smallSpacing / 2, badgeMask.width / 32)) | ||
33 | x: Qt.application.layoutDirection === Qt.RightToLeft ? -offset + iconWidthDelta : parent.width - width + offset - iconWidthDelta | 33 | x: Qt.application.layoutDirection === Qt.RightToLeft ? -offset + iconWidthDelta : parent.width - width + offset - iconWidthDelta | ||
34 | y: -offset | 34 | y: -offset | ||
35 | width: badgeRect.width + offset * 2 | 35 | width: badgeRect.width + offset * 2 | ||
36 | height: badgeRect.height + offset * 2 | 36 | height: badgeRect.height + offset * 2 | ||
37 | radius: width | 37 | radius: badgeRect.radius + offset * 2 | ||
38 | | ||||
39 | // Badge changes width based on number. | ||||
40 | onWidthChanged: maskShaderSource.scheduleUpdate() | ||||
38 | } | 41 | } | ||
39 | } | 42 | } | ||
40 | 43 | | |||
41 | ShaderEffect { | 44 | ShaderEffectSource { | ||
42 | anchors.fill: parent | 45 | id: iconShaderSource | ||
43 | property var source: ShaderEffectSource { | | |||
44 | sourceItem: icon | 46 | sourceItem: icon | ||
45 | hideSource: true | 47 | hideSource: true | ||
46 | } | 48 | } | ||
47 | property var mask: ShaderEffectSource { | 49 | | ||
50 | ShaderEffectSource { | ||||
51 | id: maskShaderSource | ||||
48 | sourceItem: badgeMask | 52 | sourceItem: badgeMask | ||
49 | hideSource: true | 53 | hideSource: true | ||
50 | live: false | 54 | live: false | ||
51 | } | 55 | } | ||
52 | 56 | | |||
53 | onWidthChanged: mask.scheduleUpdate() | 57 | ShaderEffect { | ||
54 | onHeightChanged: mask.scheduleUpdate() | 58 | id: shader | ||
59 | | ||||
60 | anchors.fill: parent | ||||
61 | property var source: iconShaderSource | ||||
62 | property var mask: maskShaderSource | ||||
63 | | ||||
64 | onWidthChanged: maskShaderSource.scheduleUpdate() | ||||
65 | onHeightChanged: maskShaderSource.scheduleUpdate() | ||||
55 | 66 | | |||
56 | supportsAtlasTextures: true | 67 | supportsAtlasTextures: true | ||
57 | 68 | | |||
58 | fragmentShader: " | 69 | fragmentShader: " | ||
59 | varying highp vec2 qt_TexCoord0; | 70 | varying highp vec2 qt_TexCoord0; | ||
60 | uniform highp float qt_Opacity; | 71 | uniform highp float qt_Opacity; | ||
61 | uniform lowp sampler2D source; | 72 | uniform lowp sampler2D source; | ||
62 | uniform lowp sampler2D mask; | 73 | uniform lowp sampler2D mask; | ||
63 | void main() { | 74 | void main() { | ||
64 | gl_FragColor = texture2D(source, qt_TexCoord0.st) * (1.0 - (texture2D(mask, qt_TexCoord0.st).a)) * qt_Opacity; | 75 | gl_FragColor = texture2D(source, qt_TexCoord0.st) * (1.0 - (texture2D(mask, qt_TexCoord0.st).a)) * qt_Opacity; | ||
65 | } | 76 | } | ||
66 | " | 77 | " | ||
67 | } | 78 | } | ||
68 | 79 | | |||
69 | Rectangle { | 80 | Badge { | ||
70 | id: badgeRect | 81 | id: badgeRect | ||
71 | x: Qt.application.layoutDirection === Qt.RightToLeft ? iconWidthDelta : parent.width - width - iconWidthDelta | 82 | x: Qt.application.layoutDirection === Qt.RightToLeft ? iconWidthDelta : parent.width - width - iconWidthDelta | ||
72 | width: height | | |||
73 | height: Math.round(parent.height * 0.4) | 83 | height: Math.round(parent.height * 0.4) | ||
74 | color: theme.highlightColor | | |||
75 | radius: width | | |||
76 | 84 | | |||
77 | PlasmaComponents.Label { | 85 | number: task.smartLauncherItem.count | ||
78 | anchors.centerIn: parent | | |||
79 | width: height | | |||
80 | height: Math.round(parent.height) | | |||
81 | horizontalAlignment: Text.AlignHCenter | | |||
82 | verticalAlignment: Text.AlignVCenter | | |||
83 | fontSizeMode: Text.Fit | | |||
84 | font.pointSize: 1024 | | |||
85 | minimumPointSize: 5 | | |||
86 | color: theme.backgroundColor | | |||
87 | text: task.smartLauncherItem.count | | |||
88 | } | | |||
89 | } | 86 | } | ||
90 | } | 87 | } |