Precise time on hover

Implement showing a long datetime as a tooltip when hovering over the timestamp for a message. The timestamp is also moved to just after the username of the poster this means it will not be under the hover buttons unless the message is very short.

Also some cleanup of the alignment of items in the bubble. The reply text is now indented the same amount as the username and message and the padding isn't removed from the username and message when avatars are disabled.

Implements: network/neochat#223
This commit is contained in:
James Graham
2022-07-15 15:39:33 +00:00
committed by Carl Schwan
parent b20b1c10d0
commit 400d86a1e9
2 changed files with 14 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ TextEdit {
Layout.fillWidth: Config.compactLayout Layout.fillWidth: Config.compactLayout
Layout.rightMargin: Kirigami.Units.largeSpacing Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.leftMargin: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing : 0 Layout.leftMargin: Kirigami.Units.largeSpacing
text: "<style> text: "<style>
table { table {

View File

@@ -196,15 +196,13 @@ QQC2.ItemDelegate {
topInset: 0 topInset: 0
visible: model.showAuthor && !isEmote visible: model.showAuthor && !isEmote
anchors.left: rowLayout.left width: Math.min(contentMaxWidth - timeLabel.width, implicitWidth)
anchors.right: timeLabel.left
anchors.rightMargin: Kirigami.Units.smallSpacing
text: visible ? author.displayName : "" text: visible ? author.displayName : ""
textFormat: Text.PlainText textFormat: Text.PlainText
font.weight: Font.Bold font.weight: Font.Bold
color: author.color color: author.color
wrapMode: Text.Wrap elide: Text.ElideRight
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
@@ -221,10 +219,18 @@ QQC2.ItemDelegate {
} }
QQC2.Label { QQC2.Label {
id: timeLabel id: timeLabel
anchors.right: rowLayout.right leftPadding: Kirigami.Units.largeSpacing
rightPadding: Kirigami.Units.largeSpacing
anchors.left: nameLabel.right
visible: model.showAuthor && !isEmote visible: model.showAuthor && !isEmote
text: visible ? time.toLocaleTimeString(Locale.ShortFormat) : "" text: visible ? time.toLocaleTimeString(Qt.locale(), Locale.ShortFormat) : ""
color: Kirigami.Theme.disabledTextColor color: Kirigami.Theme.disabledTextColor
QQC2.ToolTip.visible: hoverHandler.hovered
QQC2.ToolTip.text: time.toLocaleString(Qt.locale(), Locale.LongFormat)
HoverHandler {
id: hoverHandler
}
} }
} }
Loader { Loader {
@@ -234,6 +240,7 @@ QQC2.ItemDelegate {
visible: active visible: active
Layout.topMargin: Kirigami.Units.smallSpacing Layout.topMargin: Kirigami.Units.smallSpacing
Layout.bottomMargin: Config.compactLayout ? 0 : Kirigami.Units.smallSpacing Layout.bottomMargin: Config.compactLayout ? 0 : Kirigami.Units.smallSpacing
Layout.leftMargin: Config.compactLayout ? 0 : Kirigami.Units.largeSpacing
Connections { Connections {
target: replyLoader.item target: replyLoader.item