2019-07-12 17:06:37 -04:00
|
|
|
import QtQuick 2.12
|
2019-07-13 05:39:01 -04:00
|
|
|
import QtQuick.Layouts 1.12
|
2019-04-28 15:18:36 -04:00
|
|
|
import "../Base"
|
2019-07-03 22:31:29 -04:00
|
|
|
import "../utils.js" as Utils
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
HTileDelegate {
|
2019-04-28 12:40:18 -04:00
|
|
|
id: roomDelegate
|
2019-08-21 04:39:07 -04:00
|
|
|
spacing: sidePane.currentSpacing
|
|
|
|
backgroundColor: theme.sidePane.room.background
|
2019-08-18 03:27:00 -04:00
|
|
|
opacity: model.data.left ? theme.sidePane.room.leftRoomOpacity : 1
|
2019-08-21 06:02:00 -04:00
|
|
|
|
|
|
|
shouldBeCurrent:
|
|
|
|
window.uiState.page == "Chat/Chat.qml" &&
|
|
|
|
window.uiState.pageProperties.userId == model.user_id &&
|
|
|
|
window.uiState.pageProperties.roomId == model.data.room_id
|
2019-08-19 10:28:49 -04:00
|
|
|
|
|
|
|
|
2019-08-16 13:04:54 -04:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
|
2019-08-19 10:28:49 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
readonly property var eventDate:
|
|
|
|
model.data.last_event ? model.data.last_event.date : null
|
2019-08-19 14:28:12 -04:00
|
|
|
|
2019-08-19 10:28:49 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
onActivated: pageLoader.showRoom(model.user_id, model.data.room_id)
|
2019-08-17 16:59:13 -04:00
|
|
|
|
2019-08-19 10:28:49 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
image: HRoomAvatar {
|
|
|
|
displayName: model.data.display_name
|
|
|
|
avatarUrl: model.data.avatar_url
|
|
|
|
}
|
2019-08-19 13:09:05 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
title.color: theme.sidePane.room.name
|
|
|
|
title.text: model.data.display_name || "<i>Empty room</i>"
|
|
|
|
title.textFormat: model.data.display_name? Text.PlainText : Text.StyledText
|
2019-08-19 13:09:05 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
additionalInfo.children: HIcon {
|
|
|
|
svgName: "invite-received"
|
2019-08-19 13:09:05 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
visible: Layout.maximumWidth > 0
|
|
|
|
Layout.maximumWidth:
|
|
|
|
model.data.inviter_id && ! model.data.left ?
|
|
|
|
implicitWidth : 0
|
|
|
|
|
|
|
|
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
2019-08-18 03:27:00 -04:00
|
|
|
}
|
2019-08-17 20:29:56 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
rightInfo.color: theme.sidePane.room.lastEventDate
|
|
|
|
rightInfo.text: {
|
|
|
|
! eventDate ? "" :
|
2019-08-19 10:28:49 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
Utils.dateIsToday(eventDate) ?
|
|
|
|
Utils.formatTime(eventDate, false) : // no seconds
|
2019-08-19 13:09:05 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
eventDate.getFullYear() == new Date().getFullYear() ?
|
|
|
|
Qt.formatDate(eventDate, "d MMM") : // e.g. "5 Dec"
|
2019-08-20 14:29:03 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
eventDate.getFullYear()
|
2019-08-19 18:32:43 -04:00
|
|
|
}
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
subtitle.color: theme.sidePane.room.subtitle
|
|
|
|
subtitle.textFormat: Text.StyledText
|
|
|
|
subtitle.text: {
|
|
|
|
if (! model.data.last_event) { return "" }
|
2019-08-20 13:12:40 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
let ev = model.data.last_event
|
2019-08-11 22:57:36 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
if (ev.event_type === "RoomMessageEmote" ||
|
|
|
|
! ev.event_type.startsWith("RoomMessage")) {
|
|
|
|
return Utils.processedEventText(ev)
|
2019-08-11 22:57:36 -04:00
|
|
|
}
|
2019-05-02 14:20:21 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
return Utils.coloredNameHtml(
|
|
|
|
ev.sender_name, ev.sender_id
|
|
|
|
) + ": " + ev.inline_content
|
2019-03-21 23:28:14 -04:00
|
|
|
}
|
|
|
|
}
|