Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/ui/Badge.qml
Show All 25 Lines | 24 | Rectangle { | |||
---|---|---|---|---|---|
26 | 26 | | |||
27 | property alias text: label.text | 27 | property alias text: label.text | ||
28 | property alias textColor: label.color | 28 | property alias textColor: label.color | ||
29 | property int number: 0 | 29 | property int number: 0 | ||
30 | 30 | | |||
31 | implicitWidth: Math.max(height, Math.round(label.contentWidth + radius / 2)) // Add some padding around. | 31 | implicitWidth: Math.max(height, Math.round(label.contentWidth + radius / 2)) // Add some padding around. | ||
32 | color: theme.highlightColor | 32 | color: theme.highlightColor | ||
33 | radius: height / 2 | 33 | radius: height / 2 | ||
34 | visible: label.text.length !== 0 | ||||
34 | 35 | | |||
35 | PlasmaComponents.Label { | 36 | PlasmaComponents.Label { | ||
36 | id: label | 37 | id: label | ||
37 | anchors.centerIn: parent | 38 | anchors.centerIn: parent | ||
38 | width: height | 39 | width: height | ||
39 | height: Math.min(units.gridUnit * 2, Math.round(parent.height)) | 40 | height: Math.min(units.gridUnit * 2, Math.round(parent.height)) | ||
40 | horizontalAlignment: Text.AlignHCenter | 41 | horizontalAlignment: Text.AlignHCenter | ||
41 | verticalAlignment: Text.AlignVCenter | 42 | verticalAlignment: Text.AlignVCenter | ||
42 | fontSizeMode: Text.VerticalFit | 43 | fontSizeMode: Text.VerticalFit | ||
43 | font.pointSize: 1024 | 44 | font.pointSize: 1024 | ||
44 | minimumPointSize: 5 | 45 | minimumPointSize: 5 | ||
45 | color: theme.highlightedTextColor | 46 | color: theme.highlightedTextColor | ||
46 | text: { | 47 | text: { | ||
47 | if (badgeRect.number < 0) { | 48 | if (badgeRect.number < 0) { | ||
48 | return i18nc("Invalid number of new messages, overlay, keep short", "—"); | 49 | return i18nc("Invalid number of new messages, overlay, keep short", "—"); | ||
49 | } else if (badgeRect.number > 9999) { | 50 | } else if (badgeRect.number > 9999) { | ||
50 | return i18nc("Over 9999 new messages, overlay, keep short", "9,999+"); | 51 | return ""; | ||
51 | } else { | 52 | } else { | ||
52 | return badgeRect.number.toLocaleString(Qt.locale(), 'f', 0); | 53 | return badgeRect.number.toLocaleString(Qt.locale(), 'f', 0); | ||
53 | } | 54 | } | ||
54 | } | 55 | } | ||
55 | } | 56 | } | ||
56 | } | 57 | } |