summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-01 10:00:11 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-01 10:00:11 +0200
commitbc6ac986dc9dde942b0a9185940e748c3a0e87c9 (patch)
treee5279c9d957ed2653e315274079d7325ce2f2e8f /framework
parent88616288d8541397776b54c5546d61af835483af (diff)
downloadkube-bc6ac986dc9dde942b0a9185940e748c3a0e87c9.tar.gz
kube-bc6ac986dc9dde942b0a9185940e748c3a0e87c9.zip
Enable HTML mode when loading an html message.
Diffstat (limited to 'framework')
-rw-r--r--framework/qml/TextEditor.qml5
-rw-r--r--framework/src/domain/textdocumenthandler.cpp6
-rw-r--r--framework/src/domain/textdocumenthandler.h2
3 files changed, 12 insertions, 1 deletions
diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml
index e5cc665c..7b1c5dee 100644
--- a/framework/qml/TextEditor.qml
+++ b/framework/qml/TextEditor.qml
@@ -34,6 +34,7 @@ FocusScope {
34 34
35 property string initialText 35 property string initialText
36 onInitialTextChanged: { 36 onInitialTextChanged: {
37 htmlEnabled = document.isHtml(initialText)
37 edit.text = initialText 38 edit.text = initialText
38 } 39 }
39 40
@@ -55,7 +56,9 @@ FocusScope {
55 document: edit.textDocument 56 document: edit.textDocument
56 selectionStart: edit.selectionStart 57 selectionStart: edit.selectionStart
57 selectionEnd: edit.selectionEnd 58 selectionEnd: edit.selectionEnd
58 onTextChanged: root.htmlEnabled ? root.text = htmlText : root.text = plainText 59 onTextChanged: {
60 root.htmlEnabled ? root.text = htmlText : root.text = plainText
61 }
59 cursorPosition: edit.cursorPosition 62 cursorPosition: edit.cursorPosition
60 } 63 }
61 64
diff --git a/framework/src/domain/textdocumenthandler.cpp b/framework/src/domain/textdocumenthandler.cpp
index 6c2bc323..ea312282 100644
--- a/framework/src/domain/textdocumenthandler.cpp
+++ b/framework/src/domain/textdocumenthandler.cpp
@@ -289,3 +289,9 @@ void TextDocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &fo
289 } 289 }
290 } 290 }
291} 291}
292
293
294bool TextDocumentHandler::isHtml(const QString &text)
295{
296 return Qt::mightBeRichText(text);
297}
diff --git a/framework/src/domain/textdocumenthandler.h b/framework/src/domain/textdocumenthandler.h
index 91cd8489..38de917d 100644
--- a/framework/src/domain/textdocumenthandler.h
+++ b/framework/src/domain/textdocumenthandler.h
@@ -88,6 +88,8 @@ public:
88 88
89 Q_INVOKABLE void resetFormat(); 89 Q_INVOKABLE void resetFormat();
90 90
91 Q_INVOKABLE static bool isHtml(const QString &);
92
91Q_SIGNALS: 93Q_SIGNALS:
92 void documentChanged(); 94 void documentChanged();
93 void cursorPositionChanged(); 95 void cursorPositionChanged();