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-08-21 18:39:07 +10:00
|
|
|
spacing: sidePane.currentSpacing
|
|
|
|
backgroundColor: theme.sidePane.room.background
|
2019-08-18 17:27:00 +10:00
|
|
|
opacity: model.data.left ? theme.sidePane.room.leftRoomOpacity : 1
|
2019-08-21 20:02:00 +10: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-20 00:28:49 +10:00
|
|
|
|
2019-08-31 00:56:38 +10:00
|
|
|
setCurrentTimer.running:
|
2019-08-31 01:05:11 +10:00
|
|
|
! sidePaneList.activateLimiter.running && ! sidePane.hasFocus
|
2019-08-24 00:53:54 +10:00
|
|
|
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-08-17 03:04:54 +10:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-08-22 04:58:57 +10:00
|
|
|
readonly property bool invited:
|
|
|
|
model.data.inviter_id && ! model.data.left
|
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
readonly property var eventDate:
|
|
|
|
model.data.last_event ? model.data.last_event.date : null
|
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
|
|
|
|
avatarUrl: model.data.avatar_url
|
|
|
|
}
|
2019-08-20 03:09:05 +10:00
|
|
|
|
2019-08-21 18:39:07 +10: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-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-08-21 18:39:07 +10:00
|
|
|
rightInfo.color: theme.sidePane.room.lastEventDate
|
|
|
|
rightInfo.text: {
|
|
|
|
! eventDate ? "" :
|
2019-08-20 00:28:49 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
Utils.dateIsToday(eventDate) ?
|
|
|
|
Utils.formatTime(eventDate, false) : // no seconds
|
2019-08-20 03:09:05 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
eventDate.getFullYear() == new Date().getFullYear() ?
|
|
|
|
Qt.formatDate(eventDate, "d MMM") : // e.g. "5 Dec"
|
2019-08-21 04:29:03 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
eventDate.getFullYear()
|
2019-08-20 08:32:43 +10:00
|
|
|
}
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
subtitle.color: theme.sidePane.room.subtitle
|
|
|
|
subtitle.textFormat: Text.StyledText
|
|
|
|
subtitle.text: {
|
|
|
|
if (! model.data.last_event) { return "" }
|
2019-08-21 03:12:40 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
let ev = model.data.last_event
|
2019-08-12 12:57:36 +10:00
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
if (ev.event_type === "RoomMessageEmote" ||
|
|
|
|
! ev.event_type.startsWith("RoomMessage")) {
|
|
|
|
return Utils.processedEventText(ev)
|
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-08-21 18:39:07 +10:00
|
|
|
ev.sender_name, ev.sender_id
|
|
|
|
) + ": " + ev.inline_content
|
2019-08-31 02:07:50 +10:00
|
|
|
|
|
|
|
return text.replace(
|
2019-08-31 02:10:45 +10:00
|
|
|
/< *span +class=['"]?quote['"]? *>(.+)<\/ *span *>/,
|
2019-09-07 04:12:32 +10:00
|
|
|
'<font color="' +
|
|
|
|
theme.sidePane.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-08-22 04:58:57 +10:00
|
|
|
onTriggered: py.callClientCoro(
|
|
|
|
model.user_id, "room_leave", [model.data.room_id]
|
|
|
|
)
|
|
|
|
}
|
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-08-22 06:29:44 +10:00
|
|
|
onTriggered: py.callClientCoro(
|
|
|
|
model.user_id, "room_forget", [model.data.room_id]
|
|
|
|
)
|
|
|
|
}
|
2019-08-22 04:58:57 +10:00
|
|
|
}
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|