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

View File

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