Improve time handling in NeoChat

This introduces a new NeoChatDateTime object that wraps a QDateTime. The intent is that it can be passed to QML and has a series of functions that format the QDateTime into the various string representations we need.

This means we only have to send the single object to QML and then the correct string can be grabbed from there, simplifying the backend. It is also easy to add a new representation if needed as a function with a QString output and Q_PROPERTY can be added and then it will be available.
This commit is contained in:
James Graham
2026-01-25 13:01:31 +00:00
parent 72416884d4
commit 275d221f75
23 changed files with 222 additions and 186 deletions

View File

@@ -28,9 +28,9 @@ QQC2.Control {
required property NeochatRoomMember author
/**
* @brief The timestamp of the message.
* @brief The timestamp of the event as a NeoChatDateTime.
*/
required property var time
required property NeoChatDateTime dateTime
/**
* @brief The display text of the message.
@@ -164,12 +164,12 @@ QQC2.Control {
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
QQC2.Button {
visible: root.time.toString() !== "Invalid Date"
visible: root.dateTime.isValid
icon.name: "view-fullscreen"
text: i18nc("@action:button", "Maximize")
display: QQC2.AbstractButton.IconOnly
onClicked: RoomManager.maximizeCode(root.author, root.time, root.display, root.componentAttributes.class);
onClicked: RoomManager.maximizeCode(root.author, root.dateTime, root.display, root.componentAttributes.class);
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered