2019-03-21 23:28:14 -04:00
|
|
|
import QtQuick 2.7
|
2019-05-02 14:20:21 -04:00
|
|
|
import QtQuick.Layouts 1.3
|
2019-04-28 15:18:36 -04:00
|
|
|
import "../Base"
|
2019-04-28 14:34:29 -04:00
|
|
|
import "Banners"
|
|
|
|
import "RoomEventList"
|
2019-05-12 13:17:42 -04:00
|
|
|
import "RoomSidePane"
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2019-05-12 13:17:42 -04:00
|
|
|
HColumnLayout {
|
2019-04-21 10:44:04 -04:00
|
|
|
property string userId: ""
|
2019-05-02 14:20:21 -04:00
|
|
|
property string category: ""
|
2019-04-21 10:44:04 -04:00
|
|
|
property string roomId: ""
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2019-04-21 10:44:04 -04:00
|
|
|
readonly property var roomInfo:
|
2019-05-02 14:31:47 -04:00
|
|
|
Backend.accounts.get(userId)
|
|
|
|
.roomCategories.get(category)
|
|
|
|
.rooms.get(roomId)
|
2019-04-14 16:12:07 -04:00
|
|
|
|
2019-05-11 15:52:56 -04:00
|
|
|
readonly property var sender: Backend.users.get(userId)
|
|
|
|
|
2019-05-08 13:45:25 -04:00
|
|
|
readonly property bool hasUnknownDevices:
|
2019-05-11 15:52:56 -04:00
|
|
|
category == "Rooms" ?
|
|
|
|
Backend.clients.get(userId).roomHasUnknownDevices(roomId) : false
|
2019-05-08 13:45:25 -04:00
|
|
|
|
2019-04-20 17:45:51 -04:00
|
|
|
id: chatPage
|
2019-03-21 23:28:14 -04:00
|
|
|
onFocusChanged: sendBox.setFocus()
|
|
|
|
|
2019-05-06 14:06:28 -04:00
|
|
|
Component.onCompleted: Backend.signals.roomCategoryChanged.connect(
|
|
|
|
function(forUserId, forRoomId, previous, now) {
|
|
|
|
if (chatPage && forUserId == userId && forRoomId == roomId) {
|
|
|
|
chatPage.category = now
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2019-05-12 13:17:42 -04:00
|
|
|
RoomHeader {
|
|
|
|
id: roomHeader
|
|
|
|
displayName: roomInfo.displayName
|
|
|
|
topic: roomInfo.topic || ""
|
|
|
|
|
2019-05-02 14:20:21 -04:00
|
|
|
Layout.fillWidth: true
|
2019-05-12 15:57:18 -04:00
|
|
|
Layout.preferredHeight: HStyle.avatar.size
|
2019-05-12 13:17:42 -04:00
|
|
|
}
|
2019-04-21 10:44:04 -04:00
|
|
|
|
|
|
|
|
2019-05-12 13:17:42 -04:00
|
|
|
HSplitView {
|
2019-05-12 16:01:18 -04:00
|
|
|
id: chatSplitView
|
2019-05-12 13:17:42 -04:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
HColumnLayout {
|
2019-05-11 17:51:00 -04:00
|
|
|
Layout.fillWidth: true
|
2019-04-21 10:44:04 -04:00
|
|
|
|
2019-05-12 13:17:42 -04:00
|
|
|
RoomEventList {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2019-05-08 13:45:25 -04:00
|
|
|
|
2019-05-12 13:17:42 -04:00
|
|
|
TypingMembersBar {}
|
2019-05-11 17:51:00 -04:00
|
|
|
|
2019-05-12 13:17:42 -04:00
|
|
|
InviteBanner {
|
|
|
|
visible: category === "Invites"
|
|
|
|
inviter: roomInfo.inviter
|
|
|
|
}
|
2019-05-11 17:51:00 -04:00
|
|
|
|
2019-05-12 13:17:42 -04:00
|
|
|
UnknownDevicesBanner {
|
|
|
|
visible: category == "Rooms" && hasUnknownDevices
|
|
|
|
}
|
|
|
|
|
|
|
|
SendBox {
|
|
|
|
id: sendBox
|
|
|
|
visible: category == "Rooms" && ! hasUnknownDevices
|
|
|
|
}
|
2019-05-11 17:51:00 -04:00
|
|
|
|
2019-05-12 13:17:42 -04:00
|
|
|
LeftBanner {
|
|
|
|
visible: category === "Left"
|
|
|
|
leftEvent: roomInfo.leftEvent
|
|
|
|
}
|
2019-05-11 17:51:00 -04:00
|
|
|
}
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2019-05-12 13:17:42 -04:00
|
|
|
RoomSidePane {
|
|
|
|
id: roomSidePane
|
2019-05-11 17:51:00 -04:00
|
|
|
|
2019-05-13 12:01:57 -04:00
|
|
|
activeView: roomHeader.activeButton
|
2019-05-15 02:25:40 -04:00
|
|
|
property int oldWidth: width
|
|
|
|
onActiveViewChanged:
|
|
|
|
activeView ? restoreAnimation.start() : hideAnimation.start()
|
|
|
|
|
|
|
|
NumberAnimation {
|
|
|
|
id: hideAnimation
|
|
|
|
target: roomSidePane
|
|
|
|
properties: "width"
|
|
|
|
duration: HStyle.animationDuration
|
|
|
|
from: target.width
|
|
|
|
to: 0
|
2019-05-17 14:24:03 -04:00
|
|
|
|
2019-05-15 02:25:40 -04:00
|
|
|
onStarted: {
|
|
|
|
target.oldWidth = target.width
|
|
|
|
target.Layout.minimumWidth = 0
|
2019-05-13 12:01:57 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-15 02:25:40 -04:00
|
|
|
NumberAnimation {
|
|
|
|
id: restoreAnimation
|
|
|
|
target: roomSidePane
|
|
|
|
properties: "width"
|
|
|
|
duration: HStyle.animationDuration
|
|
|
|
from: 0
|
|
|
|
to: target.oldWidth
|
2019-05-17 14:24:03 -04:00
|
|
|
|
2019-05-15 02:25:40 -04:00
|
|
|
onStopped: target.Layout.minimumWidth = Qt.binding(
|
|
|
|
function() { return HStyle.avatar.size }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-05-12 18:59:29 -04:00
|
|
|
collapsed: width < Layout.minimumWidth + 8
|
2019-05-12 16:01:18 -04:00
|
|
|
|
2019-05-13 12:37:35 -04:00
|
|
|
property bool wasSnapped: false
|
2019-05-13 10:52:26 -04:00
|
|
|
property int referenceWidth: roomHeader.buttonsWidth
|
2019-05-13 12:37:35 -04:00
|
|
|
onReferenceWidthChanged: {
|
|
|
|
if (chatSplitView.canAutoSize || wasSnapped) {
|
|
|
|
if (wasSnapped) { chatSplitView.canAutoSize = true }
|
|
|
|
width = referenceWidth
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property int currentWidth: width
|
|
|
|
onCurrentWidthChanged: {
|
|
|
|
if (referenceWidth != width &&
|
|
|
|
referenceWidth - 15 < width &&
|
|
|
|
width < referenceWidth + 15)
|
|
|
|
{
|
|
|
|
currentWidth = referenceWidth
|
|
|
|
width = referenceWidth
|
|
|
|
wasSnapped = true
|
|
|
|
currentWidth = Qt.binding(
|
|
|
|
function() { return roomSidePane.width }
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
wasSnapped = false
|
|
|
|
}
|
|
|
|
}
|
2019-05-12 13:17:42 -04:00
|
|
|
|
2019-05-13 10:52:26 -04:00
|
|
|
width: referenceWidth // Initial width
|
2019-05-12 15:57:18 -04:00
|
|
|
Layout.minimumWidth: HStyle.avatar.size
|
2019-05-12 13:17:42 -04:00
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
}
|
2019-04-21 10:44:04 -04:00
|
|
|
}
|
2019-03-21 23:28:14 -04:00
|
|
|
}
|