mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-28 11:56:20 +00:00
Revert display image preview from URL in chat messages (because errors cannot be managed).
Use Rich text in notifications for displaying emojis and text decorations.
This commit is contained in:
parent
6506bbeb18
commit
2aa9d0fb39
3 changed files with 30 additions and 19 deletions
|
|
@ -719,14 +719,16 @@ bool Utils::isOnlyEmojis(const QString& text){
|
|||
|
||||
|
||||
QString Utils::encodeTextToQmlRichFormat(const QString& text, const QVariantMap& options){
|
||||
QString images;
|
||||
QStringList formattedText;
|
||||
/*QString images;
|
||||
QStringList imageFormat;
|
||||
bool lastWasUrl = false;
|
||||
for(auto format : QImageReader::supportedImageFormats())
|
||||
imageFormat.append(QString::fromLatin1(format).toUpper());
|
||||
*/
|
||||
QStringList formattedText;
|
||||
bool lastWasUrl = false;
|
||||
|
||||
if(options.contains("noLink") && options["noLink"].toBool()){
|
||||
formattedText.append(text);
|
||||
formattedText.append(encodeEmojiToQmlRichFormat(text));
|
||||
}else{
|
||||
auto primaryColor = App::getInstance()->getColorListModel()->getColor("i")->getColor();
|
||||
auto iriParsed = UriTools::parseIri(text);
|
||||
|
|
@ -743,9 +745,10 @@ QString Utils::encodeTextToQmlRichFormat(const QString& text, const QVariantMap&
|
|||
if(iri.front() != ' ')
|
||||
iri.push_front(' ');
|
||||
}
|
||||
formattedText.append(iri);
|
||||
formattedText.append(encodeEmojiToQmlRichFormat(iri));
|
||||
}else{
|
||||
QString uri = iriParsed[i].second.left(3) == "www" ? "http://"+iriParsed[i].second : iriParsed[i].second ;
|
||||
/* TODO : preview from link
|
||||
int extIndex = iriParsed[i].second.lastIndexOf('.');
|
||||
QString ext;
|
||||
if( extIndex >= 0)
|
||||
|
|
@ -759,24 +762,19 @@ QString Utils::encodeTextToQmlRichFormat(const QString& text, const QVariantMap&
|
|||
options.contains("imagesWidth")
|
||||
? QString(" height='auto'")
|
||||
: ""
|
||||
) + " src=\"" + iriParsed[i].second + "\" /></a>";
|
||||
) + " src=\"" + iriParsed[i].second + "\" />"+uri+"</a>";
|
||||
}else{
|
||||
*/
|
||||
formattedText.append( "<a style=\"color:"+ primaryColor.name() +";\" href=\"" + uri + "\">" + iri + "</a>");
|
||||
lastWasUrl = true;
|
||||
}
|
||||
/*}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
if(lastWasUrl && formattedText.last().back() != ' '){
|
||||
formattedText.push_back(" ");
|
||||
}
|
||||
if(images != "")
|
||||
images = "<div>" + images +"</div>";
|
||||
QString encodeEmojis = encodeEmojiToQmlRichFormat(formattedText.join(""));
|
||||
if( encodeEmojis.isEmpty() && images.isEmpty())
|
||||
return "";
|
||||
else
|
||||
return images + "<p style=\"white-space:pre-wrap;\">" + encodeEmojiToQmlRichFormat(formattedText.join("")) + "</p>";
|
||||
return "<p style=\"white-space:pre-wrap;\">" + formattedText.join("") + "</p>";
|
||||
}
|
||||
|
||||
QString Utils::getFileContent(const QString& filePath){
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import Common 1.0
|
|||
import Linphone 1.0
|
||||
import Linphone.Styles 1.0
|
||||
import UtilsCpp 1.0
|
||||
import Units 1.0
|
||||
|
||||
import 'qrc:/ui/scripts/Utils/utils.js' as Utils
|
||||
|
||||
|
|
@ -56,23 +57,36 @@ Notification {
|
|||
color: NotificationReceivedMessageStyle.messageContainer.colorModel.color
|
||||
radius: NotificationReceivedMessageStyle.messageContainer.radius
|
||||
|
||||
Text {
|
||||
TextEdit {
|
||||
id: messageText
|
||||
property font customFont : SettingsModel.textMessageFont
|
||||
property string fullText: notification.notificationData.message
|
||||
anchors {
|
||||
fill: parent
|
||||
margins: NotificationReceivedMessageStyle.messageContainer.margins
|
||||
}
|
||||
|
||||
color: NotificationReceivedMessageStyle.messageContainer.text.colorModel.color
|
||||
elide: Text.ElideRight
|
||||
|
||||
|
||||
font {
|
||||
italic: true
|
||||
pointSize: NotificationReceivedMessageStyle.messageContainer.text.pointSize
|
||||
family: customFont.family
|
||||
pointSize: Units.dp * (customFont.pointSize - 1)
|
||||
}
|
||||
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: notification.notificationData.message
|
||||
text: UtilsCpp.encodeTextToQmlRichFormat(metrics.elidedText)
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.Wrap
|
||||
|
||||
TextMetrics {
|
||||
id: metrics
|
||||
font: messageText.font
|
||||
text: messageText.fullText
|
||||
elideWidth: messageText.width
|
||||
elide: Qt.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ QtObject {
|
|||
|
||||
property QtObject text: QtObject {
|
||||
property var colorModel: ColorsList.add(sectionName+'_message_container_text', 'l')
|
||||
property int pointSize: Units.dp * 9
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue