Adds rich text format display in chat sending text zone
This commit is contained in:
parent
096501ee20
commit
e178bd43cf
3 changed files with 41 additions and 5 deletions
|
|
@ -20,7 +20,7 @@ Control.Control {
|
||||||
property bool isRemoteMessage: chatMessage? chatMessage.core.isRemoteMessage : false
|
property bool isRemoteMessage: chatMessage? chatMessage.core.isRemoteMessage : false
|
||||||
property bool isFromChatGroup: chatMessage? chatMessage.core.isFromChatGroup : false
|
property bool isFromChatGroup: chatMessage? chatMessage.core.isFromChatGroup : false
|
||||||
property var msgState: chatMessage ? chatMessage.core.messageState : LinphoneEnums.ChatMessageState.StateIdle
|
property var msgState: chatMessage ? chatMessage.core.messageState : LinphoneEnums.ChatMessageState.StateIdle
|
||||||
property string processedText: UtilsCpp.encodeTextToQmlRichFormat(modelData.core.text)
|
property string richFormatText: UtilsCpp.encodeTextToQmlRichFormat(modelData.core.text)
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
property bool linkHovered: false
|
property bool linkHovered: false
|
||||||
|
|
||||||
|
|
@ -112,8 +112,8 @@ Control.Control {
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
id: textElement
|
id: textElement
|
||||||
visible: mainItem.processedText !== ""
|
visible: mainItem.richFormatText !== ""
|
||||||
text: mainItem.processedText
|
text: mainItem.richFormatText
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import QtQuick
|
||||||
import QtQuick.Controls.Basic as Control
|
import QtQuick.Controls.Basic as Control
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Linphone
|
import Linphone
|
||||||
|
import UtilsCpp
|
||||||
|
|
||||||
TextEdit {
|
TextEdit {
|
||||||
id: mainItem
|
id: mainItem
|
||||||
|
|
||||||
|
|
@ -17,6 +18,21 @@ TextEdit {
|
||||||
bottomPadding: Math.round(5 * DefaultStyle.dp)
|
bottomPadding: Math.round(5 * DefaultStyle.dp)
|
||||||
activeFocusOnTab: true
|
activeFocusOnTab: true
|
||||||
|
|
||||||
|
property bool displayAsRichText: false
|
||||||
|
property string richFormatText: UtilsCpp.encodeTextToQmlRichFormat(text)
|
||||||
|
property color textAreaColor
|
||||||
|
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
mainItem.textAreaColor = mainItem.color // backup original color
|
||||||
|
if (displayAsRichText)
|
||||||
|
mainItem.color = 'transparent'
|
||||||
|
}
|
||||||
|
|
||||||
|
onTextChanged: {
|
||||||
|
richFormatText = UtilsCpp.encodeTextToQmlRichFormat(text)
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -43,5 +59,24 @@ TextEdit {
|
||||||
weight: mainItem.placeholderWeight
|
weight: mainItem.placeholderWeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Text {
|
||||||
|
id: formattedText
|
||||||
|
visible: mainItem.displayAsRichText && mainItem.richFormatText !== ""
|
||||||
|
text: mainItem.richFormatText
|
||||||
|
textFormat: Text.RichText
|
||||||
|
wrapMode: mainItem.wrapMode
|
||||||
|
font: mainItem.font
|
||||||
|
color: mainItem.textAreaColor
|
||||||
|
anchors.fill: parent
|
||||||
|
focus: false
|
||||||
|
onHoveredLinkChanged: {
|
||||||
|
mainItem.hovered = mainItem.displayAsRichText && hoveredLink !== ""
|
||||||
|
}
|
||||||
|
onLinkActivated: {
|
||||||
|
if (link.startsWith('sip'))
|
||||||
|
UtilsCpp.createCall(link)
|
||||||
|
else
|
||||||
|
Qt.openUrlExternally(link)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,7 @@ RowLayout {
|
||||||
onCursorRectangleChanged: sendingAreaFlickable.ensureVisible(cursorRectangle)
|
onCursorRectangleChanged: sendingAreaFlickable.ensureVisible(cursorRectangle)
|
||||||
property string previousText
|
property string previousText
|
||||||
Component.onCompleted: previousText = text
|
Component.onCompleted: previousText = text
|
||||||
|
displayAsRichText: true
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
if (previousText === "" && text !== "") {
|
if (previousText === "" && text !== "") {
|
||||||
mainItem.chat.core.lCompose()
|
mainItem.chat.core.lCompose()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue