Decode HTML entities when copying text to clipboard (fixes #1850)

Currently, when using `Copy` in the context menu, the text will be
HTML escaped (e.g. `"` becomes `"`). Add a function to decode
HTML entities when copying to clipboard.

This PR fixes issue #1850.
pull/1855/head
Integral 3 weeks ago
parent 5fe8ebf335
commit 6143d11e1a
No known key found for this signature in database
GPG Key ID: 06313911057DD5A8
  1. 4
      resources/qml/MessageView.qml
  2. 7
      src/Clipboard.cpp
  3. 1
      src/Clipboard.h

@ -477,7 +477,7 @@ Item {
text: qsTr("&Copy")
visible: messageContextMenuC.text
onTriggered: Clipboard.text = messageContextMenuC.text
onTriggered: Clipboard.setHtmlText(messageContextMenuC.text)
}
}
Component {
@ -679,7 +679,7 @@ Item {
text: qsTr("&Copy")
visible: replyContextMenuC.text
onTriggered: Clipboard.text = replyContextMenuC.text
onTriggered: Clipboard.setHtmlText(replyContextMenuC.text)
}
}
Component {

@ -6,6 +6,7 @@
#include <QClipboard>
#include <QGuiApplication>
#include <QTextDocumentFragment>
Clipboard::Clipboard(QObject *parent)
: QObject(parent)
@ -19,6 +20,12 @@ Clipboard::setText(QString text)
QGuiApplication::clipboard()->setText(text);
}
void
Clipboard::setHtmlText(QString text)
{
setText(QTextDocumentFragment::fromHtml(text).toPlainText());
}
QString
Clipboard::text() const
{

@ -21,6 +21,7 @@ public:
QString text() const;
void setText(QString text_);
Q_INVOKABLE void setHtmlText(QString text_);
signals:
void textChanged();
};

Loading…
Cancel
Save