Why can't we be friends

Update the UX to refer to structure direct chats as friends. The direct chats are pulled into their own tab in the space drawer.

The `UserDetailDialog` is also updated to check whether a direct chat already exists and if not ask to invite as friend.

![image](/uploads/67f13fa8558e704e0acaf7c60e135bbc/image.png)
This commit is contained in:
James Graham
2024-01-13 21:38:43 +00:00
parent 981edc9cf7
commit 77e366b179
9 changed files with 222 additions and 9 deletions

View File

@@ -196,6 +196,7 @@ Kirigami.Page {
listView.currentIndex = sortFilterRoomListModel.mapFromSource(itemSelection.currentIndex).row
}
activeSpaceId: spaceDrawer.selectedSpaceId
mode: spaceDrawer.showDirectChats ? SortFilterRoomListModel.DirectChats : SortFilterRoomListModel.Rooms
}
section {

View File

@@ -23,6 +23,8 @@ QQC2.Control {
property string selectedSpaceId
property bool showDirectChats: false
contentItem: Loader {
id: sidebarColumn
z: 0
@@ -86,8 +88,56 @@ QQC2.Control {
source: "globe"
}
checked: root.selectedSpaceId === ""
onClicked: root.selectedSpaceId = ""
checked: root.selectedSpaceId === "" && root.showDirectChats === false
onClicked: {
root.showDirectChats = false
root.selectedSpaceId = ""
}
}
AvatarTabButton {
id: directChatButton
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")
contentItem: Kirigami.Icon {
source: "system-users"
}
checked: root.showDirectChats === true
onClicked: {
root.showDirectChats = true
root.selectedSpaceId = ""
}
QQC2.Label {
id: notificationCountLabel
anchors.top: parent.top
anchors.right: parent.right
anchors.rightMargin: Kirigami.Units.smallSpacing / 2
z: 1
width: Math.max(notificationCountTextMetrics.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
color: Kirigami.Theme.textColor
horizontalAlignment: Text.AlignHCenter
background: Rectangle {
visible: true
Kirigami.Theme.colorSet: Kirigami.Theme.Button
color: Kirigami.Theme.positiveTextColor
radius: height / 2
}
TextMetrics {
id: notificationCountTextMetrics
text: notificationCountLabel.text
}
}
}
Repeater {
@@ -117,7 +167,10 @@ QQC2.Control {
text: displayName
source: avatar ? ("image://mxc/" + avatar) : ""
onSelected: root.selectedSpaceId = roomId
onSelected: {
root.showDirectChats = false
root.selectedSpaceId = roomId
}
checked: root.selectedSpaceId === roomId
onContextMenuRequested: root.createContextMenu(currentRoom)
}

View File

@@ -215,7 +215,7 @@ Kirigami.Dialog {
FormCard.FormButtonDelegate {
visible: !root.user.isLocalUser
action: Kirigami.Action {
text: i18n("Open a private chat")
text: root.room.connection.directChatExists(root.user.object) ? i18nc("%1 is the name of the user.", "Chat with %1", root.user.displayName) : i18n("Invite to private chat")
icon.name: "document-send"
onTriggered: {
root.room.connection.openOrCreateDirectChat(root.user.object)