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-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-12-08 14:43:41 -04:00
|
|
|
spacing: theme.spacing
|
2019-12-10 15:17:41 -04:00
|
|
|
backgroundColor: theme.mainPane.room.background
|
|
|
|
opacity: model.data.left ? theme.mainPane.room.leftRoomOpacity : 1
|
2019-08-21 06:02:00 -04:00
|
|
|
|
|
|
|
shouldBeCurrent:
|
2019-12-09 11:35:50 -04:00
|
|
|
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-12-10 15:17:41 -04:00
|
|
|
! mainPaneList.activateLimiter.running && ! mainPane.hasFocus
|
2019-08-23 10:53:54 -04:00
|
|
|
|
2019-08-19 10:28:49 -04:00
|
|
|
|
2019-12-16 04:42:41 -04:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-08-16 13:04:54 -04:00
|
|
|
|
2019-08-19 10:28:49 -04:00
|
|
|
|
2019-12-13 17:04:56 -04:00
|
|
|
readonly property bool joined: ! invited && ! parted
|
|
|
|
readonly property bool invited: model.data.inviter_id && ! parted
|
|
|
|
readonly property bool parted: model.data.left
|
2019-11-30 08:14:39 -04:00
|
|
|
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-12-10 15:17:41 -04:00
|
|
|
title.color: theme.mainPane.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-12-10 15:17:41 -04:00
|
|
|
rightInfo.color: theme.mainPane.room.lastEventDate
|
2019-08-21 04:39:07 -04:00
|
|
|
rightInfo.text: {
|
2019-11-30 08:14:39 -04:00
|
|
|
! lastEvent || ! lastEvent.date ?
|
|
|
|
"" :
|
2019-08-19 10:28:49 -04:00
|
|
|
|
2019-12-17 17:59:53 -04:00
|
|
|
utils.dateIsToday(lastEvent.date) ?
|
|
|
|
utils.formatTime(lastEvent.date, false) : // no seconds
|
2019-08-19 13:09:05 -04:00
|
|
|
|
2019-12-09 11:35:50 -04:00
|
|
|
lastEvent.date.getFullYear() === new Date().getFullYear() ?
|
2019-11-30 08:14:39 -04:00
|
|
|
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-12-10 15:17:41 -04:00
|
|
|
subtitle.color: theme.mainPane.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-12-04 18:27:56 -04:00
|
|
|
let isEmote = lastEvent.event_type === "RoomMessageEmote"
|
|
|
|
let isMsg = lastEvent.event_type.startsWith("RoomMessage")
|
|
|
|
let isUnknownMsg = lastEvent.event_type === "RoomMessageUnknown"
|
|
|
|
let isCryptMedia = lastEvent.event_type.startsWith("RoomEncrypted")
|
|
|
|
|
|
|
|
// If it's a general event
|
|
|
|
if (isEmote || isUnknownMsg || (! isMsg && ! isCryptMedia)) {
|
2019-12-17 17:59:53 -04:00
|
|
|
return utils.processedEventText(lastEvent)
|
2019-08-11 22:57:36 -04:00
|
|
|
}
|
2019-05-02 14:20:21 -04:00
|
|
|
|
2019-12-17 17:59:53 -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-12-10 15:17:41 -04:00
|
|
|
`<font color="${theme.mainPane.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-12-13 17:04:56 -04:00
|
|
|
HMenuItem {
|
|
|
|
visible: joined
|
|
|
|
enabled: model.data.can_invite
|
|
|
|
icon.name: "room-send-invite"
|
|
|
|
text: qsTr("Invite members")
|
|
|
|
|
2019-12-17 17:59:53 -04:00
|
|
|
onTriggered: utils.makePopup(
|
2019-12-13 17:04:56 -04:00
|
|
|
"Popups/InviteToRoomPopup.qml",
|
|
|
|
window,
|
|
|
|
{
|
|
|
|
userId: model.user_id,
|
|
|
|
roomId: model.data.room_id,
|
2019-12-13 17:08:59 -04:00
|
|
|
roomName: model.data.display_name,
|
2019-12-13 17:04:56 -04:00
|
|
|
invitingAllowed: Qt.binding(() => model.data.can_invite)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-12-12 08:32:50 -04:00
|
|
|
HMenuItem {
|
|
|
|
icon.name: "copy-room-id"
|
|
|
|
text: qsTr("Copy room ID")
|
|
|
|
onTriggered: Clipboard.text = model.data.room_id
|
|
|
|
}
|
|
|
|
|
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-12-17 17:59:53 -04:00
|
|
|
text: qsTr("Accept %1's invite").arg(utils.coloredNameHtml(
|
2019-08-21 16:38:34 -04:00
|
|
|
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-12-13 17:04:56 -04:00
|
|
|
visible: invited || joined
|
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-12-17 17:59:53 -04:00
|
|
|
onTriggered: utils.makePopup(
|
2019-09-09 09:12:51 -04:00
|
|
|
"Popups/LeaveRoomPopup.qml",
|
2019-12-08 14:43:41 -04:00
|
|
|
window,
|
2019-09-09 09:12:51 -04:00
|
|
|
{
|
|
|
|
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-12-17 17:59:53 -04:00
|
|
|
onTriggered: utils.makePopup(
|
2019-09-09 09:24:45 -04:00
|
|
|
"Popups/ForgetRoomPopup.qml",
|
2019-12-08 14:43:41 -04:00
|
|
|
window,
|
2019-09-09 09:24:45 -04:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|