diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-10-08 20:14:13 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-10-08 20:14:13 +0200 |
commit | 6c6370c83fab2140a81f431b8909746a0b6833dc (patch) | |
tree | 9c0aeaece5cdb461fdbc0863ea276e259b86137b /resources | |
parent | Reimplement mention highlight and scroll to highlight (diff) | |
download | nheko-6c6370c83fab2140a81f431b8909746a0b6833dc.tar.xz |
Switch to manual polishing of event delegates
Diffstat (limited to 'resources')
-rw-r--r-- | resources/qml/MessageView.qml | 4 | ||||
-rw-r--r-- | resources/qml/TimelineDefaultMessageStyle.qml | 71 | ||||
-rw-r--r-- | resources/qml/delegates/MessageDelegate.qml | 1 | ||||
-rw-r--r-- | resources/qml/delegates/TextMessage.qml | 7 |
4 files changed, 41 insertions, 42 deletions
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index 3cdfda22..3ffe7d9a 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -52,8 +52,8 @@ Item { //onModelChanged: if (room) room.sendReset() //reuseItems: true boundsBehavior: Flickable.StopAtBounds - displayMarginBeginning: height / 2 - displayMarginEnd: height / 2 + displayMarginBeginning: height / 4 + displayMarginEnd: height / 4 model: (filteredTimeline.filterByThread || filteredTimeline.filterByContent) ? filteredTimeline : room //pixelAligned: true spacing: 2 diff --git a/resources/qml/TimelineDefaultMessageStyle.qml b/resources/qml/TimelineDefaultMessageStyle.qml index 1d12daef..0866fab6 100644 --- a/resources/qml/TimelineDefaultMessageStyle.qml +++ b/resources/qml/TimelineDefaultMessageStyle.qml @@ -18,7 +18,7 @@ TimelineEvent { id: wrapper ListView.delayRemove: true width: chat.delegateMaxWidth - height: Math.max((section.item?.height ?? 0) + gridContainer.implicitHeight + reactionRow.implicitHeight + unreadRow.height, 10) + height: Math.max((section.item?.height ?? 0) + gridContainer.implicitHeight + reactionRow.implicitHeight + unreadRow.height, 20) anchors.horizontalCenter: ListView.view.contentItem.horizontalCenter //room: chatRoot.roommodel @@ -51,6 +51,8 @@ TimelineEvent { property alias hovered: messageHover.hovered property bool scrolledToThis: false + maxWidth: chat.delegateMaxWidth - avatarMargin - metadata.width + data: [ Loader { id: section @@ -131,7 +133,7 @@ TimelineEvent { anchors.top: gridContainer.top anchors.left: gridContainer.left anchors.topMargin: -2 - anchors.leftMargin: wrapper.avatarMargin + 2 + anchors.leftMargin: -2 color: "transparent" border.color: Nheko.theme.red border.width: wrapper.notificationlevel == MtxEvent.Highlight ? 1 : 0 @@ -139,11 +141,13 @@ TimelineEvent { height: contentColumn.implicitHeight + 4 width: contentColumn.implicitWidth + 4 }, - RowLayout { + Row { id: gridContainer - width: wrapper.width + width: wrapper.width - wrapper.avatarMargin + x: wrapper.avatarMargin y: section.visible && section.active ? section.y + section.height : 0 + spacing: Nheko.paddingSmall HoverHandler { id: messageHover @@ -154,23 +158,20 @@ TimelineEvent { messageActions.model = wrapper; messageActions.attached = wrapper; messageActions.anchors.bottomMargin = -gridContainer.y + messageActions.anchors.rightMargin = metadata.width } } } } - Item { - Layout.preferredWidth: wrapper.avatarMargin - } - AbstractButton { ToolTip.delay: Nheko.tooltipDelay ToolTip.text: qsTr("Part of a thread") ToolTip.visible: hovered - Layout.fillHeight: true + height: contentColumn.height visible: wrapper.threadId - Layout.preferredWidth: 4 + width: 4 onClicked: wrapper.room.thread = wrapper.threadId @@ -181,17 +182,16 @@ TimelineEvent { color: TimelineManager.userColor(wrapper.threadId, palette.base) } } - ColumnLayout { + Column { id: contentColumn - Layout.fillWidth: true AbstractButton { id: replyRow visible: wrapper.reply - Layout.fillWidth: true - Layout.maximumHeight: timelineView.height / 8 - Layout.preferredWidth: replyRowLay.implicitWidth - Layout.preferredHeight: replyRowLay.implicitHeight + //Layout.fillWidth: true + //Layout.maximumHeight: timelineView.height / 8 + //Layout.preferredWidth: replyRowLay.implicitWidth + //Layout.preferredHeight: replyRowLay.implicitHeight property color userColor: TimelineManager.userColor(wrapper.reply?.userId ?? '', palette.base) @@ -202,32 +202,33 @@ TimelineEvent { cursorShape: Qt.PointingHandCursor } - contentItem: RowLayout { + contentItem: Row { id: replyRowLay - anchors.fill: parent - + spacing: Nheko.paddingSmall Rectangle { id: replyLine - Layout.fillHeight: true + height: replyCol.height color: replyRow.userColor - Layout.preferredWidth: 4 + width: 4 } - ColumnLayout { + Column { spacing: 0 + id: replyCol + AbstractButton { id: replyUserButton - Layout.fillWidth: true - contentItem: ElidedLabel { + + contentItem: Label { id: userName_ - fullText: wrapper.reply?.userName ?? '' + text: wrapper.reply?.userName ?? '' color: replyRow.userColor textFormat: Text.RichText - width: parent.width - elideWidth: width + width: wrapper.maxWidth + //elideWidth: wrapper.maxWidth } onClicked: wrapper.room.openUserProfile(wrapper.reply?.userId) } @@ -239,7 +240,7 @@ TimelineEvent { } background: Rectangle { - width: replyRow.implicitContentWidth + //width: replyRow.implicitContentWidth color: Qt.tint(palette.base, Qt.hsla(replyRow.userColor.hslHue, 0.5, replyRow.userColor.hslLightness, 0.1)) } @@ -259,19 +260,16 @@ TimelineEvent { ] } - Item { - // spacer to fill width if needed - Layout.fillWidth: true - } - + }, RowLayout { id: metadata property int iconSize: Math.floor(fontMetrics.ascent * scaling) property double scaling: Settings.bubbles ? 0.75 : 1 - Layout.alignment: Qt.AlignTop | Qt.AlignRight - Layout.preferredWidth: implicitWidth + anchors.right: parent.right + y: section.visible && section.active ? section.y + section.height : 0 + spacing: 2 visible: !isStateEvent @@ -339,8 +337,7 @@ TimelineEvent { } } - } - }, + }, Reactions { id: reactionRow diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index 44726a63..cd1bdcd4 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -620,7 +620,6 @@ Item { roleValue: MtxEvent.Member ColumnLayout { - width: parent?.width ?? 100 NoticeMessage { body: formatted diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml index 9ef2e6cc..03623924 100644 --- a/resources/qml/delegates/TextMessage.qml +++ b/resources/qml/delegates/TextMessage.qml @@ -4,7 +4,7 @@ import ".." import QtQuick.Controls -import QtQuick.Layouts +//import QtQuick.Layouts import im.nheko MatrixText { @@ -41,7 +41,10 @@ MatrixText { }" : "") + // TODO(Nico): Figure out how to support mobile "</style> " + formatted.replace(/<del>/g, "<s>").replace(/<\/del>/g, "</s>").replace(/<strike>/g, "<s>").replace(/<\/strike>/g, "</s>") - Layout.maximumHeight: !keepFullText ? Math.round(Math.min(timelineView.height / 8, implicitHeight)) : implicitHeight + //Layout.maximumHeight: !keepFullText ? Math.round(Math.min(timelineView.height / 8, implicitHeight)) : implicitHeight + + //EventDelegateChooser.fillWidth: true + clip: !keepFullText selectByMouse: !Settings.mobileMode && !isReply enabled: !Settings.mobileMode && !isReply |