From 7302bd5e2ed129b4c73e179df4d9909191d6df3d Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 15 Feb 2021 16:57:45 +0300 Subject: Use dc_msg_get_override_sender_name() --- message.cpp | 9 +++++++++ message.h | 1 + qml/Message.qml | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/message.cpp b/message.cpp index 3027cec..7317075 100644 --- a/message.cpp +++ b/message.cpp @@ -85,6 +85,15 @@ DcMessage::getHeight() return dc_msg_get_height(m_message); } +QString +DcMessage::getOverrideSenderName() +{ + char *name = dc_msg_get_override_sender_name(m_message); + QString result{name}; + dc_str_unref(name); + return result; +} + bool DcMessage::isInfo() { diff --git a/message.h b/message.h index 6405cc6..f8ab1e9 100644 --- a/message.h +++ b/message.h @@ -45,6 +45,7 @@ public: //uint32_t getEphemeralTimer(); //int64_t getEphemeralTimestamp(); //... getsummary ... + Q_INVOKABLE QString getOverrideSenderName(); //hasDeviatingTimestamp //hasLocation //isSent diff --git a/qml/Message.qml b/qml/Message.qml index 9170676..ae10dcd 100644 --- a/qml/Message.qml +++ b/qml/Message.qml @@ -16,6 +16,11 @@ RowLayout { width: ListView.view.width layoutDirection: message.fromId == 1 ? Qt.RightToLeft : Qt.LeftToRight + readonly property string overrideName: message.getOverrideSenderName() + readonly property string displayName: overrideName != "" ? ("~" + overrideName) + : messageObject.message.fromId > 0 ? messageObject.from.displayName + : "" + Rectangle { Layout.preferredWidth: messageContents.width Layout.preferredHeight: messageContents.height @@ -34,7 +39,7 @@ RowLayout { Label { font.bold: true color: messageObject.message.fromId > 0 ? messageObject.from.color : "black" - text: messageObject.message.fromId > 0 ? messageObject.from.displayName : "" + text: messageObject.displayName textFormat: Text.PlainText } } @@ -46,7 +51,7 @@ RowLayout { Label { font.bold: true color: messageObject.message.fromId > 0 ? messageObject.from.color : "black" - text: messageObject.message.fromId > 0 ? messageObject.from.displayName : "" + text: messageObject.displayName textFormat: Text.PlainText } } -- cgit v1.2.3-70-g09d2