mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
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 isFromChatGroup: chatMessage? chatMessage.core.isFromChatGroup : false
|
||||
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
|
||||
property bool linkHovered: false
|
||||
|
||||
|
|
@ -112,8 +112,8 @@ Control.Control {
|
|||
}
|
||||
Text {
|
||||
id: textElement
|
||||
visible: mainItem.processedText !== ""
|
||||
text: mainItem.processedText
|
||||
visible: mainItem.richFormatText !== ""
|
||||
text: mainItem.richFormatText
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ import QtQuick
|
|||
import QtQuick.Controls.Basic as Control
|
||||
import QtQuick.Layouts
|
||||
import Linphone
|
||||
|
||||
import UtilsCpp
|
||||
|
||||
TextEdit {
|
||||
id: mainItem
|
||||
|
||||
|
|
@ -17,6 +18,21 @@ TextEdit {
|
|||
bottomPadding: Math.round(5 * DefaultStyle.dp)
|
||||
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 {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
|
|
@ -43,5 +59,24 @@ TextEdit {
|
|||
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)
|
||||
property string previousText
|
||||
Component.onCompleted: previousText = text
|
||||
displayAsRichText: true
|
||||
onTextChanged: {
|
||||
if (previousText === "" && text !== "") {
|
||||
mainItem.chat.core.lCompose()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue