Add text wrap behaivour on bubbles

This commit is contained in:
Angela Mazzurco 2017-06-08 17:10:37 +02:00
parent 4a90436e8e
commit 92bcd4cbfd
2 changed files with 13 additions and 6 deletions

View File

@ -22,6 +22,7 @@ Item {
Rectangle {
id: rootBubble
anchors.fill: parent
width: parent.width
height: parent.height
@ -29,7 +30,10 @@ Item {
Rectangle
{
id: bubble
width: Math.max(mesageText.implicitWidth, sendersName.implicitWidth ) + timeText.implicitWidth + styles.aditionalBubbleWidth
width: Math.min (
rootBubble.width * styles.bubbleMaxWidth,
Math.max(mesageText.implicitWidth, sendersName.implicitWidth )
) + timeText.implicitWidth + styles.aditionalBubbleWidth
height: mesageText.height + sendersName.height + styles.aditionalBubbleHeight
@ -77,7 +81,7 @@ Item {
Text {
id: mesageText
text: model.msg
width: rootBubble.width * styles.bubbleMaxWidth
anchors.left: (model.incoming)? parent.left : undefined
anchors.right:(!model.incoming)? parent.right : undefined
@ -85,11 +89,13 @@ Item {
anchors.leftMargin: styles.lMarginBubble
anchors.rightMargin: styles.rMarginBubble
// wrapMode: Text.Wrap
horizontalAlignment: (!model.incoming &&
mesageText.implicitWidth <= (rootBubble.width * styles.bubbleMaxWidth)
)? Text.AlignRight : Text.AlignLeft
wrapMode: Text.Wrap
}
}
}

View File

@ -3,13 +3,14 @@ pragma Singleton
QtObject {
// Margins
// Bubble measures
readonly property int lMarginBubble: 10
readonly property int rMarginBubble: 10
readonly property int tMarginBubble: 5
readonly property int bMarginBubble: 10
readonly property int aditionalBubbleHeight: tMarginBubble * 2
readonly property int aditionalBubbleWidth: 30
readonly property real bubbleMaxWidth: 0.5 // % from parent
// BubbleProps
readonly property int radius: 5