From c02c9dbb15af7598994edbcb7e13eb937bce1e6a Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 12 Oct 2020 01:06:11 +0300 Subject: Add basic quoting support --- message.cpp | 9 +++++++++ message.h | 2 ++ qml/Message.qml | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/message.cpp b/message.cpp index 7eb6019..3027cec 100644 --- a/message.cpp +++ b/message.cpp @@ -90,3 +90,12 @@ DcMessage::isInfo() { return dc_msg_is_info(m_message); } + +QString +DcMessage::getQuotedText() +{ + char *text = dc_msg_get_quoted_text(m_message); + QString result{text}; + dc_str_unref(text); + return result; +} diff --git a/message.h b/message.h index bda3108..6405cc6 100644 --- a/message.h +++ b/message.h @@ -17,6 +17,7 @@ class DcMessage : public QObject { Q_PROPERTY(int width READ getWidth CONSTANT) Q_PROPERTY(int height READ getHeight CONSTANT) Q_PROPERTY(bool isInfo READ isInfo CONSTANT) + Q_PROPERTY(QString quotedText READ getQuotedText CONSTANT) dc_msg_t *m_message{nullptr}; public: @@ -52,4 +53,5 @@ public: bool isInfo(); //isIncreation //isSetupmessage + Q_INVOKABLE QString getQuotedText(); }; diff --git a/qml/Message.qml b/qml/Message.qml index 32cf001..0723546 100644 --- a/qml/Message.qml +++ b/qml/Message.qml @@ -63,7 +63,7 @@ RowLayout { } TextEdit { Layout.maximumWidth: messageObject.width > 30 ? messageObject.width - 30 : messageObject.width - text: messageObject.message.text + text: (messageObject.message.quotedText ? "> " + messageObject.message.quotedText + "\n\n" : "") + messageObject.message.text textFormat: Text.PlainText selectByMouse: true readOnly: true -- cgit v1.2.3-70-g09d2