summaryrefslogtreecommitdiffstats
path: root/framework/qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-30 18:06:31 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-30 18:06:31 +0200
commit2bf195a1f5cbf5f473cbbcc929ad64d675e829cb (patch)
treef5070a61bb505fb66413a95c817a952367ffc08d /framework/qml
parent8dc99625d54dbe15816b4b4d0f6c87850289d30d (diff)
downloadkube-2bf195a1f5cbf5f473cbbcc929ad64d675e829cb.tar.gz
kube-2bf195a1f5cbf5f473cbbcc929ad64d675e829cb.zip
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.
Diffstat (limited to 'framework/qml')
-rw-r--r--framework/qml/TextEditor.qml17
1 files changed, 4 insertions, 13 deletions
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 {
34 34
35 property string initialText 35 property string initialText
36 onInitialTextChanged: { 36 onInitialTextChanged: {
37 htmlEnabled = document.isHtml(initialText)
38 edit.text = initialText 37 edit.text = initialText
39 } 38 }
40 39
41 onHtmlEnabledChanged: { 40 function clearFormatting() {
42 if (htmlEnabled) { 41 document.resetFormat()
43 var t = document.htmlText
44 edit.textFormat = Qt.RichText
45 edit.text = t
46 } else {
47 var t = document.plainText
48 document.resetFormat()
49 edit.textFormat = Qt.PlainText
50 edit.text = t
51 }
52 } 42 }
53 43
54 Kube.TextDocumentHandler { 44 Kube.TextDocumentHandler {
@@ -57,6 +47,7 @@ FocusScope {
57 selectionStart: edit.selectionStart 47 selectionStart: edit.selectionStart
58 selectionEnd: edit.selectionEnd 48 selectionEnd: edit.selectionEnd
59 onTextChanged: { 49 onTextChanged: {
50 root.htmlEnabled = containsFormatting();
60 root.htmlEnabled ? root.text = htmlText : root.text = plainText 51 root.htmlEnabled ? root.text = htmlText : root.text = plainText
61 } 52 }
62 cursorPosition: edit.cursorPosition 53 cursorPosition: edit.cursorPosition
@@ -105,7 +96,7 @@ FocusScope {
105 focus: true 96 focus: true
106 selectByMouse: true 97 selectByMouse: true
107 wrapMode: TextEdit.Wrap 98 wrapMode: TextEdit.Wrap
108 textFormat: Qt.PlainText 99 textFormat: Qt.RichText
109 onCursorRectangleChanged: flickableItem.ensureVisible(cursorRectangle) 100 onCursorRectangleChanged: flickableItem.ensureVisible(cursorRectangle)
110 101
111 color: Kube.Colors.textColor 102 color: Kube.Colors.textColor