Refactor TimelineView

Refactor TimelineView to make it more reliable and prepare for read marker choice. This is done by creating signalling from the mode when reset which can be used to move the scrollbar to the newest meassage.

Some of the spaghetti is also removed so there is no need for ChatBar and TimelineView to talk directly.

The code to mark messages as read if they are all visible after 10s has been removed infour of just marking as read on entry if all are visible. This is temporary until a follow up providing user options is finished (although it will be one of the options)
This commit is contained in:
James Graham
2025-06-14 12:16:39 +01:00
parent 235143528c
commit 6a5a2e6144
17 changed files with 368 additions and 318 deletions

View File

@@ -112,15 +112,10 @@ Kirigami.Page {
active: root.currentRoom && !root.currentRoom.isInvite && !root.loading && !root.currentRoom.isSpace
sourceComponent: TimelineView {
id: timelineView
currentRoom: root.currentRoom
page: root
timelineModel: root.timelineModel
room: root.currentRoom
messageFilterModel: root.messageFilterModel
onFocusChatBar: {
if (chatBarLoader.item) {
chatBarLoader.item.forceActiveFocus();
}
}
compactLayout: NeoChatConfig.compactLayout
fileDropEnabled: !Controller.isFlatpak
}
}
@@ -175,11 +170,6 @@ Kirigami.Page {
width: parent.width
currentRoom: root.currentRoom
connection: root.connection
onMessageSent: {
if (!timelineViewLoader.item.atYEnd) {
timelineViewLoader.item.goToLastMessage();
}
}
}
}

View File

@@ -1,122 +0,0 @@
/* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.de>
* SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com>
* SPDX-FileCopyrightText: 2021 Srevin Saju <srevinsaju@sugarlabs.org>
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls as QQC2
import org.kde.kirigami as Kirigami
import org.kde.neochat
Loader {
id: root
property string labelText: ""
active: visible
sourceComponent: QQC2.Pane {
id: typingPane
leftPadding: Kirigami.Units.largeSpacing
rightPadding: Kirigami.Units.largeSpacing
topPadding: Kirigami.Units.smallSpacing
bottomPadding: Kirigami.Units.smallSpacing
spacing: Kirigami.Units.largeSpacing
FontMetrics {
id: fontMetrics
}
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false
contentItem: RowLayout {
spacing: typingPane.spacing
Row {
id: dotRow
property int duration: 400
spacing: Kirigami.Units.smallSpacing
Repeater {
model: 3
delegate: Rectangle {
id: dot
color: Kirigami.Theme.textColor
radius: height / 2
implicitWidth: fontMetrics.xHeight
implicitHeight: fontMetrics.xHeight
// rotating 45 degrees makes the dots look a bit smoother when scaled up
rotation: 45
opacity: 0.5
scale: 1
// FIXME: Sometimes the animation timings for each
// dot drift slightly reletative to each other.
// Not everyone can see this, but I'm pretty sure it's there.
SequentialAnimation {
running: true
PauseAnimation {
duration: dotRow.duration * index / 2
}
SequentialAnimation {
loops: Animation.Infinite
ParallelAnimation {
// Animators unfortunately sync up instead of being
// staggered, so I'm using NumberAnimations instead.
NumberAnimation {
target: dot
property: "scale"
from: 1
to: 1.33
duration: dotRow.duration
}
NumberAnimation {
target: dot
property: "opacity"
from: 0.5
to: 1
duration: dotRow.duration
}
}
ParallelAnimation {
NumberAnimation {
target: dot
property: "scale"
from: 1.33
to: 1
duration: dotRow.duration
}
NumberAnimation {
target: dot
property: "opacity"
from: 1
to: 0.5
duration: dotRow.duration
}
}
PauseAnimation {
duration: dotRow.duration
}
}
}
}
}
}
QQC2.Label {
id: typingLabel
elide: Text.ElideRight
text: root.labelText
textFormat: Text.PlainText
}
}
leftInset: !mirrored ? 0 : -background.radius
rightInset: mirrored ? 0 : -background.radius
bottomInset: -background.radius
background: Rectangle {
radius: Kirigami.Units.cornerRadius
color: Kirigami.Theme.backgroundColor
border.color: Kirigami.ColorUtils.tintWithAlpha(Kirigami.Theme.backgroundColor, Kirigami.Theme.textColor, 0.2)
border.width: 1
}
}
}