From b595a2966cd5b13997160736561fa6396bae2364 Mon Sep 17 00:00:00 2001 From: James Graham Date: Wed, 25 Dec 2024 19:53:41 +0000 Subject: [PATCH] Thread alignment It doesn't make sense for a thread to be on the right or tinted when the local user started it as they contain messages from multiple users. So always make them align left and never tint them. --- src/timeline/Bubble.qml | 7 ++++++- src/timeline/MessageDelegate.qml | 10 +++++----- src/timeline/ReplyButtonComponent.qml | 2 ++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/timeline/Bubble.qml b/src/timeline/Bubble.qml index 5e161b899..ae3e4317e 100644 --- a/src/timeline/Bubble.qml +++ b/src/timeline/Bubble.qml @@ -51,6 +51,11 @@ QQC2.Control { */ required property var contentModel + /** + * @brief Whether the message in a thread. + */ + required property bool isThreaded + /** * @brief Whether the bubble background should be shown. */ @@ -134,7 +139,7 @@ QQC2.Control { visible: root.showBackground Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.inherit: false - color: if (root.author.isLocalMember) { + color: if (root.author.isLocalMember && !root.isThreaded) { return Kirigami.ColorUtils.tintWithAlpha(Kirigami.Theme.backgroundColor, Kirigami.Theme.highlightColor, 0.15); } else if (root.showHighlight) { return Kirigami.Theme.positiveBackgroundColor; diff --git a/src/timeline/MessageDelegate.qml b/src/timeline/MessageDelegate.qml index 68793d62b..50e682893 100644 --- a/src/timeline/MessageDelegate.qml +++ b/src/timeline/MessageDelegate.qml @@ -201,7 +201,7 @@ TimelineDelegate { /** * @brief The width available to the bubble content. */ - property real contentMaxWidth: bubbleSizeHelper.currentWidth - bubble.leftPadding - bubble.rightPadding + property real contentMaxWidth: (root.isThreaded ? bubbleSizeHelper.parentWidth : bubbleSizeHelper.currentWidth) - bubble.leftPadding - bubble.rightPadding width: parent?.width rightPadding: NeoChatConfig.compactLayout && root.ListView.view.width >= Kirigami.Units.gridUnit * 20 ? Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing : Kirigami.Units.largeSpacing @@ -246,7 +246,7 @@ TimelineDelegate { topMargin: Kirigami.Units.smallSpacing } - visible: (root.contentModel?.showAuthor ?? false) && NeoChatConfig.showAvatarInTimeline && (NeoChatConfig.compactLayout || !_private.showUserMessageOnRight) + visible: ((root.contentModel?.showAuthor ?? false) || root.isThreaded) && NeoChatConfig.showAvatarInTimeline && (NeoChatConfig.compactLayout || !_private.showUserMessageOnRight) name: root.author.displayName source: root.author.avatarUrl color: root.author.color @@ -258,7 +258,7 @@ TimelineDelegate { id: bubble anchors.left: avatar.right anchors.leftMargin: Kirigami.Units.largeSpacing - anchors.rightMargin: Kirigami.Units.largeSpacing + anchors.rightMargin: rightPadding maxContentWidth: root.contentMaxWidth topPadding: NeoChatConfig.compactLayout ? Kirigami.Units.smallSpacing / 2 : Kirigami.Units.largeSpacing @@ -290,8 +290,8 @@ TimelineDelegate { room: root.room index: root.index - author: root.author + isThreaded: root.isThreaded // HACK: This is stupid but seemingly QConcatenateTablesProxyModel // can't be passed as a model role, always returning null. @@ -383,7 +383,7 @@ TimelineDelegate { /** * @brief Whether local user messages should be aligned right. */ - property bool showUserMessageOnRight: NeoChatConfig.showLocalMessagesOnRight && root.author.isLocalMember && !NeoChatConfig.compactLayout && !root.alwaysFillWidth + property bool showUserMessageOnRight: NeoChatConfig.showLocalMessagesOnRight && root.author.isLocalMember && !NeoChatConfig.compactLayout && !root.alwaysFillWidth && !root.isThreaded function showMessageMenu() { RoomManager.viewEventMenu(root.eventId, root.room, root.author, root.selectedText, root.hoveredLink); diff --git a/src/timeline/ReplyButtonComponent.qml b/src/timeline/ReplyButtonComponent.qml index 7dc60664b..149fc4e87 100644 --- a/src/timeline/ReplyButtonComponent.qml +++ b/src/timeline/ReplyButtonComponent.qml @@ -38,6 +38,8 @@ Delegates.RoundedItemDelegate { leftInset: 0 rightInset: 0 + highlighted: true + icon.name: "mail-reply-custom" text: i18nc("@action:button", "Reply")