Commit 30c2c8cd authored by Ronan Abhamon's avatar Ronan Abhamon

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

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