summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-10-08 22:37:46 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-10-08 22:38:24 +0200
commit9f2626385bf9c12a240f5fd17b90304c231fba5e (patch)
tree24ed7d30ac7e54f54f78cab0a2e1163e6298b014
parentf1e9fd9c4b5a166f8d0cbcec099470cbcea0f058 (diff)
downloadkube-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.qml2
-rw-r--r--framework/src/domain/textdocumenthandler.cpp11
-rw-r--r--framework/src/domain/textdocumenthandler.h2
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
35void 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
35QQuickTextDocument *TextDocumentHandler::document() const 46QQuickTextDocument *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
89Q_SIGNALS: 91Q_SIGNALS:
90 void documentChanged(); 92 void documentChanged();
91 void cursorPositionChanged(); 93 void cursorPositionChanged();