From 6651fa4fa3ebf358b4043cde88ec60888569c8b6 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sat, 31 Dec 2022 12:54:45 +0000 Subject: [PATCH] Improve the sizing of notification count with longer numbers ![image](/uploads/ad2128bbfc0ebfd58e2d58926fceb844/image.png) --- src/qml/Page/RoomListPage.qml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/qml/Page/RoomListPage.qml b/src/qml/Page/RoomListPage.qml index e7f97f24f..089e3ee68 100644 --- a/src/qml/Page/RoomListPage.qml +++ b/src/qml/Page/RoomListPage.qml @@ -370,11 +370,13 @@ Kirigami.ScrollablePage { Accessible.name: i18n("Muted room") } QQC2.Label { + id: notificationCountLabel text: notificationCount > 0 ? notificationCount : "●" visible: unreadCount > 0 color: Kirigami.Theme.textColor 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 background: Rectangle { visible: notificationCount > 0 @@ -383,6 +385,12 @@ Kirigami.ScrollablePage { opacity: highlightCount > 0 ? 1 : 0.3 radius: height / 2 } + + TextMetrics { + id: notificationCountTextMetrics + text: notificationCountLabel.text + onTextChanged: console.log(text, advanceWidth) + } } QQC2.Button { id: configButton