diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-14 05:00:05 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-15 20:14:48 +0200 |
commit | d2e9a7f4b20bf59bc01fb577b72a42250ae335ce (patch) | |
tree | e7347605cb7f42793118e7b6be0f6548f2edd0e1 /framework/qml/TextEditor.qml | |
parent | 142cfea2ee8b50b5ef2e22b9de4fe4c461411ff2 (diff) | |
download | kube-d2e9a7f4b20bf59bc01fb577b72a42250ae335ce.tar.gz kube-d2e9a7f4b20bf59bc01fb577b72a42250ae335ce.zip |
A scrollable texteditor
Diffstat (limited to 'framework/qml/TextEditor.qml')
-rw-r--r-- | framework/qml/TextEditor.qml | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml index 0ef91157..d80bebb9 100644 --- a/framework/qml/TextEditor.qml +++ b/framework/qml/TextEditor.qml | |||
@@ -18,32 +18,25 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | import QtQuick 2.7 | 20 | import QtQuick 2.7 |
21 | import QtQuick.Controls 1.3 | 21 | import QtQuick.Controls 2.2 |
22 | 22 | ||
23 | import org.kube.framework 1.0 as Kube | 23 | import org.kube.framework 1.0 as Kube |
24 | 24 | ||
25 | ScrollView { | 25 | Kube.ScrollHelper { |
26 | id: root | 26 | id: scrollHelper |
27 | property alias text: edit.text | 27 | property alias text: edit.text |
28 | flickable: root | ||
29 | Flickable { | ||
30 | id: root | ||
31 | anchors.fill: parent | ||
32 | ScrollBar.vertical: ScrollBar {} | ||
28 | 33 | ||
29 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | 34 | Kube.TextArea { |
30 | 35 | id: edit | |
31 | function ensureVisible(r) | 36 | anchors.fill: parent |
32 | { | 37 | selectByMouse: true |
33 | if (flickableItem.contentY >= r.y) | 38 | wrapMode: TextEdit.Wrap |
34 | flickableItem.contentY = r.y; | 39 | } |
35 | else if (flickableItem.contentY + height <= r.y + r.height) | 40 | TextArea.flickable: edit |
36 | flickableItem.contentY = r.y + r.height - height + edit.padding; | ||
37 | } | ||
38 | |||
39 | Kube.TextArea { | ||
40 | //TODO drop all sizes and use the following once we have qt 5.9 | ||
41 | // Controls2.TextArea.flickable: Kube.TextArea { | ||
42 | id: edit | ||
43 | width: root.viewport.width | ||
44 | height: Math.max(edit.contentHeight + edit.topPadding + edit.bottomPadding, root.height) | ||
45 | selectByMouse: true | ||
46 | onCursorRectangleChanged: root.ensureVisible(cursorRectangle) | ||
47 | wrapMode: TextEdit.Wrap | ||
48 | } | 41 | } |
49 | } | 42 | } |