2019-07-07 23:52:41 -04:00
|
|
|
// Copyright 2019 miruka
|
|
|
|
// This file is part of harmonyqml, licensed under LGPLv3.
|
|
|
|
|
2019-07-13 05:39:01 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-04-28 15:18:36 -04:00
|
|
|
import "../Base"
|
2019-04-28 14:34:29 -04:00
|
|
|
import "Banners"
|
2019-07-02 22:29:09 -04:00
|
|
|
import "Timeline"
|
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-07-07 02:35:22 -04:00
|
|
|
property var roomInfo: null
|
2019-07-07 22:19:17 -04:00
|
|
|
onRoomInfoChanged: if (! roomInfo) { pageStack.showPage("Default") }
|
2019-03-21 23:28:14 -04:00
|
|
|
|
2019-07-07 02:35:22 -04:00
|
|
|
readonly property string userId: roomInfo.userId
|
|
|
|
readonly property string category: roomInfo.category
|
|
|
|
readonly property string roomId: roomInfo.roomId
|
2019-07-06 23:46:06 -04:00
|
|
|
|
2019-07-07 22:41:32 -04:00
|
|
|
readonly property var senderInfo: users.find(userId)
|
2019-04-14 16:12:07 -04:00
|
|
|
|
2019-07-02 13:59:52 -04:00
|
|
|
readonly property bool hasUnknownDevices: false
|
|
|
|
//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-12 13:17:42 -04:00
|
|
|
RoomHeader {
|
|
|
|
id: roomHeader
|
|
|
|
displayName: roomInfo.displayName
|
2019-07-04 18:37:15 -04:00
|
|
|
topic: roomInfo.topic
|
2019-05-12 13:17:42 -04:00
|
|
|
|
2019-05-02 14:20:21 -04:00
|
|
|
Layout.fillWidth: true
|
2019-07-06 17:50:55 -04:00
|
|
|
Layout.preferredHeight: theme.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-07-02 22:29:09 -04:00
|
|
|
EventList {
|
2019-05-12 13:17:42 -04:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2019-05-08 13:45:25 -04:00
|
|
|
|
2019-07-06 17:29:32 -04:00
|
|
|
TypingMembersBar {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2019-05-11 17:51:00 -04:00
|
|
|
|
2019-07-05 16:48:30 -04:00
|
|
|
InviteBanner {
|
2019-07-06 22:35:42 -04:00
|
|
|
visible: category == "Invites"
|
2019-07-05 16:48:30 -04:00
|
|
|
inviterId: roomInfo.inviterId
|
|
|
|
}
|
2019-05-11 17:51:00 -04:00
|
|
|
|
2019-07-02 22:22:29 -04:00
|
|
|
//UnknownDevicesBanner {
|
|
|
|
//visible: category == "Rooms" && hasUnknownDevices
|
|
|
|
//}
|
2019-05-12 13:17:42 -04:00
|
|
|
|
|
|
|
SendBox {
|
|
|
|
id: sendBox
|
|
|
|
visible: category == "Rooms" && ! hasUnknownDevices
|
|
|
|
}
|
2019-05-11 17:51:00 -04:00
|
|
|
|
2019-07-06 23:43:51 -04:00
|
|
|
LeftBanner {
|
|
|
|
visible: category == "Left"
|
|
|
|
userId: chatPage.userId
|
|
|
|
}
|
2019-07-06 22:35:42 -04:00
|
|
|
}
|
2019-04-21 15:20:20 -04:00
|
|
|
|
2019-07-07 05:15:18 -04:00
|
|
|
RoomSidePane {
|
|
|
|
id: roomSidePane
|
|
|
|
|
|
|
|
activeView: roomHeader.activeButton
|
|
|
|
property int oldWidth: width
|
|
|
|
onActiveViewChanged:
|
|
|
|
activeView ? restoreAnimation.start() : hideAnimation.start()
|
|
|
|
|
|
|
|
HNumberAnimation {
|
|
|
|
id: hideAnimation
|
|
|
|
target: roomSidePane
|
|
|
|
properties: "width"
|
|
|
|
from: target.width
|
|
|
|
to: 0
|
|
|
|
|
|
|
|
onStarted: {
|
|
|
|
target.oldWidth = target.width
|
|
|
|
target.Layout.minimumWidth = 0
|
|
|
|
}
|
|
|
|
}
|
2019-07-02 13:59:52 -04:00
|
|
|
|
2019-07-07 05:15:18 -04:00
|
|
|
HNumberAnimation {
|
|
|
|
id: restoreAnimation
|
|
|
|
target: roomSidePane
|
|
|
|
properties: "width"
|
|
|
|
from: 0
|
|
|
|
to: target.oldWidth
|
|
|
|
|
|
|
|
onStopped: target.Layout.minimumWidth = Qt.binding(
|
|
|
|
function() { return theme.avatar.size }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
collapsed: width < theme.avatar.size + 8
|
|
|
|
|
|
|
|
property bool wasSnapped: false
|
|
|
|
property int referenceWidth: roomHeader.buttonsWidth
|
|
|
|
onReferenceWidthChanged: {
|
|
|
|
if (chatSplitView.canAutoSize || wasSnapped) {
|
|
|
|
if (wasSnapped) { chatSplitView.canAutoSize = true }
|
|
|
|
width = referenceWidth
|
|
|
|
}
|
|
|
|
}
|
2019-07-02 13:59:52 -04:00
|
|
|
|
2019-07-07 05:15:18 -04:00
|
|
|
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-07-02 13:59:52 -04:00
|
|
|
|
2019-07-07 05:15:18 -04:00
|
|
|
width: referenceWidth // Initial width
|
|
|
|
Layout.minimumWidth: theme.avatar.size
|
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
}
|
2019-04-21 10:44:04 -04:00
|
|
|
}
|
2019-03-21 23:28:14 -04:00
|
|
|
}
|