diff --git a/Linphone/view/Control/Display/Chat/ChatMessage.qml b/Linphone/view/Control/Display/Chat/ChatMessage.qml index d753af03c..a0e59e5a8 100644 --- a/Linphone/view/Control/Display/Chat/ChatMessage.qml +++ b/Linphone/view/Control/Display/Chat/ChatMessage.qml @@ -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 diff --git a/Linphone/view/Control/Input/TextArea.qml b/Linphone/view/Control/Input/TextArea.qml index 99bea614f..81c6892df 100644 --- a/Linphone/view/Control/Input/TextArea.qml +++ b/Linphone/view/Control/Input/TextArea.qml @@ -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) + } + } } - diff --git a/Linphone/view/Page/Form/Chat/SelectedChatView.qml b/Linphone/view/Page/Form/Chat/SelectedChatView.qml index 292fa032c..266b38103 100644 --- a/Linphone/view/Page/Form/Chat/SelectedChatView.qml +++ b/Linphone/view/Page/Form/Chat/SelectedChatView.qml @@ -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()