diff --git a/tests/resources.qrc b/tests/resources.qrc
index 6b4e52fc1..7e8f0e5f0 100644
--- a/tests/resources.qrc
+++ b/tests/resources.qrc
@@ -137,6 +137,7 @@
ui/modules/Common/Form/CheckBoxText.qml
ui/modules/Common/Form/ExclusiveButtons.qml
ui/modules/Common/Form/ListForm.qml
+ ui/modules/Common/Form/ScrollableTextEdit.qml
ui/modules/Common/Form/SmallButton.qml
ui/modules/Common/Form/TextButtonA.qml
ui/modules/Common/Form/TextButtonB.qml
diff --git a/tests/src/components/contacts/ContactModel.cpp b/tests/src/components/contacts/ContactModel.cpp
index 3f15e71ec..aba2ba51b 100644
--- a/tests/src/components/contacts/ContactModel.cpp
+++ b/tests/src/components/contacts/ContactModel.cpp
@@ -30,13 +30,12 @@ QString ContactModel::getUsername () const {
);
}
-bool ContactModel::setUsername (const QString &username) {
- if (username.length() == 0)
- return false;
+void ContactModel::setUsername (const QString &username) {
+ if (username.length() == 0 || username == getUsername())
+ return;
- return !m_linphone_friend->setName(
- Utils::qStringToLinphoneString(username)
- );
+ if (!m_linphone_friend->setName(Utils::qStringToLinphoneString(username)))
+ emit contactUpdated();
}
// -------------------------------------------------------------------
@@ -62,12 +61,12 @@ QString ContactModel::getAvatar () const {
));
}
-bool ContactModel::setAvatar (const QString &path) {
+void ContactModel::setAvatar (const QString &path) {
// 1. Try to copy photo in avatars folder.
QFile file(path);
if (!file.exists() || QImageReader::imageFormat(path).size() == 0)
- return false;
+ return;
QFileInfo info(file);
QString uuid = QUuid::createUuid().toString();
@@ -79,7 +78,7 @@ bool ContactModel::setAvatar (const QString &path) {
file_id;
if (!file.copy(dest))
- return false;
+ return;
qInfo() << QStringLiteral("Update avatar of `%1`. (path=%2)")
.arg(getUsername()).arg(dest);
@@ -116,7 +115,7 @@ bool ContactModel::setAvatar (const QString &path) {
emit contactUpdated();
- return true;
+ return;
}
// -------------------------------------------------------------------
diff --git a/tests/src/components/contacts/ContactModel.hpp b/tests/src/components/contacts/ContactModel.hpp
index 3768fa382..112c013f4 100644
--- a/tests/src/components/contacts/ContactModel.hpp
+++ b/tests/src/components/contacts/ContactModel.hpp
@@ -89,10 +89,10 @@ signals:
private:
QString getUsername () const;
- bool setUsername (const QString &username);
+ void setUsername (const QString &username);
QString getAvatar () const;
- bool setAvatar (const QString &path);
+ void setAvatar (const QString &path);
QVariantList getSipAddresses () const;
void setSipAddresses (const QVariantList &sip_addresses);
diff --git a/tests/ui/modules/Common/Form/ScrollableTextEdit.qml b/tests/ui/modules/Common/Form/ScrollableTextEdit.qml
new file mode 100644
index 000000000..b7bca766b
--- /dev/null
+++ b/tests/ui/modules/Common/Form/ScrollableTextEdit.qml
@@ -0,0 +1,83 @@
+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 editionFinished
+
+ // -----------------------------------------------------------------
+
+ function _handleEditionFinished () {
+ textEdit.cursorPosition = 0
+ editionFinished()
+ }
+
+ // -----------------------------------------------------------------
+
+ Rectangle {
+ anchors.fill: flick
+ color: textEdit.activeFocus && !textEdit.readOnly
+ ? TextEditStyle.backgroundColor.focused
+ : TextEditStyle.backgroundColor.normal
+
+ 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
+ ? TextEditStyle.textColor.focused
+ : TextEditStyle.textColor.normal
+ padding: ListFormStyle.value.text.padding
+ selectByMouse: true
+ wrapMode: Text.Wrap
+
+ Keys.onEscapePressed: focus = false
+ Keys.onReturnPressed: focus = false
+
+ height: flick.height
+ width: flick.width
+
+ onCursorRectangleChanged: flick._ensureVisible(cursorRectangle)
+ onEditingFinished: _handleEditionFinished()
+ }
+ }
+}
diff --git a/tests/ui/modules/Common/Form/TextEdit.qml b/tests/ui/modules/Common/Form/TextEdit.qml
index 2ab19951d..90e2cf4e4 100644
--- a/tests/ui/modules/Common/Form/TextEdit.qml
+++ b/tests/ui/modules/Common/Form/TextEdit.qml
@@ -8,16 +8,13 @@ import Common.Styles 1.0
TextEdit {
id: textEdit
- color: activeFocus
+ color: activeFocus && !readOnly
? TextEditStyle.textColor.focused
: TextEditStyle.textColor.normal
padding: ListFormStyle.value.text.padding
selectByMouse: true
verticalAlignment: TextEdit.AlignVCenter
-
- width: !activeFocus
- ? parent.width
- : contentWidth + padding * 2
+ wrapMode: Text.Wrap
Keys.onEscapePressed: focus = false
Keys.onReturnPressed: focus = false
@@ -29,9 +26,10 @@ TextEdit {
}
Rectangle {
- color: parent.activeFocus
+ anchors.fill: textEdit
+ color: textEdit.activeFocus && !readOnly
? TextEditStyle.backgroundColor.focused
: TextEditStyle.backgroundColor.normal
- anchors.fill: parent
+ z: -1
}
}
diff --git a/tests/ui/modules/Common/qmldir b/tests/ui/modules/Common/qmldir
index 1eec559b3..a2616c12e 100644
--- a/tests/ui/modules/Common/qmldir
+++ b/tests/ui/modules/Common/qmldir
@@ -38,6 +38,7 @@ 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
TextEdit 1.0 Form/TextEdit.qml
diff --git a/tests/ui/modules/Linphone/Chat/Message.qml b/tests/ui/modules/Linphone/Chat/Message.qml
index 1f7c057bd..6dff4a01c 100644
--- a/tests/ui/modules/Linphone/Chat/Message.qml
+++ b/tests/ui/modules/Linphone/Chat/Message.qml
@@ -70,8 +70,6 @@ Item {
// and http://doc.qt.io/qt-5/richtext-html-subset.html
textFormat: Text.RichText // To supports links and imgs.
- wrapMode: Text.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 f8cb48354..567f5f407 100644
--- a/tests/ui/views/App/MainWindow/ContactEdit.qml
+++ b/tests/ui/views/App/MainWindow/ContactEdit.qml
@@ -96,8 +96,12 @@ ColumnLayout {
}
}
- TextEdit {
+ ScrollableTextEdit {
+ id: editUsername
+
Layout.fillWidth: true
+ Layout.preferredHeight: ContactEditStyle.infoBar.buttons.size
+
color: ContactEditStyle.infoBar.username.color
font {
@@ -106,6 +110,11 @@ ColumnLayout {
}
text: avatar.username
+
+ onEditionFinished: {
+ _contact.username = text
+ text = _contact.username
+ }
}
ActionBar {