Warning, /plasma/plasma-desktop/applets/taskmanager/package/contents/ui/Badge.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2018 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
0009 import org.kde.plasma.components 3.0 as PlasmaComponents3
0010 import org.kde.kirigami 2.20 as Kirigami
0011
0012 // This top-level item is an opaque background that goes behind the colored
0013 // background, for contrast. It's not an Item since that it would be square,
0014 // and not round, as required here
0015 Rectangle {
0016 id: badgeRect
0017
0018 property alias text: label.text
0019 property alias textColor: label.color
0020 property int number: 0
0021
0022 implicitWidth: Math.max(height, Math.round(label.contentWidth + radius / 2)) // Add some padding around.
0023 implicitHeight: implicitWidth
0024
0025 radius: height / 2
0026
0027 color: Kirigami.Theme.backgroundColor
0028
0029 // Colored background
0030 Rectangle {
0031 readonly property color color_: Kirigami.Theme.highlightColor
0032
0033 anchors.fill: parent
0034 radius: height / 2
0035
0036 color: Qt.rgba(color_.r, color_.g, color_.b, 0.3)
0037 border.color: color_
0038 border.width: 1
0039 }
0040
0041 // Number
0042 PlasmaComponents3.Label {
0043 id: label
0044 anchors.centerIn: parent
0045 width: height
0046 height: Math.min(Kirigami.Units.gridUnit * 2, Math.round(parent.height))
0047 horizontalAlignment: Text.AlignHCenter
0048 verticalAlignment: Text.AlignVCenter
0049 fontSizeMode: Text.VerticalFit
0050 font.pointSize: 1024
0051 minimumPointSize: 5
0052 text: {
0053 if (badgeRect.number < 0) {
0054 return i18nc("Invalid number of new messages, overlay, keep short", "—");
0055 } else if (badgeRect.number > 9999) {
0056 return i18nc("Over 9999 new messages, overlay, keep short", "9,999+");
0057 } else {
0058 return badgeRect.number.toLocaleString(Qt.locale(), 'f', 0);
0059 }
0060 }
0061 textFormat: Text.PlainText
0062 }
0063 }