From 6025a2856ea086b9c226a08a4821bedcf29501d4 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 23 Jun 2017 00:44:12 +0200 Subject: Use the implcit flickable to simplify the code --- framework/qml/TextEditor.qml | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'framework') diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml index 9c2298b6..0ef91157 100644 --- a/framework/qml/TextEditor.qml +++ b/framework/qml/TextEditor.qml @@ -26,30 +26,24 @@ ScrollView { id: root property alias text: edit.text - Flickable { - id: flick + horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff - contentWidth: root.viewport.width - contentHeight: Math.max(edit.contentHeight + edit.topPadding + edit.bottomPadding, flick.height) - clip: true - - function ensureVisible(r) - { - if (contentY >= r.y) - contentY = r.y; - else if (contentY + height <= r.y + r.height) - contentY = r.y+r.height-height; - } + function ensureVisible(r) + { + if (flickableItem.contentY >= r.y) + flickableItem.contentY = r.y; + else if (flickableItem.contentY + height <= r.y + r.height) + flickableItem.contentY = r.y + r.height - height + edit.padding; + } - Kube.TextArea { - //TODO drop all sizes and use the following once we have qt 5.9 - // Controls2.TextArea.flickable: Kube.TextArea { - id: edit - width: flick.contentWidth - edit.leftPadding - edit.rightPadding - height: flick.contentHeight - selectByMouse: true - onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) - wrapMode: TextEdit.Wrap - } + Kube.TextArea { + //TODO drop all sizes and use the following once we have qt 5.9 + // Controls2.TextArea.flickable: Kube.TextArea { + id: edit + width: root.viewport.width + height: Math.max(edit.contentHeight + edit.topPadding + edit.bottomPadding, root.height) + selectByMouse: true + onCursorRectangleChanged: root.ensureVisible(cursorRectangle) + wrapMode: TextEdit.Wrap } } -- cgit v1.2.3