Commit ab7a8659 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): remove `ScrollableTextEdit` component

parent 30c2c8cd
......@@ -137,7 +137,6 @@
<file>ui/modules/Common/Form/CheckBoxText.qml</file>
<file>ui/modules/Common/Form/ExclusiveButtons.qml</file>
<file>ui/modules/Common/Form/ListForm.qml</file>
<file>ui/modules/Common/Form/ScrollableTextEdit.qml</file>
<file>ui/modules/Common/Form/SmallButton.qml</file>
<file>ui/modules/Common/Form/TextButtonA.qml</file>
<file>ui/modules/Common/Form/TextButtonB.qml</file>
......
import QtQuick 2.7
import QtQuick 2.7 as Quick
import Common 1.0
import Common.Styles 1.0
// ===================================================================
Item {
property alias text: textEdit.text
property alias font: textEdit.font
property alias color: textEdit.color
signal editingFinished
// -----------------------------------------------------------------
function _handleEditingFinished () {
textEdit.cursorPosition = 0
editingFinished()
}
// -----------------------------------------------------------------
Rectangle {
anchors.fill: flick
color: textEdit.activeFocus && !textEdit.readOnly
? TransparentTextInputStyle.backgroundColor.focused
: 'transparent'
InvertedMouseArea {
anchors.fill: parent
enabled: textEdit.activeFocus
onPressed: textEdit.focus = false
}
}
Flickable {
id: flick
// See: http://doc.qt.io/qt-5/qml-qtquick-texttextEdit.html
function _ensureVisible (r) {
if (contentX >= r.x) {
contentX = r.x
} else if (contentX + width <= r.x + r.width) {
contentX = r.x + r.width - width
}
if (contentY >= r.y) {
contentY = r.y
} else if (contentY + height <= r.y + r.height) {
contentY = r.y + r.height - height
}
}
anchors.fill: parent
boundsBehavior: Flickable.StopAtBounds
clip: true
contentHeight: textEdit.paintedHeight
contentWidth: textEdit.paintedWidth
interactive: textEdit.activeFocus
Quick.TextEdit {
id: textEdit
color: activeFocus && !readOnly
? TransparentTextInputStyle.textColor.focused
: TransparentTextInputStyle.textColor.normal
selectByMouse: true
width: flick.width
wrapMode: Text.Wrap
Keys.onEscapePressed: focus = false
Keys.onReturnPressed: focus = false
onCursorRectangleChanged: flick._ensureVisible(cursorRectangle)
onEditingFinished: _handleEditingFinished()
}
}
}
......@@ -3,6 +3,8 @@ import QtQuick 2.7
import Common 1.0
import Common.Styles 1.0
// ===================================================================
// A editable text that become the content of a box on focus.
// ===================================================================
Item {
......
......@@ -38,7 +38,6 @@ CheckBoxText 1.0 Form/CheckBoxText.qml
ExclusiveButtons 1.0 Form/ExclusiveButtons.qml
LightButton 1.0 Form/LightButton.qml
ListForm 1.0 Form/ListForm.qml
ScrollableTextEdit 1.0 Form/ScrollableTextEdit.qml
TextButtonA 1.0 Form/TextButtonA.qml
TextButtonB 1.0 Form/TextButtonB.qml
TextField 1.0 Form/TextField.qml
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment