From 5aa1bb17015a85000312a5b93cdfb8fb7df3b1b2 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Mon, 15 Jun 2020 20:28:39 +0200 Subject: [PATCH] preserving unicode and newlines --- src/Chat/Helper/ChatDelegator.h | 4 ++-- src/chatmodel.cpp | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Chat/Helper/ChatDelegator.h b/src/Chat/Helper/ChatDelegator.h index e4474a8..99a9bde 100644 --- a/src/Chat/Helper/ChatDelegator.h +++ b/src/Chat/Helper/ChatDelegator.h @@ -50,7 +50,7 @@ inline void ListViewDelegate::paint(QPainter *painter, QStyleOptionViewItem cons bodydoc.setDefaultTextOption(textOption); bodydoc.setDefaultFont(QFont("Roboto", 12)); QString bodytext(index.data(Qt::DisplayRole).toString()); - bodydoc.setHtml(bodytext); + bodydoc.setHtml(bodytext.replace("\n", "
")); qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding; bodydoc.setTextWidth(contentswidth); qreal bodyheight = bodydoc.size().height(); @@ -190,4 +190,4 @@ inline QSize ListViewDelegate::sizeHint(QStyleOptionViewItem const &option, QMod return size; } -#endif \ No newline at end of file +#endif diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 7460972..c30b06d 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -479,10 +479,17 @@ Tx MainWindow::createTxFromChatPage() { } + // Let's try to preserve Unicode characters + QByteArray ba_memo = memoplain.toUtf8(); + int ba_memo_length = ba_memo.size(); + + #define MESSAGE (const unsigned char *) ba_memo.data() + #define MESSAGE_LEN ba_memo_length + ////////////Now lets encrypt the message Alice send to Bob////////////////////////////// - #define MESSAGE (const unsigned char *) memoplainchar - #define MESSAGE_LEN lengthmemo + //#define MESSAGE (const unsigned char *) memoplainchar + //#define MESSAGE_LEN lengthmemo #define CIPHERTEXT_LEN (crypto_secretstream_xchacha20poly1305_ABYTES + MESSAGE_LEN) unsigned char ciphertext[CIPHERTEXT_LEN]; unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES];