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