2019-12-19 22:46:16 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-12-03 07:29:29 +11:00
|
|
|
import "../.."
|
2019-12-18 19:53:08 +11:00
|
|
|
import "../../Base"
|
2019-12-11 05:57:54 +11:00
|
|
|
import "RoomPane"
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-12-09 20:25:31 +11:00
|
|
|
Item {
|
|
|
|
id: chat
|
2019-12-10 05:13:38 +11:00
|
|
|
onFocusChanged: if (focus && loader.item) loader.item.composer.takeFocus()
|
2019-12-09 05:43:41 +11:00
|
|
|
|
2019-07-21 22:38:49 +10:00
|
|
|
|
2020-03-08 19:02:26 +11:00
|
|
|
property string userId
|
|
|
|
property string roomId
|
2019-07-17 07:08:06 +10:00
|
|
|
|
2020-03-08 19:02:26 +11:00
|
|
|
property QtObject userInfo: null
|
|
|
|
property QtObject roomInfo: null
|
2019-07-07 13:46:06 +10:00
|
|
|
|
2019-12-03 07:29:29 +11:00
|
|
|
property bool ready: Boolean(userInfo && roomInfo)
|
2019-08-17 04:44:45 +10:00
|
|
|
|
2019-12-10 05:22:39 +11:00
|
|
|
readonly property alias loader: loader
|
2019-12-14 00:52:04 +11:00
|
|
|
readonly property alias roomPane: roomPaneLoader.item
|
2019-12-10 04:52:02 +11:00
|
|
|
|
2019-11-11 00:38:16 +11:00
|
|
|
|
2020-03-08 19:02:26 +11:00
|
|
|
Timer {
|
|
|
|
interval: 100
|
|
|
|
running: ! userInfo
|
|
|
|
repeat: true
|
|
|
|
triggeredOnStart: true
|
|
|
|
onTriggered: userInfo = ModelStore.get("accounts").find(userId)
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
interval: 100
|
|
|
|
running: ! roomInfo
|
|
|
|
repeat: true
|
|
|
|
triggeredOnStart: true
|
|
|
|
onTriggered: roomInfo = ModelStore.get(userId, "rooms").find(roomId)
|
|
|
|
}
|
|
|
|
|
2019-12-09 20:25:31 +11:00
|
|
|
HLoader {
|
2019-12-10 05:13:38 +11:00
|
|
|
id: loader
|
2019-12-14 00:52:04 +11:00
|
|
|
anchors.rightMargin: ready ? roomPane.visibleSize : 0
|
2019-12-09 20:25:31 +11:00
|
|
|
anchors.fill: parent
|
2019-12-14 00:52:04 +11:00
|
|
|
visible:
|
|
|
|
ready ? ! roomPane.hidden || anchors.rightMargin < width : true
|
2019-12-10 05:13:38 +11:00
|
|
|
onLoaded: if (chat.focus) item.composer.takeFocus()
|
2019-05-09 03:45:25 +10:00
|
|
|
|
2019-12-09 20:25:31 +11:00
|
|
|
source: ready ? "ChatPage.qml" : ""
|
2019-11-11 00:38:16 +11:00
|
|
|
|
2019-12-09 20:25:31 +11:00
|
|
|
HLoader {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: 96 * theme.uiScale
|
|
|
|
height: width
|
2019-07-21 22:38:49 +10:00
|
|
|
|
2019-12-18 19:53:08 +11:00
|
|
|
source: opacity > 0 ? "../../Base/HBusyIndicator.qml" : ""
|
2019-12-09 20:25:31 +11:00
|
|
|
opacity: ready ? 0 : 1
|
2019-04-22 00:44:04 +10:00
|
|
|
|
2019-12-16 19:42:41 +11:00
|
|
|
Behavior on opacity { HNumberAnimation { factor: 2 } }
|
2019-12-09 20:25:31 +11:00
|
|
|
}
|
|
|
|
}
|
2019-07-07 19:15:18 +10:00
|
|
|
|
2019-12-14 00:52:04 +11:00
|
|
|
HLoader {
|
|
|
|
id: roomPaneLoader
|
|
|
|
active: ready
|
2019-12-20 10:27:39 +11:00
|
|
|
|
2019-12-14 00:52:04 +11:00
|
|
|
sourceComponent: RoomPane {
|
|
|
|
id: roomPane
|
|
|
|
referenceSizeParent: chat
|
2019-12-20 22:38:42 +11:00
|
|
|
maximumSize: chat.width - theme.minimumSupportedWidth * 1.5
|
2019-12-14 00:52:04 +11:00
|
|
|
}
|
2019-04-22 00:44:04 +10:00
|
|
|
}
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|