/*SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport org.kde.plasma.components as PlasmaComponents3import org.kde.kirigami as Kirigami// This top-level item is an opaque background that goes behind the colored// background, for contrast. It's not an Item since that it would be square,// and not round, as required hereRectangle {id: badgeRectproperty alias text: label.textproperty alias textColor: label.colorproperty int number: 0implicitWidth: Math.max(height, Math.round(label.contentWidth + radius / 2)) // Add some padding around.implicitHeight: implicitWidthradius: height / 2color: Kirigami.Theme.backgroundColor// Colored backgroundRectangle {anchors.fill: parentradius: height / 2color: Qt.alpha(Kirigami.Theme.highlightColor, 0.3)border.color: Kirigami.Theme.highlightColorborder.width: 1}// NumberPlasmaComponents3.Label {id: labelanchors.centerIn: parentwidth: heightheight: Math.min(Kirigami.Units.gridUnit * 2, Math.round(parent.height))horizontalAlignment: Text.AlignHCenterverticalAlignment: Text.AlignVCenterfontSizeMode: Text.VerticalFitfont.pointSize: 1024minimumPointSize: 5text: {if (badgeRect.number < 0) {return i18nc("Invalid number of new messages, overlay, keep short", "—");} else if (badgeRect.number > 9999) {return i18nc("Over 9999 new messages, overlay, keep short", "9,999+");} else {return badgeRect.number.toLocaleString(Qt.locale(), 'f', 0);}}textFormat: Text.PlainText}}