Set max width for text area

This commit is contained in:
Angela Mazzurco 2017-06-09 19:00:15 +02:00
parent 2809a9638a
commit ee0b347200
2 changed files with 37 additions and 7 deletions

View File

@ -63,15 +63,20 @@ Item
ListView ListView
{ {
property var styles: StyleChat.chat
id: chatListView id: chatListView
width: parent.width - 20 width: parent.width - styles.bubbleMargin
height: parent.height - inferiorPanel.height
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
height: 300
model: chatModel.model model: chatModel.model
delegate: ChatBubbleDelegate {} delegate: ChatBubbleDelegate {}
spacing: 10 spacing: styles.bubbleSpacing
preferredHighlightBegin: 1 preferredHighlightBegin: 1
onHeightChanged: {
chatListView.currentIndex = count - 1
}
} }
Item { Item {
@ -118,12 +123,18 @@ Item
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: attachButton.right anchors.left: attachButton.right
height: (contentHeight > font.pixelSize)? contentHeight +font.pixelSize : parent.styles.height height: setTextAreaHeight()
////
//// (contentHeight > font.pixelSize)? contentHeight +font.pixelSize : parent.styles.height
width: chatView.width - width: chatView.width -
(sendButton.width + sendButton.anchors.margins) - (sendButton.width + sendButton.anchors.margins) -
(attachButton.width + attachButton.anchors.margins) - (attachButton.width + attachButton.anchors.margins) -
(emojiButton.width + emojiButton.anchors.margins) (emojiButton.width + emojiButton.anchors.margins)
placeholderText: styles.placeHolder placeholderText: styles.placeHolder
background: styles.background background: styles.background
@ -140,6 +151,21 @@ Item
} }
} }
function setTextAreaHeight (){
if (msgComposer.height >= chatView.height / msgComposer.styles.maxHeight)
{
return msgComposer.height
}
else if (contentHeight > font.pixelSize)
{
return msgComposer.contentHeight + msgComposer.font.pixelSize
}
else
{
return parent.styles.height
}
}
} }
BtnIcon { BtnIcon {

View File

@ -34,6 +34,7 @@ QtObject {
property QtObject msgComposer: QtObject{ property QtObject msgComposer: QtObject{
readonly property string placeHolder: "Send message..." readonly property string placeHolder: "Send message..."
readonly property int maxHeight: 2 // chatListView/maxHeight
property QtObject background: Rectangle { property QtObject background: Rectangle {
color: "transparent" color: "transparent"
@ -56,9 +57,12 @@ QtObject {
} }
}
property QtObject chat: QtObject {
// Measures
readonly property int bubbleMargin: 20
readonly property int bubbleSpacing: 10
} }