summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/kube/contents/ui/ComposerView.qml8
-rw-r--r--framework/qml/TextEditor.qml56
-rw-r--r--framework/qmldir1
3 files changed, 59 insertions, 6 deletions
diff --git a/components/kube/contents/ui/ComposerView.qml b/components/kube/contents/ui/ComposerView.qml
index b8da8a83..7bc3b061 100644
--- a/components/kube/contents/ui/ComposerView.qml
+++ b/components/kube/contents/ui/ComposerView.qml
@@ -297,16 +297,12 @@ Kube.View {
297 } 297 }
298 } 298 }
299 299
300 Kube.TextArea { 300 Kube.TextEditor {
301 id: content
302 Layout.fillWidth: true 301 Layout.fillWidth: true
303 Layout.fillHeight: true 302 Layout.fillHeight: true
304 303 onActiveFocusChanged: closeFirstSplitIfNecessary()
305 selectByMouse: true
306
307 text: composerController.body 304 text: composerController.body
308 onTextChanged: composerController.body = text; 305 onTextChanged: composerController.body = text;
309 onActiveFocusChanged: closeFirstSplitIfNecessary()
310 } 306 }
311 } 307 }
312 } 308 }
diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml
new file mode 100644
index 00000000..c21f3748
--- /dev/null
+++ b/framework/qml/TextEditor.qml
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
3 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20import QtQuick 2.7
21import QtQuick.Controls 1.3
22
23import org.kube.framework 1.0 as Kube
24
25ScrollView {
26 id: root
27 property alias text: edit.text
28
29 Flickable {
30 id: flick
31
32 contentWidth: root.viewport.width
33 contentHeight: edit.height
34 clip: true
35
36 function ensureVisible(r)
37 {
38 if (contentX >= r.x)
39 contentX = r.x;
40 else if (contentX + width <= r.x + r.width)
41 contentX = r.x+r.width-width;
42 if (contentY >= r.y)
43 contentY = r.y;
44 else if (contentY + height <= r.y + r.height)
45 contentY = r.y+r.height-height;
46 }
47
48 Kube.TextArea {
49 id: edit
50 width: flick.width
51 height: edit.contentHeight > flick.height ? edit.contentHeight : flick.height
52 selectByMouse: true
53 onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
54 }
55 }
56}
diff --git a/framework/qmldir b/framework/qmldir
index 74f8a4af..4328548b 100644
--- a/framework/qmldir
+++ b/framework/qmldir
@@ -23,6 +23,7 @@ ComboBox 1.0 ComboBox.qml
23PositiveButton 1.0 PositiveButton.qml 23PositiveButton 1.0 PositiveButton.qml
24TextField 1.0 TextField.qml 24TextField 1.0 TextField.qml
25TextArea 1.0 TextArea.qml 25TextArea 1.0 TextArea.qml
26TextEditor 1.0 TextEditor.qml
26Label 1.0 Label.qml 27Label 1.0 Label.qml
27View 1.0 View.qml 28View 1.0 View.qml
28AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml 29AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml