summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/qml/TextEditor.qml30
-rw-r--r--framework/src/domain/documenthandler.cpp16
-rw-r--r--framework/src/domain/documenthandler.h3
3 files changed, 39 insertions, 10 deletions
diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml
index 5f29cef3..047c9b77 100644
--- a/framework/qml/TextEditor.qml
+++ b/framework/qml/TextEditor.qml
@@ -23,7 +23,32 @@ import QtQuick.Controls 2.2
23import org.kube.framework 1.0 as Kube 23import org.kube.framework 1.0 as Kube
24 24
25FocusScope { 25FocusScope {
26 property alias text: edit.text 26 id: root
27 property string text: ""
28
29 property bool htmlEnabled: false
30
31 property alias bold: document.bold
32 property alias italic: document.italic
33 property alias underline: document.underline
34
35 property string initialText
36 onInitialTextChanged: {
37 if (text == "") {
38 edit.text = initialText
39 }
40 }
41
42 Kube.DocumentHandler {
43 id: document
44 document: edit.textDocument
45 cursorPosition: edit.cursorPosition
46 selectionStart: edit.selectionStart
47 selectionEnd: edit.selectionEnd
48 //textColor: colorDialog.color
49 onTextChanged: root.text = text
50 }
51
27 Kube.ScrollHelper { 52 Kube.ScrollHelper {
28 anchors.fill: parent 53 anchors.fill: parent
29 flickable: flickableItem 54 flickable: flickableItem
@@ -37,7 +62,10 @@ FocusScope {
37 focus: true 62 focus: true
38 anchors.fill: parent 63 anchors.fill: parent
39 selectByMouse: true 64 selectByMouse: true
65 persistentSelection: true
40 wrapMode: TextEdit.Wrap 66 wrapMode: TextEdit.Wrap
67 textFormat: Qt.RichText
68 cursorPosition: document.cursorPosition
41 } 69 }
42 TextArea.flickable: edit 70 TextArea.flickable: edit
43 } 71 }
diff --git a/framework/src/domain/documenthandler.cpp b/framework/src/domain/documenthandler.cpp
index 266f4a27..0f949da8 100644
--- a/framework/src/domain/documenthandler.cpp
+++ b/framework/src/domain/documenthandler.cpp
@@ -94,16 +94,20 @@ void DocumentHandler::setCursorPosition(int position)
94 //Skip over invisible char 94 //Skip over invisible char
95 if (m_cursorPosition < position) { 95 if (m_cursorPosition < position) {
96 auto cursor = textCursor(); 96 auto cursor = textCursor();
97 cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); 97 if (!cursor.atEnd()) {
98 if (cursor.selectedText() == "\u2063") { 98 cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
99 position++; 99 if (cursor.selectedText() == "\u2063") {
100 position++;
101 }
100 } 102 }
101 } 103 }
102 if (m_cursorPosition > position) { 104 if (m_cursorPosition > position) {
103 auto cursor = textCursor(); 105 auto cursor = textCursor();
104 cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); 106 if (!cursor.atStart()) {
105 if (cursor.selectedText() == "\u2063") { 107 cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
106 position--; 108 if (cursor.selectedText() == "\u2063") {
109 position--;
110 }
107 } 111 }
108 } 112 }
109 m_cursorPosition = position; 113 m_cursorPosition = position;
diff --git a/framework/src/domain/documenthandler.h b/framework/src/domain/documenthandler.h
index 74b7c4f9..24b3b35f 100644
--- a/framework/src/domain/documenthandler.h
+++ b/framework/src/domain/documenthandler.h
@@ -145,9 +145,6 @@ private:
145 int m_cursorPosition; 145 int m_cursorPosition;
146 int m_selectionStart; 146 int m_selectionStart;
147 int m_selectionEnd; 147 int m_selectionEnd;
148
149 QFont m_font;
150 int m_fontSize;
151}; 148};
152 149
153#endif // DOCUMENTHANDLER_H 150#endif // DOCUMENTHANDLER_H