diff options
-rw-r--r-- | message.cpp | 11 | ||||
-rw-r--r-- | message.h | 2 | ||||
-rw-r--r-- | qml/Message.qml | 34 |
3 files changed, 38 insertions, 9 deletions
diff --git a/message.cpp b/message.cpp index 7317075..ff4bab9 100644 --- a/message.cpp +++ b/message.cpp @@ -108,3 +108,14 @@ DcMessage::getQuotedText() dc_str_unref(text); return result; } + +DcMessage * +DcMessage::getQuotedMessage() +{ + dc_msg_t *quote = dc_msg_get_quoted_msg(m_message); + if (quote) { + return new DcMessage{quote}; + } else { + return NULL; + } +} @@ -18,6 +18,7 @@ class DcMessage : public QObject { Q_PROPERTY(int height READ getHeight CONSTANT) Q_PROPERTY(bool isInfo READ isInfo CONSTANT) Q_PROPERTY(QString quotedText READ getQuotedText CONSTANT) + Q_PROPERTY(DcMessage *quotedMessage READ getQuotedMessage CONSTANT) dc_msg_t *m_message{nullptr}; public: @@ -55,4 +56,5 @@ public: //isIncreation //isSetupmessage Q_INVOKABLE QString getQuotedText(); + Q_INVOKABLE DcMessage *getQuotedMessage(); }; diff --git a/qml/Message.qml b/qml/Message.qml index 73d91fc..fd13c52 100644 --- a/qml/Message.qml +++ b/qml/Message.qml @@ -13,6 +13,8 @@ RowLayout { property DcMessage message readonly property DcContact from: context.getContact(message.fromId) + readonly property DcMessage quoteMessage: message.quotedMessage + readonly property DcContact quoteFrom: quoteMessage ? context.getContact(quoteMessage.fromId) : null width: ListView.view.width layoutDirection: message.fromId == 1 ? Qt.RightToLeft : Qt.LeftToRight @@ -120,17 +122,31 @@ RowLayout { : [40, 41].includes(messageObject.message.viewtype) ? audioMessageView : textMessageView } - TextEdit { - Layout.maximumWidth: messageObject.width > 30 ? messageObject.width - 30 : messageObject.width - text: messageObject.message.quotedText ? messageObject.message.quotedText : "" - textFormat: Text.PlainText - selectByMouse: true - readOnly: true - color: "grey" - wrapMode: Text.Wrap - font.pixelSize: 12 + // Quote + RowLayout { + Layout.leftMargin: Kirigami.Units.smallSpacing + visible: messageObject.message.quotedText + implicitHeight: quoteTextEdit.height + spacing: Kirigami.Units.smallSpacing + Rectangle { + width: Kirigami.Units.smallSpacing + color: quoteFrom ? quoteFrom.color : "black" + Layout.fillHeight: true + } + TextEdit { + id: quoteTextEdit + Layout.maximumWidth: messageObject.width > 30 ? messageObject.width - 30 : messageObject.width + text: messageObject.message.quotedText ? messageObject.message.quotedText : "" + textFormat: Text.PlainText + selectByMouse: true + readOnly: true + color: "grey" + wrapMode: Text.Wrap + font.pixelSize: 12 + } } + // Message TextEdit { Layout.maximumWidth: messageObject.width > 30 ? messageObject.width - 30 : messageObject.width text: messageObject.message.text |