moment/src/gui/Pages/Chat/Chat.qml

75 lines
1.8 KiB
QML
Raw Normal View History

2019-12-19 22:46:16 +11:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
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()
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
property bool ready: Boolean(userInfo && roomInfo)
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
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-12-09 20:25:31 +11:00
source: ready ? "ChatPage.qml" : ""
2019-12-09 20:25:31 +11:00
HLoader {
anchors.centerIn: parent
width: 96 * theme.uiScale
height: width
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-12-14 00:52:04 +11:00
HLoader {
id: roomPaneLoader
active: ready
2019-12-14 00:52:04 +11:00
sourceComponent: RoomPane {
id: roomPane
referenceSizeParent: chat
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
}