2019-03-22 14:28:14 +11:00
|
|
|
import QtQuick 2.7
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.4
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
function setFocus() { textArea.forceActiveFocus() }
|
|
|
|
|
|
|
|
id: "root"
|
|
|
|
Layout.fillWidth: true
|
2019-03-26 09:29:46 +11:00
|
|
|
Layout.minimumHeight: 32
|
|
|
|
Layout.preferredHeight: textArea.implicitHeight
|
2019-03-22 14:28:14 +11:00
|
|
|
// parent.height / 2 causes binding loop?
|
|
|
|
Layout.maximumHeight: pageStack.height / 2
|
|
|
|
color: "#BBB"
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Avatar {
|
|
|
|
id: "avatar"
|
2019-03-26 18:19:55 +11:00
|
|
|
username: chatPage.user.display_name
|
2019-03-22 14:28:14 +11:00
|
|
|
dimmension: root.Layout.minimumHeight
|
2019-03-26 18:19:55 +11:00
|
|
|
//visible: textArea.text === ""
|
|
|
|
visible: textArea.height <= root.Layout.minimumHeight
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
id: sendBoxScrollView
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
TextArea {
|
|
|
|
id: textArea
|
|
|
|
placeholderText: qsTr("Type a message...")
|
|
|
|
wrapMode: TextEdit.Wrap
|
|
|
|
selectByMouse: true
|
|
|
|
font.family: "Roboto"
|
|
|
|
font.pixelSize: 16
|
|
|
|
focus: true
|
|
|
|
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
event.accepted = true
|
|
|
|
|
|
|
|
if (event.modifiers & Qt.ShiftModifier ||
|
|
|
|
event.modifiers & Qt.ControlModifier ||
|
|
|
|
event.modifiers & Qt.AltModifier) {
|
|
|
|
textArea.insert(textArea.cursorPosition, "\n")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:19:55 +11:00
|
|
|
Backend.sendMessage(chatPage.user.user_id,
|
2019-03-22 14:28:14 +11:00
|
|
|
chatPage.room.room_id,
|
|
|
|
textArea.text)
|
|
|
|
textArea.clear()
|
|
|
|
}
|
|
|
|
Keys.onEnterPressed: Keys.onReturnPressed(event) // numpad enter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|