summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--components/kube/contents/ui/ComposerView.qml2
-rw-r--r--framework/qml/TextArea.qml39
-rw-r--r--framework/qml/TextEditor.qml51
-rw-r--r--framework/qmldir1
4 files changed, 42 insertions, 51 deletions
diff --git a/components/kube/contents/ui/ComposerView.qml b/components/kube/contents/ui/ComposerView.qml
index a27e90e9..25244199 100644
--- a/components/kube/contents/ui/ComposerView.qml
+++ b/components/kube/contents/ui/ComposerView.qml
@@ -278,8 +278,6 @@ Kube.View {
278 278
279 Kube.Switch { 279 Kube.Switch {
280 id: html 280 id: html
281 //FIXME enable once the html editor works.
282 visible: false
283 text: checked ? qsTr("plain") : qsTr("html") 281 text: checked ? qsTr("plain") : qsTr("html")
284 focusPolicy: Qt.TabFocus 282 focusPolicy: Qt.TabFocus
285 focus: false 283 focus: false
diff --git a/framework/qml/TextArea.qml b/framework/qml/TextArea.qml
deleted file mode 100644
index 1f968560..00000000
--- a/framework/qml/TextArea.qml
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19
20import QtQuick 2.7
21import QtQuick.Templates 2.0 as T
22
23import org.kube.framework 1.0 as Kube
24
25T.TextArea {
26 id: root
27
28 padding: Kube.Units.smallSpacing + 1 //(boder width)
29
30 color: Kube.Colors.textColor
31 selectionColor: Kube.Colors.highlightColor
32 selectedTextColor: Kube.Colors.highlightedTextColor
33
34 background: Rectangle {
35 color: Kube.Colors.viewBackgroundColor
36 border.width: 1
37 border.color: root.activeFocus ? Kube.Colors.highlightColor : Kube.Colors.buttonColor
38 }
39}
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}
diff --git a/framework/qmldir b/framework/qmldir
index aef845b1..90d1c762 100644
--- a/framework/qmldir
+++ b/framework/qmldir
@@ -28,7 +28,6 @@ TextButton 1.0 TextButton.qml
28TextField 1.0 TextField.qml 28TextField 1.0 TextField.qml
29RequiredTextField 1.0 RequiredTextField.qml 29RequiredTextField 1.0 RequiredTextField.qml
30PasswordField 1.0 PasswordField.qml 30PasswordField 1.0 PasswordField.qml
31TextArea 1.0 TextArea.qml
32TextEditor 1.0 TextEditor.qml 31TextEditor 1.0 TextEditor.qml
33ToolTip 1.0 ToolTip.qml 32ToolTip 1.0 ToolTip.qml
34Label 1.0 Label.qml 33Label 1.0 Label.qml