Improve read marker delegate, add button to mark as read

I added an icon to the read marker (to help distinguish it from
text-heavy chat rooms), and fixed up the padding. I also find myself
reaching to right-click rooms often to mark them as read, so why not do
this from the read marker itself?
This commit is contained in:
Joshua Goins
2026-02-12 20:21:46 -05:00
parent 9d2a427619
commit 49646c63f8
2 changed files with 42 additions and 9 deletions

View File

@@ -39,7 +39,9 @@ DelegateChooser {
DelegateChoice { DelegateChoice {
roleValue: DelegateType.ReadMarker roleValue: DelegateType.ReadMarker
delegate: ReadMarkerDelegate {} delegate: ReadMarkerDelegate {
room: root.room
}
} }
DelegateChoice { DelegateChoice {

View File

@@ -13,6 +13,11 @@ import org.kde.neochat
TimelineDelegate { TimelineDelegate {
id: root id: root
/**
* @brief The NeoChatRoom the delegate is being displayed in.
*/
required property NeoChatRoom room
/** /**
* @brief The timestamp of the event as a neoChatDateTime. * @brief The timestamp of the event as a neoChatDateTime.
*/ */
@@ -29,12 +34,16 @@ TimelineDelegate {
alwaysFillWidth: NeoChatConfig.compactLayout alwaysFillWidth: NeoChatConfig.compactLayout
contentItem: QQC2.ItemDelegate { contentItem: QQC2.ItemDelegate {
padding: Kirigami.Units.largeSpacing padding: Kirigami.Units.largeSpacing * 2
topInset: Kirigami.Units.largeSpacing topPadding: padding
topPadding: Kirigami.Units.largeSpacing * 2 bottomPadding: Kirigami.Units.largeSpacing
bottomPadding: Kirigami.Units.largeSpacing * 2 leftPadding: padding
leftPadding: Kirigami.Units.largeSpacing * 2 rightPadding: padding
bottomInset: Kirigami.Units.largeSpacing
topInset: Kirigami.Units.largeSpacing + Kirigami.Units.mediumSpacing
bottomInset: Kirigami.Units.mediumSpacing
rightInset: Kirigami.Units.largeSpacing
leftInset: 0
Timer { Timer {
id: temporaryHighlightTimer id: temporaryHighlightTimer
@@ -43,8 +52,30 @@ TimelineDelegate {
onTriggered: root.isTemporaryHighlighted = false onTriggered: root.isTemporaryHighlighted = false
} }
contentItem: QQC2.Label { contentItem: RowLayout {
text: i18nc("Relative time since the room was last read", "Last read: %1", root.dateTime.relativeDateTime) spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "view-readermode"
Layout.preferredWidth: Kirigami.Units.iconSizes.sizeForLabels
Layout.preferredHeight: Kirigami.Units.iconSizes.sizeForLabels
}
QQC2.Label {
text: i18nc("Relative time since the room was last read", "Last read: %1", root.dateTime.relativeDateTime)
Layout.fillWidth: true
}
QQC2.ToolButton {
text: i18nc("@action:button Mark all messages up to now as read", "Mark as Read")
icon.name: "checkmark"
onClicked: root.room.markAllMessagesAsRead()
Layout.alignment: Qt.AlignRight
}
} }
background: Kirigami.ShadowedRectangle { background: Kirigami.ShadowedRectangle {