Commit 30c2c8cd authored by Ronan's avatar Ronan
Browse files

feat(ui/views/App/MainWindow/ContactEdit): use a custom transparent text input

parent 93c88e8a
......@@ -141,9 +141,9 @@
<file>ui/modules/Common/Form/SmallButton.qml</file>
<file>ui/modules/Common/Form/TextButtonA.qml</file>
<file>ui/modules/Common/Form/TextButtonB.qml</file>
<file>ui/modules/Common/Form/TextEdit.qml</file>
<file>ui/modules/Common/Form/TextField.qml</file>
<file>ui/modules/Common/Form/TransparentComboBox.qml</file>
<file>ui/modules/Common/Form/TransparentTextInput.qml</file>
<file>ui/modules/Common/Image/Icon.qml</file>
<file>ui/modules/Common/Image/RoundedImage.qml</file>
<file>ui/modules/Common/InvertedMouseArea.qml</file>
......@@ -171,9 +171,9 @@
<file>ui/modules/Common/Styles/Form/SmallButtonStyle.qml</file>
<file>ui/modules/Common/Styles/Form/TextButtonAStyle.qml</file>
<file>ui/modules/Common/Styles/Form/TextButtonBStyle.qml</file>
<file>ui/modules/Common/Styles/Form/TextEditStyle.qml</file>
<file>ui/modules/Common/Styles/Form/TextFieldStyle.qml</file>
<file>ui/modules/Common/Styles/Form/TransparentComboBoxStyle.qml</file>
<file>ui/modules/Common/Styles/Form/TransparentTextInputStyle.qml</file>
<file>ui/modules/Common/Styles/Menu/ActionMenuStyle.qml</file>
<file>ui/modules/Common/Styles/Menu/MenuStyle.qml</file>
<file>ui/modules/Common/Styles/PanedStyle.qml</file>
......
......@@ -109,14 +109,14 @@ RowLayout {
visible: model.count > 0
delegate: Item {
implicitHeight: textEdit.height
implicitHeight: textInput.height
width: parent.width
TextEdit {
id: textEdit
TransparentTextInput {
id: textInput
text: $value
width: 300
width: parent.width
height: ListFormStyle.lineHeight
onEditingFinished: _handleEditionFinished(index, text)
......@@ -131,7 +131,7 @@ RowLayout {
// So, I choose to run a callback executed after this
// internal event.
Utils.setTimeout(listForm, 0, function () {
textEdit.forceActiveFocus()
textInput.forceActiveFocus()
})
}
}
......
......@@ -25,8 +25,8 @@ Item {
Rectangle {
anchors.fill: flick
color: textEdit.activeFocus && !textEdit.readOnly
? TextEditStyle.backgroundColor.focused
: TextEditStyle.backgroundColor.normal
? TransparentTextInputStyle.backgroundColor.focused
: 'transparent'
InvertedMouseArea {
anchors.fill: parent
......@@ -64,8 +64,8 @@ Item {
id: textEdit
color: activeFocus && !readOnly
? TextEditStyle.textColor.focused
: TextEditStyle.textColor.normal
? TransparentTextInputStyle.textColor.focused
: TransparentTextInputStyle.textColor.normal
selectByMouse: true
width: flick.width
wrapMode: Text.Wrap
......
import QtQuick 2.7
import Common 1.0
import Common.Styles 1.0
// ===================================================================
TextInput {
id: textEdit
clip: true
color: activeFocus && !readOnly
? TextEditStyle.textColor.focused
: TextEditStyle.textColor.normal
padding: ListFormStyle.value.text.padding
selectByMouse: true
verticalAlignment: TextEdit.AlignVCenter
Keys.onEscapePressed: focus = false
Keys.onReturnPressed: focus = false
InvertedMouseArea {
anchors.fill: parent
enabled: textEdit.activeFocus
onPressed: textEdit.focus = false
}
Rectangle {
anchors.fill: textEdit
color: textEdit.activeFocus && !readOnly
? TextEditStyle.backgroundColor.focused
: TextEditStyle.backgroundColor.normal
z: -1
}
}
......@@ -4,6 +4,8 @@ import QtQuick.Controls 2.0 as Controls
import Common 1.0
import Common.Styles 1.0
// ===================================================================
// A classic TextInput which supports an icon attribute.
// ===================================================================
Controls.TextField {
......
import QtQuick 2.7
import Common 1.0
import Common.Styles 1.0
// ===================================================================
Item {
property alias color: textInput.color
property alias font: textInput.font
property alias readOnly: textInput.readOnly
property alias text: textInput.text
property int padding: TransparentTextInputStyle.padding
signal editingFinished
// -----------------------------------------------------------------
Rectangle {
anchors.fill: parent
color: textInput.activeFocus && !readOnly
? TransparentTextInputStyle.backgroundColor
: // No Style constant, see component name.
// It's a `transparent` TextInput.
'transparent'
z: -1
}
TextInput {
id: textInput
anchors.centerIn: parent
height: parent.height - parent.padding * 2
width: parent.width - parent.padding * 2
clip: true
color: activeFocus && !readOnly
? TransparentTextInputStyle.textColor.focused
: TransparentTextInputStyle.textColor.normal
selectByMouse: true
verticalAlignment: TextInput.AlignVCenter
Keys.onEscapePressed: focus = false
Keys.onReturnPressed: focus = false
onEditingFinished: {
cursorPosition = 0
parent.editingFinished()
}
InvertedMouseArea {
anchors.fill: parent
enabled: textInput.activeFocus
onPressed: textInput.focus = false
}
}
}
......@@ -6,7 +6,7 @@ import Common 1.0
// ===================================================================
QtObject {
property int lineHeight: 30
property int lineHeight: 35
property QtObject value: QtObject {
property QtObject placeholder: QtObject {
......
......@@ -6,13 +6,11 @@ import Common 1.0
// ===================================================================
QtObject {
property QtObject backgroundColor: QtObject {
property color focused: Colors.q
property color normal: Colors.a
}
property color backgroundColor: Colors.q
property int padding: 10
property QtObject textColor: QtObject {
property color focused: Colors.l
property color focused: Colors.l
property color normal: Colors.r
}
}
......@@ -22,9 +22,9 @@ singleton ListFormStyle 1.0 Form/ListFormStyle.qml
singleton SmallButtonStyle 1.0 Form/SmallButtonStyle.qml
singleton TextButtonAStyle 1.0 Form/TextButtonAStyle.qml
singleton TextButtonBStyle 1.0 Form/TextButtonBStyle.qml
singleton TextEditStyle 1.0 Form/TextEditStyle.qml
singleton TextFieldStyle 1.0 Form/TextFieldStyle.qml
singleton TransparentComboBoxStyle 1.0 Form/TransparentComboBoxStyle.qml
singleton TransparentTextInputStyle 1.0 Form/TransparentTextInputStyle.qml
singleton ActionMenuStyle 1.0 Menu/ActionMenuStyle.qml
singleton MenuStyle 1.0 Menu/MenuStyle.qml
......
......@@ -41,9 +41,9 @@ ListForm 1.0 Form/ListForm.qml
ScrollableTextEdit 1.0 Form/ScrollableTextEdit.qml
TextButtonA 1.0 Form/TextButtonA.qml
TextButtonB 1.0 Form/TextButtonB.qml
TextEdit 1.0 Form/TextEdit.qml
TextField 1.0 Form/TextField.qml
TransparentComboBox 1.0 Form/TransparentComboBox.qml
TransparentTextInput 1.0 Form/TransparentTextInput.qml
# Image
Icon 1.0 Image/Icon.qml
......
......@@ -69,6 +69,7 @@ Item {
// See http://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop
// and http://doc.qt.io/qt-5/richtext-html-subset.html
textFormat: Text.RichText // To supports links and imgs.
wrapMode: TextEdit.Wrap
onHoveredLinkChanged: _handleHoveredLink(hoveredLink)
onLinkActivated: Qt.openUrlExternally(link)
......
......@@ -96,7 +96,7 @@ ColumnLayout {
}
}
ScrollableTextEdit {
TransparentTextInput {
id: editUsername
Layout.fillWidth: true
......
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