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: shader.mask.scheduleUpdate() | ||||
38 | } | 41 | } | ||
39 | } | 42 | } | ||
40 | 43 | | |||
41 | ShaderEffect { | 44 | ShaderEffect { | ||
45 | id: shader | ||||
46 | | ||||
42 | anchors.fill: parent | 47 | anchors.fill: parent | ||
43 | property var source: ShaderEffectSource { | 48 | property var source: ShaderEffectSource { | ||
44 | sourceItem: icon | 49 | sourceItem: icon | ||
45 | hideSource: true | 50 | hideSource: true | ||
46 | } | 51 | } | ||
47 | property var mask: ShaderEffectSource { | 52 | property var mask: ShaderEffectSource { | ||
48 | sourceItem: badgeMask | 53 | sourceItem: badgeMask | ||
49 | hideSource: true | 54 | hideSource: true | ||
Show All 11 Lines | 63 | fragmentShader: " | |||
61 | uniform lowp sampler2D source; | 66 | uniform lowp sampler2D source; | ||
62 | uniform lowp sampler2D mask; | 67 | uniform lowp sampler2D mask; | ||
63 | void main() { | 68 | void main() { | ||
64 | gl_FragColor = texture2D(source, qt_TexCoord0.st) * (1.0 - (texture2D(mask, qt_TexCoord0.st).a)) * qt_Opacity; | 69 | gl_FragColor = texture2D(source, qt_TexCoord0.st) * (1.0 - (texture2D(mask, qt_TexCoord0.st).a)) * qt_Opacity; | ||
65 | } | 70 | } | ||
66 | " | 71 | " | ||
67 | } | 72 | } | ||
68 | 73 | | |||
69 | Rectangle { | 74 | Badge { | ||
70 | id: badgeRect | 75 | id: badgeRect | ||
71 | x: Qt.application.layoutDirection === Qt.RightToLeft ? iconWidthDelta : parent.width - width - iconWidthDelta | 76 | x: Qt.application.layoutDirection === Qt.RightToLeft ? iconWidthDelta : parent.width - width - iconWidthDelta | ||
72 | width: height | | |||
73 | height: Math.round(parent.height * 0.4) | 77 | height: Math.round(parent.height * 0.4) | ||
74 | color: theme.highlightColor | | |||
75 | radius: width | | |||
76 | 78 | | |||
77 | PlasmaComponents.Label { | 79 | 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 | } | 80 | } | ||
90 | } | 81 | } |