Move UserAutoCompletion outside of Composer

This commit is contained in:
miruka 2020-08-21 05:39:46 -04:00
parent 4ea3a7d52a
commit 6dcc244998
3 changed files with 49 additions and 46 deletions

View File

@ -3,6 +3,7 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../Base"
import "AutoCompletion"
import "Banners"
import "Composer"
import "FileTransfer"
@ -91,6 +92,14 @@ HColumnPage {
Behavior on Layout.preferredHeight { HNumberAnimation {} }
}
UserAutoCompletion {
id: userCompletion
textArea: composer.messageArea
Layout.fillWidth: true
Layout.maximumHeight: chatPage.height / 4
}
InviteBanner {
id: inviteBanner
visible: ! chat.roomInfo.left && inviterId
@ -108,9 +117,9 @@ HColumnPage {
Composer {
id: composer
userCompletion: userCompletion
eventList: loadEventList ? eventListLoader.item.eventList : null
visible:
! chat.roomInfo.left && ! chat.roomInfo.inviter_id
visible: ! chat.roomInfo.left && ! chat.roomInfo.inviter_id
Layout.fillWidth: true
Layout.maximumHeight: parent.height / 2

View File

@ -3,69 +3,63 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../../Base"
import "../AutoCompletion"
Rectangle {
property UserAutoCompletion userCompletion
property alias eventList: messageArea.eventList
readonly property bool hasFocus: messageArea.activeFocus
readonly property alias messageArea: messageArea
function takeFocus() { messageArea.forceActiveFocus() }
implicitHeight: Math.max(theme.baseElementsHeight, column.implicitHeight)
implicitHeight: Math.max(theme.baseElementsHeight, row.implicitHeight)
color: theme.chat.composer.background
HColumnLayout {
id: column
HRowLayout {
id: row
anchors.fill: parent
UserAutoCompletion {
id: userCompletion
textArea: messageArea
HUserAvatar {
id: avatar
radius: 0
userId: messageArea.writingUserId
Layout.fillWidth: true
Layout.maximumHeight: chat.height / 3
mxc:
messageArea.writingUserInfo ?
messageArea.writingUserInfo.avatar_url :
""
displayName:
messageArea.writingUserInfo ?
messageArea.writingUserInfo.display_name :
""
}
HRowLayout {
HUserAvatar {
id: avatar
radius: 0
userId: messageArea.writingUserId
HScrollView {
Layout.fillHeight: true
Layout.fillWidth: true
mxc:
messageArea.writingUserInfo ?
messageArea.writingUserInfo.avatar_url :
""
MessageArea {
id: messageArea
autoCompletionOpen: userCompletion.open
usersCompleted: userCompletion.usersCompleted
displayName:
messageArea.writingUserInfo ?
messageArea.writingUserInfo.display_name :
""
onAutoCompletePrevious: userCompletion.previous()
onAutoCompleteNext: userCompletion.next()
onCancelAutoCompletion: userCompletion.cancel()
onAcceptAutoCompletion:
! userCompletion.autoOpen ||
userCompletion.autoOpenCompleted ?
userCompletion.accept() :
null
}
}
HScrollView {
Layout.fillHeight: true
Layout.fillWidth: true
MessageArea {
id: messageArea
autoCompletionOpen: userCompletion.open
usersCompleted: userCompletion.usersCompleted
onAutoCompletePrevious: userCompletion.previous()
onAutoCompleteNext: userCompletion.next()
onCancelAutoCompletion: userCompletion.cancel()
onAcceptAutoCompletion:
! userCompletion.autoOpen ||
userCompletion.autoOpenCompleted ?
userCompletion.accept() :
null
}
}
UploadButton {
Layout.fillHeight: true
}
UploadButton {
Layout.fillHeight: true
}
}
}