From 2bf195a1f5cbf5f473cbbcc929ad64d675e829cb Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 30 Jul 2018 18:06:31 +0200 Subject: Removed the html switch. Instead of having a switch we're going to always use an html editor, and simply send as plaintext if there is no formatting. To easily remove all formatting a button is added. --- framework/qml/TextEditor.qml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'framework/qml') diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml index 7b1c5dee..45bf2ecd 100644 --- a/framework/qml/TextEditor.qml +++ b/framework/qml/TextEditor.qml @@ -34,21 +34,11 @@ FocusScope { property string initialText onInitialTextChanged: { - htmlEnabled = document.isHtml(initialText) edit.text = initialText } - onHtmlEnabledChanged: { - if (htmlEnabled) { - var t = document.htmlText - edit.textFormat = Qt.RichText - edit.text = t - } else { - var t = document.plainText - document.resetFormat() - edit.textFormat = Qt.PlainText - edit.text = t - } + function clearFormatting() { + document.resetFormat() } Kube.TextDocumentHandler { @@ -57,6 +47,7 @@ FocusScope { selectionStart: edit.selectionStart selectionEnd: edit.selectionEnd onTextChanged: { + root.htmlEnabled = containsFormatting(); root.htmlEnabled ? root.text = htmlText : root.text = plainText } cursorPosition: edit.cursorPosition @@ -105,7 +96,7 @@ FocusScope { focus: true selectByMouse: true wrapMode: TextEdit.Wrap - textFormat: Qt.PlainText + textFormat: Qt.RichText onCursorRectangleChanged: flickableItem.ensureVisible(cursorRectangle) color: Kube.Colors.textColor -- cgit v1.2.3