diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-10-08 22:37:46 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-10-08 22:38:24 +0200 |
commit | 9f2626385bf9c12a240f5fd17b90304c231fba5e (patch) | |
tree | 24ed7d30ac7e54f54f78cab0a2e1163e6298b014 | |
parent | f1e9fd9c4b5a166f8d0cbcec099470cbcea0f058 (diff) | |
download | kube-9f2626385bf9c12a240f5fd17b90304c231fba5e.tar.gz kube-9f2626385bf9c12a240f5fd17b90304c231fba5e.zip |
Clear all formatting when converting to plain text.
We used to end up with whatever formatting the current cursor had.
Task: https://phabricator.kde.org/T7160
-rw-r--r-- | framework/qml/TextEditor.qml | 2 | ||||
-rw-r--r-- | framework/src/domain/textdocumenthandler.cpp | 11 | ||||
-rw-r--r-- | framework/src/domain/textdocumenthandler.h | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml index 8a5c2bb9..3ce6b482 100644 --- a/framework/qml/TextEditor.qml +++ b/framework/qml/TextEditor.qml | |||
@@ -46,8 +46,8 @@ FocusScope { | |||
46 | edit.text = t | 46 | edit.text = t |
47 | } else { | 47 | } else { |
48 | var t = document.plainText | 48 | var t = document.plainText |
49 | document.resetFormat() | ||
49 | edit.textFormat = Qt.PlainText | 50 | edit.textFormat = Qt.PlainText |
50 | edit.font.bold = false | ||
51 | edit.text = t | 51 | edit.text = t |
52 | } | 52 | } |
53 | } | 53 | } |
diff --git a/framework/src/domain/textdocumenthandler.cpp b/framework/src/domain/textdocumenthandler.cpp index 729d39e8..6c2bc323 100644 --- a/framework/src/domain/textdocumenthandler.cpp +++ b/framework/src/domain/textdocumenthandler.cpp | |||
@@ -32,6 +32,17 @@ TextDocumentHandler::TextDocumentHandler(QObject *parent) | |||
32 | { | 32 | { |
33 | } | 33 | } |
34 | 34 | ||
35 | void TextDocumentHandler::resetFormat() | ||
36 | { | ||
37 | //Clear all formatting from the document. | ||
38 | auto cursor = textCursor(); | ||
39 | cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); | ||
40 | cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); | ||
41 | cursor.setCharFormat({}); | ||
42 | mCachedTextFormat = {}; | ||
43 | reset(); | ||
44 | } | ||
45 | |||
35 | QQuickTextDocument *TextDocumentHandler::document() const | 46 | QQuickTextDocument *TextDocumentHandler::document() const |
36 | { | 47 | { |
37 | return mDocument; | 48 | return mDocument; |
diff --git a/framework/src/domain/textdocumenthandler.h b/framework/src/domain/textdocumenthandler.h index b8ae5bdb..43781940 100644 --- a/framework/src/domain/textdocumenthandler.h +++ b/framework/src/domain/textdocumenthandler.h | |||
@@ -86,6 +86,8 @@ public: | |||
86 | int fontSize() const; | 86 | int fontSize() const; |
87 | void setFontSize(int size); | 87 | void setFontSize(int size); |
88 | 88 | ||
89 | Q_INVOKABLE void resetFormat(); | ||
90 | |||
89 | Q_SIGNALS: | 91 | Q_SIGNALS: |
90 | void documentChanged(); | 92 | void documentChanged(); |
91 | void cursorPositionChanged(); | 93 | void cursorPositionChanged(); |