moment/src/qml/SidePane/DelegateRoom.qml

119 lines
3.4 KiB
QML
Raw Normal View History

2019-07-13 07:06:37 +10:00
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
import "../utils.js" as Utils
2019-03-22 14:28:14 +11:00
HTileDelegate {
id: roomDelegate
spacing: sidePane.currentSpacing
backgroundColor: theme.sidePane.room.background
opacity: model.data.left ? theme.sidePane.room.leftRoomOpacity : 1
shouldBeCurrent:
window.uiState.page == "Chat/Chat.qml" &&
window.uiState.pageProperties.userId == model.user_id &&
window.uiState.pageProperties.roomId == model.data.room_id
setCurrentTimer.running: ! accountRoomList.activateLimiter.running
Behavior on opacity { HNumberAnimation {} }
readonly property bool invited:
model.data.inviter_id && ! model.data.left
readonly property var eventDate:
model.data.last_event ? model.data.last_event.date : null
onActivated: pageLoader.showRoom(model.user_id, model.data.room_id)
image: HRoomAvatar {
displayName: model.data.display_name
avatarUrl: model.data.avatar_url
}
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
additionalInfo.children: HIcon {
svgName: "invite-received"
2019-08-29 08:21:13 +10:00
colorize: theme.colors.alertBackground
visible: Layout.maximumWidth > 0
Layout.maximumWidth: invited ? implicitWidth : 0
Behavior on Layout.maximumWidth { HNumberAnimation {} }
}
rightInfo.color: theme.sidePane.room.lastEventDate
rightInfo.text: {
! eventDate ? "" :
Utils.dateIsToday(eventDate) ?
Utils.formatTime(eventDate, false) : // no seconds
eventDate.getFullYear() == new Date().getFullYear() ?
Qt.formatDate(eventDate, "d MMM") : // e.g. "5 Dec"
eventDate.getFullYear()
}
2019-03-22 14:28:14 +11:00
subtitle.color: theme.sidePane.room.subtitle
subtitle.textFormat: Text.StyledText
subtitle.text: {
if (! model.data.last_event) { return "" }
let ev = model.data.last_event
if (ev.event_type === "RoomMessageEmote" ||
! ev.event_type.startsWith("RoomMessage")) {
return Utils.processedEventText(ev)
}
return Utils.coloredNameHtml(
ev.sender_name, ev.sender_id
) + ": " + ev.inline_content
2019-03-22 14:28:14 +11: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]
)
}
HMenuItem {
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
onTriggered: py.callClientCoro(
model.user_id, "room_leave", [model.data.room_id]
)
}
HMenuItem {
icon.name: "room-forget"
2019-08-29 08:21:13 +10:00
icon.color: theme.colors.negativeBackground
text: qsTr("Forget")
2019-08-22 06:38:34 +10:00
onTriggered: py.callClientCoro(
model.user_id, "room_forget", [model.data.room_id]
)
}
}
2019-03-22 14:28:14 +11:00
}