linphone-desktop/linphone-app/ui/modules/Linphone/Chat/ChatTextMessage.qml
Julien Wadel 4532e278ac New chat layout :
- Split content type to be filtered by proxy lists.
- Add a message in notification when receiving a conference invitation.
- Change chat bubbles colors to match mobile application.
- Change date display on messages to remove sections. It allows to be more coherent when sorting messages.
- Change Chat Layout : outgoing messages to right, incoming messages to left.
- Change bubble design to be squared when grouped.
- Group messages on 1 second away from previous (and same sender).
- Add a background color with radius to files in reply messages.
- Make color corners on reply.
- Fix filename to 2 lines in file download icon.
- Add a background color on conference invitations.
- Change conference title from bold to normal on invitations.
- Rework chat message content layout to be used with grids and lists : files are now displayed in grid.
- Remove cyclic dependencies with reply design (which was recursivly linked with ChatContent).
- Fix center layouts that were not bind to the correct one.
- Align pictures to center.
- Fix hidden admin usernames in participant view.
2023-03-03 17:09:25 +01:00

95 lines
2.7 KiB
QML

import QtQuick 2.7
import QtQuick.Layouts 1.3
import Clipboard 1.0
import Common 1.0
import Linphone 1.0
import Common.Styles 1.0
import Linphone.Styles 1.0
import TextToSpeech 1.0
import Utils 1.0
import Units 1.0
import UtilsCpp 1.0
import LinphoneEnums 1.0
import ColorsList 1.0
import 'Message.js' as Logic
// TODO : into Loader
// =============================================================================
TextEdit {
id: message
property ContentModel contentModel
property string lastTextSelected : ''
property font customFont : SettingsModel.textMessageFont
property int fitHeight: contentHeight + padding + 8
property int fitWidth: implicitWidth + 2 // add 2 because there is a bug on border that lead to not fit text exactly
signal rightClicked()
property int removeWarningFromBindingLoop : implicitWidth // Just a dummy variable to remove meaningless binding loop on implicitWidth
height: fitHeight
width: parent && parent.width || 1
visible: contentModel// && contentModel.isText()
clip: false
padding: ChatStyle.entry.message.padding
textMargin: 0
readOnly: true
selectByMouse: true
font.family: customFont.family
font.pointSize: Units.dp * customFont.pointSize * (contentModel && UtilsCpp.isOnlyEmojis(contentModel.text) ? 4 : 1 )
text: visible ? UtilsCpp.encodeTextToQmlRichFormat(contentModel.text, {
imagesHeight: ChatStyle.entry.message.images.height,
imagesWidth: ChatStyle.entry.message.images.width
})
: ''
// See http://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop
// and http://doc.qt.io/qt-5/richtext-html-subset.html
textFormat: Text.RichText // To supports links and imgs.
wrapMode: TextEdit.Wrap
onLinkActivated: Qt.openUrlExternally(link)
onSelectedTextChanged:{
if(selectedText != '') lastTextSelected = selectedText
else {
if( mouseArea.keepLastSelection) {
mouseArea.keepLastSelection = false
select(mouseArea.lastStartSelection, mouseArea.lastEndSelection)
}
}
}
onActiveFocusChanged: {
if(activeFocus) {
lastTextSelected = ''
mouseArea.keepLastSelection = false
}
deselect()
}
MouseArea {
id: mouseArea
property bool keepLastSelection: false
property int lastStartSelection:0
property int lastEndSelection:0
anchors.fill: parent
propagateComposedEvents: true
hoverEnabled: false
scrollGestureEnabled: false
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
acceptedButtons: Qt.RightButton
onClicked: {
if(!keepLastSelection) {
lastStartSelection = parent.selectionStart
lastEndSelection = parent.selectionEnd
}
keepLastSelection = true
message.rightClicked()
mouse.accepted = true
}
}
}