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-30 10:56:38 -04:00
|
|
|
setCurrentTimer.running:
|
2019-08-30 11:05:11 -04:00
|
|
|
! sidePaneList.activateLimiter.running && ! sidePane.hasFocus
|
2019-08-23 10:53:54 -04:00
|
|
|
|
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-11-30 08:14:39 -04:00
|
|
|
readonly property bool invited: model.data.inviter_id && ! model.data.left
|
|
|
|
readonly property var lastEvent: model.data.last_event
|
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
|
2019-11-03 13:48:12 -04:00
|
|
|
mxc: model.data.avatar_url
|
2019-08-21 04:39:07 -04:00
|
|
|
}
|
2019-08-19 13:09:05 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
title.color: theme.sidePane.room.name
|
2019-11-27 10:03:49 -04:00
|
|
|
title.text: model.data.display_name || qsTr("Empty room")
|
2019-08-19 13:09:05 -04:00
|
|
|
|
2019-08-21 04:39:07 -04:00
|
|
|
additionalInfo.children: HIcon {
|
|
|
|
svgName: "invite-received"
|
2019-08-28 18:21:13 -04:00
|
|
|
colorize: theme.colors.alertBackground
|
2019-08-19 13:09:05 -04:00
|
|
|
|
2019-09-06 14:04:18 -04:00
|
|
|
visible: invited
|
2019-08-21 14:58:57 -04:00
|
|
|
Layout.maximumWidth: invited ? implicitWidth : 0
|
2019-08-21 04:39:07 -04:00
|
|
|
|
|
|
|
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: {
|
2019-11-30 08:14:39 -04:00
|
|
|
! lastEvent || ! lastEvent.date ?
|
|
|
|
"" :
|
2019-08-19 10:28:49 -04:00
|
|
|
|
2019-11-30 08:14:39 -04:00
|
|
|
Utils.dateIsToday(lastEvent.date) ?
|
|
|
|
Utils.formatTime(lastEvent.date, false) : // no seconds
|
2019-08-19 13:09:05 -04:00
|
|
|
|
2019-11-30 08:14:39 -04:00
|
|
|
lastEvent.date.getFullYear() == new Date().getFullYear() ?
|
|
|
|
Qt.formatDate(lastEvent.date, "d MMM") : // e.g. "5 Dec"
|
2019-08-20 14:29:03 -04:00
|
|
|
|
2019-11-30 08:14:39 -04:00
|
|
|
lastEvent.date.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
|
2019-11-30 08:14:39 -04:00
|
|
|
subtitle.font.italic:
|
|
|
|
Boolean(lastEvent && lastEvent.event_type === "RoomMessageEmote")
|
2019-08-21 04:39:07 -04:00
|
|
|
subtitle.textFormat: Text.StyledText
|
|
|
|
subtitle.text: {
|
2019-11-30 08:14:39 -04:00
|
|
|
if (! lastEvent) return ""
|
2019-08-11 22:57:36 -04:00
|
|
|
|
2019-11-04 14:37:25 -04:00
|
|
|
// If it's an emote or non-message/media event
|
2019-11-30 08:14:39 -04:00
|
|
|
if (lastEvent.event_type === "RoomMessageEmote" ||
|
|
|
|
(! lastEvent.event_type.startsWith("RoomMessage") &&
|
|
|
|
! lastEvent.event_type.startsWith("RoomEncrypted")))
|
|
|
|
{
|
|
|
|
return Utils.processedEventText(lastEvent)
|
2019-08-11 22:57:36 -04:00
|
|
|
}
|
2019-05-02 14:20:21 -04:00
|
|
|
|
2019-08-30 12:07:50 -04:00
|
|
|
let text = Utils.coloredNameHtml(
|
2019-11-30 08:14:39 -04:00
|
|
|
lastEvent.sender_name, lastEvent.sender_id
|
|
|
|
) + ": " + lastEvent.inline_content
|
2019-08-30 12:07:50 -04:00
|
|
|
|
|
|
|
return text.replace(
|
2019-10-24 09:43:40 -04:00
|
|
|
/< *span +class=['"]?quote['"]? *>(.+?)<\/ *span *>/g,
|
2019-11-18 03:57:13 -04:00
|
|
|
`<font color="${theme.sidePane.room.subtitleQuote}">$1</font>`,
|
2019-08-30 12:07:50 -04:00
|
|
|
)
|
2019-03-21 23:28:14 -04:00
|
|
|
}
|
2019-08-21 14:58:57 -04:00
|
|
|
|
|
|
|
contextMenu: HMenu {
|
2019-08-21 16:38:34 -04:00
|
|
|
HMenuItem {
|
|
|
|
visible: invited
|
|
|
|
icon.name: "invite-accept"
|
2019-08-28 18:21:13 -04:00
|
|
|
icon.color: theme.colors.positiveBackground
|
2019-08-21 16:38:34 -04:00
|
|
|
text: qsTr("Accept %1's invite").arg(Utils.coloredNameHtml(
|
|
|
|
model.data.inviter_name, model.data.inviter_id
|
|
|
|
))
|
|
|
|
label.textFormat: Text.StyledText
|
|
|
|
|
|
|
|
onTriggered: py.callClientCoro(
|
|
|
|
model.user_id, "join", [model.data.room_id]
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-08-21 14:58:57 -04:00
|
|
|
HMenuItem {
|
2019-08-21 16:29:44 -04:00
|
|
|
visible: ! model.data.left
|
2019-08-21 16:23:22 -04:00
|
|
|
icon.name: invited ? "invite-decline" : "room-leave"
|
2019-08-28 18:21:13 -04:00
|
|
|
icon.color: theme.colors.negativeBackground
|
2019-08-21 16:23:22 -04:00
|
|
|
text: invited ? qsTr("Decline invite") : qsTr("Leave")
|
2019-08-21 16:38:34 -04:00
|
|
|
|
2019-09-09 09:12:51 -04:00
|
|
|
onTriggered: Utils.makePopup(
|
|
|
|
"Popups/LeaveRoomPopup.qml",
|
|
|
|
sidePane,
|
|
|
|
{
|
|
|
|
userId: model.user_id,
|
|
|
|
roomId: model.data.room_id,
|
|
|
|
roomName: model.data.display_name,
|
|
|
|
}
|
2019-08-21 14:58:57 -04:00
|
|
|
)
|
|
|
|
}
|
2019-08-21 16:29:44 -04:00
|
|
|
|
|
|
|
HMenuItem {
|
|
|
|
icon.name: "room-forget"
|
2019-08-28 18:21:13 -04:00
|
|
|
icon.color: theme.colors.negativeBackground
|
2019-08-21 16:29:44 -04:00
|
|
|
text: qsTr("Forget")
|
2019-08-21 16:38:34 -04:00
|
|
|
|
2019-09-09 09:24:45 -04:00
|
|
|
onTriggered: Utils.makePopup(
|
|
|
|
"Popups/ForgetRoomPopup.qml",
|
|
|
|
sidePane,
|
|
|
|
{
|
|
|
|
userId: model.user_id,
|
|
|
|
roomId: model.data.room_id,
|
|
|
|
roomName: model.data.display_name,
|
2019-09-09 20:56:10 -04:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
false,
|
2019-08-21 16:29:44 -04:00
|
|
|
)
|
|
|
|
}
|
2019-08-21 14:58:57 -04:00
|
|
|
}
|
2019-03-21 23:28:14 -04:00
|
|
|
}
|