From 5381c979996b7fff80fc846aa02d8a7e60f3e3eb Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Sun, 10 Sep 2023 21:25:54 +0300 Subject: [PATCH] Timeline: Stretch date section sections across the whole ListView width With paddings, it looked sort of glitched, especially in RTL layouts, because messages from the top were highlighting all around the padded section delegate. --- src/qml/Component/Timeline/SectionDelegate.qml | 2 ++ src/qml/Component/Timeline/TimelineContainer.qml | 2 ++ src/qml/Component/TimelineView.qml | 8 +++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qml/Component/Timeline/SectionDelegate.qml b/src/qml/Component/Timeline/SectionDelegate.qml index 98497b353..d2b0ffebb 100644 --- a/src/qml/Component/Timeline/SectionDelegate.qml +++ b/src/qml/Component/Timeline/SectionDelegate.qml @@ -19,6 +19,8 @@ QQC2.ItemDelegate { property int colorSet: Kirigami.Theme.Window topPadding: Kirigami.Units.largeSpacing + leftPadding: 0 + rightPadding: 0 bottomPadding: 0 // Note not 0 by default contentItem: ColumnLayout { diff --git a/src/qml/Component/Timeline/TimelineContainer.qml b/src/qml/Component/Timeline/TimelineContainer.qml index 5f5eb12e2..3c7710f0c 100644 --- a/src/qml/Component/Timeline/TimelineContainer.qml +++ b/src/qml/Component/Timeline/TimelineContainer.qml @@ -342,6 +342,8 @@ ColumnLayout { SectionDelegate { id: sectionDelegate Layout.fillWidth: true + // Fill ListView width without affecting size helper and the rest of components too much + Layout.rightMargin: root.parent ? root.width - root.parent.width : 0 visible: root.showSection labelText: root.section colorSet: Config.compactLayout || root.alwaysMaxWidth ? Kirigami.Theme.View : Kirigami.Theme.Window diff --git a/src/qml/Component/TimelineView.qml b/src/qml/Component/TimelineView.qml index 7b7ae044c..0c25a5d58 100644 --- a/src/qml/Component/TimelineView.qml +++ b/src/qml/Component/TimelineView.qml @@ -36,7 +36,7 @@ QQC2.ScrollView { readonly property NeoChatRoom currentRoom: root.currentRoom readonly property int largestVisibleIndex: count > 0 ? indexAt(contentX + (width / 2), contentY + height - 1) : -1 - readonly property var sectionBannerItem: contentHeight >= height ? itemAtIndex(sectionBannerIndex()) : undefined + readonly property Item sectionBannerItem: contentHeight >= height ? itemAtIndex(sectionBannerIndex()) : null // Spacing needs to be zero or the top sectionLabel overlay will be disrupted. // This is because itemAt returns null in the spaces. @@ -108,13 +108,11 @@ QQC2.ScrollView { footer: SectionDelegate { id: sectionBanner - anchors.left: parent.left - anchors.leftMargin: messageListView.sectionBannerItem ? messageListView.sectionBannerItem.x : 0 - anchors.right: parent.right + width: ListView.view ? ListView.view.width : 0 maxWidth: Config.compactLayout ? messageListView.width : (messageListView.sectionBannerItem ? messageListView.sectionBannerItem.width - Kirigami.Units.largeSpacing * 2 : 0) z: 3 - visible: !!messageListView.sectionBannerItem && messageListView.sectionBannerItem.ListView.section !== "" && !Config.blur + visible: messageListView.sectionBannerItem && messageListView.sectionBannerItem.ListView.section !== "" && !Config.blur labelText: messageListView.sectionBannerItem ? messageListView.sectionBannerItem.ListView.section : "" colorSet: Config.compactLayout ? Kirigami.Theme.View : Kirigami.Theme.Window }