From 50ceddaa7e6887202d308cd038a4cd0a548dc1cd Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 17 Apr 2025 09:25:17 +0000 Subject: [PATCH] Improve the "Friends" space notification and tooltip text If you're a first-time user, the different states on this button may be a bit confusing. Instead of showing a "plus" sign (meaning an invite) it will add it to the total notification count. The tooltip text is also changed to reflect this. --- src/rooms/SpaceDrawer.qml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/rooms/SpaceDrawer.qml b/src/rooms/SpaceDrawer.qml index 790f91dc0..bd71f7756 100644 --- a/src/rooms/SpaceDrawer.qml +++ b/src/rooms/SpaceDrawer.qml @@ -125,12 +125,20 @@ QQC2.Control { AvatarTabButton { id: directChatButton + readonly property bool hasCountableNotifications: root.connection.directChatNotifications > 0 || root.connection.directChatInvites > 0 + Layout.fillWidth: true Layout.preferredHeight: width - Kirigami.Units.smallSpacing Layout.maximumHeight: width - Kirigami.Units.smallSpacing Layout.topMargin: Kirigami.Units.smallSpacing / 2 - text: i18nc("@button View all one-on-one chats with your friends.", "Friends") + text: { + if (directChatButton.hasCountableNotifications) { + return i18ncp("@button View all one-on-one chats with your friends.", "Friends (%1 notification)", "Friends (%1 notifications)", root.connection.directChatNotifications + root.connection.directChatInvites); + } + + return i18nc("@button View all one-on-one chats with your friends.", "Friends"); + } contentItem: Kirigami.Icon { source: "system-users-symbolic" @@ -144,8 +152,8 @@ QQC2.Control { width: Math.max(directChatNotificationCountTextMetrics.advanceWidth + Kirigami.Units.smallSpacing * 2, height) height: Kirigami.Units.iconSizes.smallMedium - text: root.connection.directChatNotifications > 0 ? root.connection.directChatNotifications : "" - visible: (root.connection.directChatNotifications > 0 || root.connection.directChatInvites) && RoomManager.currentSpace !== "DM" + text: visible ? root.connection.directChatNotifications + root.connection.directChatInvites : "" + visible: directChatButton.hasCountableNotifications && RoomManager.currentSpace !== "DM" color: Kirigami.Theme.textColor horizontalAlignment: Text.AlignHCenter background: Rectangle { @@ -160,13 +168,6 @@ QQC2.Control { id: directChatNotificationCountTextMetrics text: directChatNotificationCountLabel.text } - - Kirigami.Icon { - anchors.fill: parent - - source: "list-add-symbolic" - visible: root.connection.directChatInvites && root.connection.directChatNotifications === 0 - } } }