diff options
-rw-r--r-- | framework/qml/TextEditor.qml | 5 | ||||
-rw-r--r-- | framework/src/domain/textdocumenthandler.cpp | 6 | ||||
-rw-r--r-- | framework/src/domain/textdocumenthandler.h | 2 | ||||
-rw-r--r-- | views/composer/main.qml | 9 | ||||
-rw-r--r-- | views/composer/qml/View.qml | 13 |
5 files changed, 31 insertions, 4 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 | |||
294 | bool 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 | |||
91 | Q_SIGNALS: | 93 | Q_SIGNALS: |
92 | void documentChanged(); | 94 | void documentChanged(); |
93 | void cursorPositionChanged(); | 95 | void cursorPositionChanged(); |
diff --git a/views/composer/main.qml b/views/composer/main.qml index 6c7fd581..a7f72880 100644 --- a/views/composer/main.qml +++ b/views/composer/main.qml | |||
@@ -76,6 +76,15 @@ ApplicationWindow { | |||
76 | cc: ["ccLoooooooooooooooooooooooooooooooooooooooooooooooooong@example.org"], | 76 | cc: ["ccLoooooooooooooooooooooooooooooooooooooooooooooooooong@example.org"], |
77 | bcc: ["bccLoooooooooooooooooooooooooooooooooooooooooooooooooong@example.org"], | 77 | bcc: ["bccLoooooooooooooooooooooooooooooooooooooooooooooooooong@example.org"], |
78 | draft: true | 78 | draft: true |
79 | }, | ||
80 | { | ||
81 | resource: "resource1", | ||
82 | messageId: "<msg3@test.com>", | ||
83 | date: "2017-07-23T16:46:29", | ||
84 | subject: "HTML", | ||
85 | body: "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"><html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\" font-family:'Noto Sans'; font-size:9pt; font-weight:400; font-style:normal;\"><p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">body</span></p></body></html>", | ||
86 | to: ["html@example.org"], | ||
87 | draft: true | ||
79 | } | 88 | } |
80 | ] | 89 | ] |
81 | }], | 90 | }], |
diff --git a/views/composer/qml/View.qml b/views/composer/qml/View.qml index 9afc5316..ffab3545 100644 --- a/views/composer/qml/View.qml +++ b/views/composer/qml/View.qml | |||
@@ -36,7 +36,6 @@ Kube.View { | |||
36 | resources: [ | 36 | resources: [ |
37 | Kube.ComposerController { | 37 | Kube.ComposerController { |
38 | id: composerController | 38 | id: composerController |
39 | htmlBody: html.checked | ||
40 | sign: signCheckbox.checked | 39 | sign: signCheckbox.checked |
41 | encrypt: encryptCheckbox.checked | 40 | encrypt: encryptCheckbox.checked |
42 | onDone: root.done() | 41 | onDone: root.done() |
@@ -305,6 +304,9 @@ Kube.View { | |||
305 | focusPolicy: Qt.TabFocus | 304 | focusPolicy: Qt.TabFocus |
306 | focus: false | 305 | focus: false |
307 | checked: false | 306 | checked: false |
307 | onCheckedChanged: { | ||
308 | textEditor.htmlEnabled = checked | ||
309 | } | ||
308 | } | 310 | } |
309 | 311 | ||
310 | Row { | 312 | Row { |
@@ -369,12 +371,17 @@ Kube.View { | |||
369 | 371 | ||
370 | Layout.fillWidth: true | 372 | Layout.fillWidth: true |
371 | Layout.fillHeight: true | 373 | Layout.fillHeight: true |
372 | htmlEnabled: html.checked | 374 | onHtmlEnabledChanged: { |
375 | html.checked = htmlEnabled | ||
376 | composerController.htmlBody = htmlEnabled; | ||
377 | } | ||
373 | 378 | ||
374 | onActiveFocusChanged: closeFirstSplitIfNecessary() | 379 | onActiveFocusChanged: closeFirstSplitIfNecessary() |
375 | Keys.onEscapePressed: recipients.forceActiveFocus() | 380 | Keys.onEscapePressed: recipients.forceActiveFocus() |
376 | initialText: composerController.body | 381 | initialText: composerController.body |
377 | onTextChanged: composerController.body = text; | 382 | onTextChanged: { |
383 | composerController.body = text; | ||
384 | } | ||
378 | } | 385 | } |
379 | } | 386 | } |
380 | } | 387 | } |