Fix copying multi-line selected rich text

For rich text (rendered HTML) fields and areas, the selectedText
property for some reason contains "\u2028" or "\u2029"
characters that look like newlines in Qt programs but are just
invisible anywhere else. Translate them to normal "\n".
This commit is contained in:
miruka
2020-10-31 02:59:56 -04:00
parent da75568428
commit 7564b40c3e
7 changed files with 27 additions and 12 deletions

View File

@@ -208,9 +208,9 @@ HDrawer {
Layout.fillWidth: true
onSelectedTextChanged: if (selectedText) {
onSelectedTextChanged: if (selectedPlainText) {
selectedOutputDelegateIndex = model.index
selectedOutputText = selectedText
selectedOutputText = selectedPlainText
} else if (selectedOutputDelegateIndex === model.index) {
selectedOutputDelegateIndex = -1
selectedOutputText = ""
@@ -249,7 +249,7 @@ HDrawer {
icon.name: "copy-text"
text: qsTr("Copy")
onTriggered: {
if (delegate.selectedText) {
if (delegate.selectedPlainText) {
delegate.copy()
return
}
@@ -337,7 +337,7 @@ HDrawer {
Keys.onPressed: ev => {
if (
ev.matches(StandardKey.Copy) &&
! inputArea.selectedText &&
! inputArea.selectedPlainText &&
selectedOutputText
) {
ev.accepted = true