diff --git a/tests/resources.qrc b/tests/resources.qrc index 7e8f0e5f0..f8e7dd302 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -141,9 +141,9 @@ ui/modules/Common/Form/SmallButton.qml ui/modules/Common/Form/TextButtonA.qml ui/modules/Common/Form/TextButtonB.qml - ui/modules/Common/Form/TextEdit.qml ui/modules/Common/Form/TextField.qml ui/modules/Common/Form/TransparentComboBox.qml + ui/modules/Common/Form/TransparentTextInput.qml ui/modules/Common/Image/Icon.qml ui/modules/Common/Image/RoundedImage.qml ui/modules/Common/InvertedMouseArea.qml @@ -171,9 +171,9 @@ ui/modules/Common/Styles/Form/SmallButtonStyle.qml ui/modules/Common/Styles/Form/TextButtonAStyle.qml ui/modules/Common/Styles/Form/TextButtonBStyle.qml - ui/modules/Common/Styles/Form/TextEditStyle.qml ui/modules/Common/Styles/Form/TextFieldStyle.qml ui/modules/Common/Styles/Form/TransparentComboBoxStyle.qml + ui/modules/Common/Styles/Form/TransparentTextInputStyle.qml ui/modules/Common/Styles/Menu/ActionMenuStyle.qml ui/modules/Common/Styles/Menu/MenuStyle.qml ui/modules/Common/Styles/PanedStyle.qml diff --git a/tests/ui/modules/Common/Form/ListForm.qml b/tests/ui/modules/Common/Form/ListForm.qml index 5f18caa73..d0e9e2524 100644 --- a/tests/ui/modules/Common/Form/ListForm.qml +++ b/tests/ui/modules/Common/Form/ListForm.qml @@ -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() }) } } diff --git a/tests/ui/modules/Common/Form/ScrollableTextEdit.qml b/tests/ui/modules/Common/Form/ScrollableTextEdit.qml index 78a874f4c..5308b9df3 100644 --- a/tests/ui/modules/Common/Form/ScrollableTextEdit.qml +++ b/tests/ui/modules/Common/Form/ScrollableTextEdit.qml @@ -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 diff --git a/tests/ui/modules/Common/Form/TextEdit.qml b/tests/ui/modules/Common/Form/TextEdit.qml deleted file mode 100644 index b4e0f22e2..000000000 --- a/tests/ui/modules/Common/Form/TextEdit.qml +++ /dev/null @@ -1,35 +0,0 @@ -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 - } -} diff --git a/tests/ui/modules/Common/Form/TextField.qml b/tests/ui/modules/Common/Form/TextField.qml index 2882baa16..fef84d566 100644 --- a/tests/ui/modules/Common/Form/TextField.qml +++ b/tests/ui/modules/Common/Form/TextField.qml @@ -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 { diff --git a/tests/ui/modules/Common/Form/TransparentTextInput.qml b/tests/ui/modules/Common/Form/TransparentTextInput.qml new file mode 100644 index 000000000..bc24cf2c2 --- /dev/null +++ b/tests/ui/modules/Common/Form/TransparentTextInput.qml @@ -0,0 +1,57 @@ +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 + } + } +} diff --git a/tests/ui/modules/Common/Styles/Form/ListFormStyle.qml b/tests/ui/modules/Common/Styles/Form/ListFormStyle.qml index 0020f401a..26482e672 100644 --- a/tests/ui/modules/Common/Styles/Form/ListFormStyle.qml +++ b/tests/ui/modules/Common/Styles/Form/ListFormStyle.qml @@ -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 { diff --git a/tests/ui/modules/Common/Styles/Form/TextEditStyle.qml b/tests/ui/modules/Common/Styles/Form/TransparentTextInputStyle.qml similarity index 57% rename from tests/ui/modules/Common/Styles/Form/TextEditStyle.qml rename to tests/ui/modules/Common/Styles/Form/TransparentTextInputStyle.qml index 6a0683a2f..bcb0490a1 100644 --- a/tests/ui/modules/Common/Styles/Form/TextEditStyle.qml +++ b/tests/ui/modules/Common/Styles/Form/TransparentTextInputStyle.qml @@ -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 } } diff --git a/tests/ui/modules/Common/Styles/qmldir b/tests/ui/modules/Common/Styles/qmldir index aa1c2a93e..068db0c23 100644 --- a/tests/ui/modules/Common/Styles/qmldir +++ b/tests/ui/modules/Common/Styles/qmldir @@ -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 diff --git a/tests/ui/modules/Common/qmldir b/tests/ui/modules/Common/qmldir index a2616c12e..7ae66dc1d 100644 --- a/tests/ui/modules/Common/qmldir +++ b/tests/ui/modules/Common/qmldir @@ -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 diff --git a/tests/ui/modules/Linphone/Chat/Message.qml b/tests/ui/modules/Linphone/Chat/Message.qml index 6dff4a01c..8a59e98c6 100644 --- a/tests/ui/modules/Linphone/Chat/Message.qml +++ b/tests/ui/modules/Linphone/Chat/Message.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) diff --git a/tests/ui/views/App/MainWindow/ContactEdit.qml b/tests/ui/views/App/MainWindow/ContactEdit.qml index 718e19f50..9c9994dc4 100644 --- a/tests/ui/views/App/MainWindow/ContactEdit.qml +++ b/tests/ui/views/App/MainWindow/ContactEdit.qml @@ -96,7 +96,7 @@ ColumnLayout { } } - ScrollableTextEdit { + TransparentTextInput { id: editUsername Layout.fillWidth: true