summaryrefslogtreecommitdiffstats
path: root/framework/qml/TextEditor.qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-10-03 10:01:55 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-10-06 10:41:24 +0200
commit44f1baac26944c1c5061fadf163846958095a425 (patch)
treebbae5619109dc82005725fc423a7bd45561934e2 /framework/qml/TextEditor.qml
parent63ec736eb6568510378372c035450242d51699da (diff)
downloadkube-44f1baac26944c1c5061fadf163846958095a425.tar.gz
kube-44f1baac26944c1c5061fadf163846958095a425.zip
A working Html TextEditor
It's just the TextArea that is broken, it seems the TextEdit works fine with html content.
Diffstat (limited to 'framework/qml/TextEditor.qml')
-rw-r--r--framework/qml/TextEditor.qml51
1 files changed, 42 insertions, 9 deletions
diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml
index e14e60b0..570bc322 100644
--- a/framework/qml/TextEditor.qml
+++ b/framework/qml/TextEditor.qml
@@ -18,7 +18,7 @@
18 */ 18 */
19 19
20import QtQuick 2.7 20import QtQuick 2.7
21import QtQuick.Controls 2.2 21import QtQuick.Controls 2
22 22
23import org.kube.framework 1.0 as Kube 23import org.kube.framework 1.0 as Kube
24 24
@@ -44,29 +44,62 @@ FocusScope {
44 document: edit.textDocument 44 document: edit.textDocument
45 selectionStart: edit.selectionStart 45 selectionStart: edit.selectionStart
46 selectionEnd: edit.selectionEnd 46 selectionEnd: edit.selectionEnd
47 //textColor: colorDialog.color
48 onTextChanged: root.htmlEnabled ? root.text = htmlText : root.text = plainText 47 onTextChanged: root.htmlEnabled ? root.text = htmlText : root.text = plainText
49
50 cursorPosition: edit.cursorPosition 48 cursorPosition: edit.cursorPosition
51 } 49 }
52 50
53 Kube.ScrollHelper { 51
52 Rectangle {
54 anchors.fill: parent 53 anchors.fill: parent
55 flickable: flickableItem 54 border.width: 1
55 border.color: root.activeFocus ? Kube.Colors.highlightColor : Kube.Colors.buttonColor
56 color: Kube.Colors.viewBackgroundColor
57
56 Flickable { 58 Flickable {
57 id: flickableItem 59 id: flickableItem
58 anchors.fill: parent 60 anchors.fill: parent
59 ScrollBar.vertical: Kube.ScrollBar {} 61 ScrollBar.vertical: Kube.ScrollBar {}
62 clip: true
63
64 Kube.ScrollHelper {
65 anchors.fill: parent
66 flickable: flickableItem
67 }
68
69 contentWidth: edit.paintedWidth
70 contentHeight: edit.paintedHeight
60 71
61 Kube.TextArea { 72 function ensureVisible(r) {
73 if (contentX >= r.x) {
74 contentX = r.x
75 } else if (contentX+width <= r.x+r.width) {
76 contentX = r.x+r.width-width;
77 }
78 if (contentY >= r.y) {
79 contentY = r.y;
80 } else if (contentY+height <= r.y+r.height) {
81 contentY = r.y+r.height-height;
82 }
83 }
84
85
86 TextEdit {
62 id: edit 87 id: edit
88
89 width: flickableItem.width
90 height: flickableItem.height
91
63 focus: true 92 focus: true
64 anchors.fill: parent
65 selectByMouse: true 93 selectByMouse: true
66 wrapMode: TextEdit.Wrap 94 wrapMode: TextEdit.WordWrap
67 textFormat: root.htmlEnabled ? Qt.RichText : Qt.PlainText 95 textFormat: root.htmlEnabled ? Qt.RichText : Qt.PlainText
96 onCursorRectangleChanged: flickableItem.ensureVisible(cursorRectangle)
97
98 color: Kube.Colors.textColor
99 font.family: Kube.Font.fontFamily
100 selectionColor: Kube.Colors.highlightColor
101 padding: Kube.Units.smallSpacing
68 } 102 }
69 TextArea.flickable: edit
70 } 103 }
71 } 104 }
72} 105}