2019-07-13 07:06:37 +10:00
|
|
|
import QtQuick 2.12
|
2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick.Layouts 1.12
|
2019-04-29 05:18:36 +10:00
|
|
|
import "../Base"
|
2019-07-04 12:31:29 +10:00
|
|
|
import "../utils.js" as Utils
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
HTileDelegate {
|
2019-04-29 02:40:18 +10:00
|
|
|
id: roomDelegate
|
2019-12-09 05:43:41 +11:00
|
|
|
spacing: theme.spacing
|
2019-12-11 06:17:41 +11:00
|
|
|
backgroundColor: theme.mainPane.room.background
|
|
|
|
opacity: model.data.left ? theme.mainPane.room.leftRoomOpacity : 1
|
2019-08-21 20:02:00 +10:00
|
|
|
|
|
|
|
shouldBeCurrent:
|
2019-12-10 02:35:50 +11:00
|
|
|
window.uiState.page === "Chat/Chat.qml" &&
|
|
|
|
window.uiState.pageProperties.userId === model.user_id &&
|
|
|
|
window.uiState.pageProperties.roomId === model.data.room_id
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-08-31 00:56:38 +10:00
|
|
|
setCurrentTimer.running:
|
2019-12-11 06:17:41 +11:00
|
|
|
! mainPaneList.activateLimiter.running && ! mainPane.hasFocus
|
2019-08-24 00:53:54 +10:00
|
|
|
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-12-01 02:29:59 +11:00
|
|
|
Behavior on opacity { HOpacityAnimator {} }
|
2019-08-17 03:04:54 +10:00
|
|
|
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-11-30 23:14:39 +11:00
|
|
|
readonly property bool invited: model.data.inviter_id && ! model.data.left
|
|
|
|
readonly property var lastEvent: model.data.last_event
|
2019-08-20 04:28:12 +10:00
|
|
|
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
onActivated: pageLoader.showRoom(model.user_id, model.data.room_id)
|
2019-08-18 06:59:13 +10:00
|
|
|
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
image: HRoomAvatar {
|
|
|
|
displayName: model.data.display_name
|
2019-11-04 04:48:12 +11:00
|
|
|
mxc: model.data.avatar_url
|
2019-08-21 18:39:07 +10:00
|
|
|
}
|
2019-08-20 03:09:05 +10:00
|
|
|
|
2019-12-11 06:17:41 +11:00
|
|
|
title.color: theme.mainPane.room.name
|
2019-11-28 01:03:49 +11:00
|
|
|
title.text: model.data.display_name || qsTr("Empty room")
|
2019-08-20 03:09:05 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
additionalInfo.children: HIcon {
|
|
|
|
svgName: "invite-received"
|
2019-08-29 08:21:13 +10:00
|
|
|
colorize: theme.colors.alertBackground
|
2019-08-20 03:09:05 +10:00
|
|
|
|
2019-09-07 04:04:18 +10:00
|
|
|
visible: invited
|
2019-08-22 04:58:57 +10:00
|
|
|
Layout.maximumWidth: invited ? implicitWidth : 0
|
2019-08-21 18:39:07 +10:00
|
|
|
|
|
|
|
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
2019-08-18 17:27:00 +10:00
|
|
|
}
|
2019-08-18 10:29:56 +10:00
|
|
|
|
2019-12-11 06:17:41 +11:00
|
|
|
rightInfo.color: theme.mainPane.room.lastEventDate
|
2019-08-21 18:39:07 +10:00
|
|
|
rightInfo.text: {
|
2019-11-30 23:14:39 +11:00
|
|
|
! lastEvent || ! lastEvent.date ?
|
|
|
|
"" :
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-11-30 23:14:39 +11:00
|
|
|
Utils.dateIsToday(lastEvent.date) ?
|
|
|
|
Utils.formatTime(lastEvent.date, false) : // no seconds
|
2019-08-20 03:09:05 +10:00
|
|
|
|
2019-12-10 02:35:50 +11:00
|
|
|
lastEvent.date.getFullYear() === new Date().getFullYear() ?
|
2019-11-30 23:14:39 +11:00
|
|
|
Qt.formatDate(lastEvent.date, "d MMM") : // e.g. "5 Dec"
|
2019-08-21 04:29:03 +10:00
|
|
|
|
2019-11-30 23:14:39 +11:00
|
|
|
lastEvent.date.getFullYear()
|
2019-08-20 08:32:43 +10:00
|
|
|
}
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-12-11 06:17:41 +11:00
|
|
|
subtitle.color: theme.mainPane.room.subtitle
|
2019-11-30 23:14:39 +11:00
|
|
|
subtitle.font.italic:
|
|
|
|
Boolean(lastEvent && lastEvent.event_type === "RoomMessageEmote")
|
2019-08-21 18:39:07 +10:00
|
|
|
subtitle.textFormat: Text.StyledText
|
|
|
|
subtitle.text: {
|
2019-11-30 23:14:39 +11:00
|
|
|
if (! lastEvent) return ""
|
2019-08-12 12:57:36 +10:00
|
|
|
|
2019-12-05 09:27:56 +11: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-11-30 23:14:39 +11:00
|
|
|
return Utils.processedEventText(lastEvent)
|
2019-08-12 12:57:36 +10:00
|
|
|
}
|
2019-05-03 04:20:21 +10:00
|
|
|
|
2019-08-31 02:07:50 +10:00
|
|
|
let text = Utils.coloredNameHtml(
|
2019-11-30 23:14:39 +11:00
|
|
|
lastEvent.sender_name, lastEvent.sender_id
|
|
|
|
) + ": " + lastEvent.inline_content
|
2019-08-31 02:07:50 +10:00
|
|
|
|
|
|
|
return text.replace(
|
2019-10-25 00:43:40 +11:00
|
|
|
/< *span +class=['"]?quote['"]? *>(.+?)<\/ *span *>/g,
|
2019-12-11 06:17:41 +11:00
|
|
|
`<font color="${theme.mainPane.room.subtitleQuote}">$1</font>`,
|
2019-08-31 02:07:50 +10:00
|
|
|
)
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|
2019-08-22 04:58:57 +10:00
|
|
|
|
|
|
|
contextMenu: HMenu {
|
2019-08-22 06:38:34 +10:00
|
|
|
HMenuItem {
|
|
|
|
visible: invited
|
|
|
|
icon.name: "invite-accept"
|
2019-08-29 08:21:13 +10:00
|
|
|
icon.color: theme.colors.positiveBackground
|
2019-08-22 06:38:34 +10: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-22 04:58:57 +10:00
|
|
|
HMenuItem {
|
2019-08-22 06:29:44 +10:00
|
|
|
visible: ! model.data.left
|
2019-08-22 06:23:22 +10:00
|
|
|
icon.name: invited ? "invite-decline" : "room-leave"
|
2019-08-29 08:21:13 +10:00
|
|
|
icon.color: theme.colors.negativeBackground
|
2019-08-22 06:23:22 +10:00
|
|
|
text: invited ? qsTr("Decline invite") : qsTr("Leave")
|
2019-08-22 06:38:34 +10:00
|
|
|
|
2019-09-09 23:12:51 +10:00
|
|
|
onTriggered: Utils.makePopup(
|
|
|
|
"Popups/LeaveRoomPopup.qml",
|
2019-12-09 05:43:41 +11:00
|
|
|
window,
|
2019-09-09 23:12:51 +10:00
|
|
|
{
|
|
|
|
userId: model.user_id,
|
|
|
|
roomId: model.data.room_id,
|
|
|
|
roomName: model.data.display_name,
|
|
|
|
}
|
2019-08-22 04:58:57 +10:00
|
|
|
)
|
|
|
|
}
|
2019-08-22 06:29:44 +10:00
|
|
|
|
|
|
|
HMenuItem {
|
|
|
|
icon.name: "room-forget"
|
2019-08-29 08:21:13 +10:00
|
|
|
icon.color: theme.colors.negativeBackground
|
2019-08-22 06:29:44 +10:00
|
|
|
text: qsTr("Forget")
|
2019-08-22 06:38:34 +10:00
|
|
|
|
2019-09-09 23:24:45 +10:00
|
|
|
onTriggered: Utils.makePopup(
|
|
|
|
"Popups/ForgetRoomPopup.qml",
|
2019-12-09 05:43:41 +11:00
|
|
|
window,
|
2019-09-09 23:24:45 +10:00
|
|
|
{
|
|
|
|
userId: model.user_id,
|
|
|
|
roomId: model.data.room_id,
|
|
|
|
roomName: model.data.display_name,
|
2019-09-10 10:56:10 +10:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
false,
|
2019-08-22 06:29:44 +10:00
|
|
|
)
|
|
|
|
}
|
2019-08-22 04:58:57 +10:00
|
|
|
}
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|