Improve the sizing of notification count with longer numbers

![image](/uploads/ad2128bbfc0ebfd58e2d58926fceb844/image.png)
This commit is contained in:
James Graham
2022-12-31 12:54:45 +00:00
parent 07d65a0046
commit 6651fa4fa3

View File

@@ -370,11 +370,13 @@ Kirigami.ScrollablePage {
Accessible.name: i18n("Muted room") Accessible.name: i18n("Muted room")
} }
QQC2.Label { QQC2.Label {
id: notificationCountLabel
text: notificationCount > 0 ? notificationCount : "●" text: notificationCount > 0 ? notificationCount : "●"
visible: unreadCount > 0 visible: unreadCount > 0
color: Kirigami.Theme.textColor color: Kirigami.Theme.textColor
Layout.rightMargin: Kirigami.Units.smallSpacing Layout.rightMargin: Kirigami.Units.smallSpacing
Layout.minimumWidth: height Layout.minimumHeight: Kirigami.Units.iconSizes.smallMedium
Layout.minimumWidth: Math.max(notificationCountTextMetrics.advanceWidth + Kirigami.Units.smallSpacing * 2, height)
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
background: Rectangle { background: Rectangle {
visible: notificationCount > 0 visible: notificationCount > 0
@@ -383,6 +385,12 @@ Kirigami.ScrollablePage {
opacity: highlightCount > 0 ? 1 : 0.3 opacity: highlightCount > 0 ? 1 : 0.3
radius: height / 2 radius: height / 2
} }
TextMetrics {
id: notificationCountTextMetrics
text: notificationCountLabel.text
onTextChanged: console.log(text, advanceWidth)
}
} }
QQC2.Button { QQC2.Button {
id: configButton id: configButton