From 4370878b125a329e4d7707342b8debef86198426 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 31 Mar 2018 10:29:15 +0300 Subject: [PATCH] support pretty big badge messages counter --following plasma paradigm we now support badge messages until 9.999 and even more to be shown to the user as indicator --- liblattedock/qml/BadgeText.qml | 25 ++++++++++++++++--- .../package/contents/ui/task/TaskIconItem.qml | 14 ++++++----- .../contents/ui/task/TaskProgressOverlay.qml | 10 +++++--- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/liblattedock/qml/BadgeText.qml b/liblattedock/qml/BadgeText.qml index 2fff9db40..099879d10 100644 --- a/liblattedock/qml/BadgeText.qml +++ b/liblattedock/qml/BadgeText.qml @@ -38,6 +38,7 @@ Rectangle { property bool textWithBackgroundColor: false property int radiusPerCentage: 100 + property int minimumWidth: 0 property double circleOpacity: 1 property double fontPixelSize: partSize // * 0.55 @@ -49,8 +50,11 @@ Rectangle { property color alphaBackColor: Qt.rgba(theme.backgroundColor.r, theme.backgroundColor.g, theme.backgroundColor.b, 0.45) property color alphaBackColor2: Qt.rgba(theme.backgroundColor.r, theme.backgroundColor.g, theme.backgroundColor.b, 0.8) + + width: Math.max(minimumWidth, valueText.width + 4*units.smallSpacing) + color: theme.backgroundColor //mainItemContainer.badgeIndicator > 0 ? alphaBackColor2 : alphaBackColor - radius: (radiusPerCentage / 100) * (width / 2) + radius: (radiusPerCentage / 100) * (height / 2) border.width: Math.max(1,width/64) border.color: root.minimizedDotColor //alphaBackColor2 @@ -106,19 +110,34 @@ Rectangle { } } + Rectangle { + id: badgerBackground + anchors.fill: canvas + color: canvas.drawColor + + visible: proportion === 100 && showNumber + radius: parent.radius + } + Text { id: valueText anchors.centerIn: parent text: { if (showNumber) { - return numberValue > 0 ? numberValue : "" + if (numberValue > 9999) { + return i18nc("Over 9999 new messages, overlay, keep short", "9,999+"); + } else if (numberValue > 0) { + return numberValue.toLocaleString(Qt.locale(), 'f', 0); + } else { + return ""; + } } if (showText) { return textValue; } } - font.pixelSize: 0.6 * parent.height + font.pixelSize: 0.55 * parent.height font.bold: true color: textWithBackgroundColor ? theme.backgroundColor : theme.textColor visible: showNumber || showText diff --git a/plasmoid/package/contents/ui/task/TaskIconItem.qml b/plasmoid/package/contents/ui/task/TaskIconItem.qml index 7db24929e..704343de3 100644 --- a/plasmoid/package/contents/ui/task/TaskIconItem.qml +++ b/plasmoid/package/contents/ui/task/TaskIconItem.qml @@ -322,15 +322,16 @@ Item{ Rectangle{ id: maskRect - width: parent.width/2 - height: width - radius: width + width: Math.max(infoBadge.contentWidth, parent.width / 2) + height: parent.height / 2 + radius: parent.height visible: badgesLoader.showProgress + //! Removes any remainings from the icon around the roundness at the corner Rectangle{ id: maskCorner - width:parent.width/2 - height:parent.height/2 + width: parent.width/2 + height: parent.height/2 } states: [ @@ -436,6 +437,7 @@ Item{ } //end of sourceComponent TaskProgressOverlay{ + id: infoBadge anchors.fill:parent opacity: badgesLoader.opacityN visible: badgesLoader.showProgress @@ -495,7 +497,7 @@ Item{ anchors.centerIn: parent //opacity: taskNumberLoader.opacityN && !root.enableShadows ? 1 : 0 - width: 0.4 * parent.width + minimumWidth: 0.4 * parent.width height: width numberValue: taskNumberLoader.fixedIndex < 10 ? taskNumberLoader.fixedIndex : 0 textValue: (keysArrayIndex>=0 && keysArrayIndex<10) ? keysAboveTen[keysArrayIndex] : '' diff --git a/plasmoid/package/contents/ui/task/TaskProgressOverlay.qml b/plasmoid/package/contents/ui/task/TaskProgressOverlay.qml index a93fa504a..8ab330184 100644 --- a/plasmoid/package/contents/ui/task/TaskProgressOverlay.qml +++ b/plasmoid/package/contents/ui/task/TaskProgressOverlay.qml @@ -27,10 +27,12 @@ import org.kde.latte 0.1 as Latte Item { id: background + readonly property int contentWidth: progressCircle.width + 0.1*height + Item { id: subRectangle - width: parent.width/ 2 - height: width + width: contentWidth + height: parent.height / 2 states: [ State { @@ -56,8 +58,8 @@ Item { Latte.BadgeText { id: progressCircle anchors.centerIn: parent - width: 0.8 * parent.width - height: width + minimumWidth: 0.8 * parent.height + height: 0.8 * parent.height numberValue: mainItemContainer.badgeIndicator > 0 ? mainItemContainer.badgeIndicator : centralItem.smartLauncherItem.count fullCircle: true showNumber: true