diff --git a/tests/ui/modules/Linphone/Chat/Message.qml b/tests/ui/modules/Linphone/Chat/Message.qml index 8304724ca..76f97e9e7 100644 --- a/tests/ui/modules/Linphone/Chat/Message.qml +++ b/tests/ui/modules/Linphone/Chat/Message.qml @@ -12,10 +12,28 @@ Item { property alias backgroundColor: rectangle.color property alias color: text.color property alias fontSize: text.font.pointSize + default property alias _content: content.data // ----------------------------------------------------------------- + function _handleHoveredLink (hoveredLink) { + var root = Utils.getTopParent(container) + var children = root.children + + // Can be the `invertedMouseArea` of other message. + // Or another? It's a problem in this case... + var mouseArea = children[children.length - 1] + + if (Utils.qmlTypeof(mouseArea, 'QQuickMouseArea')) { + mouseArea.cursorShape = hoveredLink + ? Qt.PointingHandCursor + : Qt.ArrowCursor + } + } + + // ----------------------------------------------------------------- + implicitHeight: text.contentHeight + text.padding * 2 Rectangle { @@ -45,21 +63,15 @@ Item { imagesHeight: ChatStyle.entry.message.images.height, imagesWidth: ChatStyle.entry.message.images.width }) - wrapMode: Text.Wrap // 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. - onLinkActivated: Qt.openUrlExternally(link) + wrapMode: Text.Wrap - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.NoButton - cursorShape: parent.hoveredLink - ? Qt.PointingHandCursor - : Qt.ArrowCursor - } + onHoveredLinkChanged: _handleHoveredLink(hoveredLink) + onLinkActivated: Qt.openUrlExternally(link) InvertedMouseArea { anchors.fill: parent @@ -70,6 +82,17 @@ Item { parent.focus = false } } + + // Used if no InvertedMouseArea exists. + MouseArea { + id: mouseArea + + anchors.fill: parent + acceptedButtons: Qt.NoButton + cursorShape: parent.hoveredLink + ? Qt.PointingHandCursor + : Qt.ArrowCursor + } } Item { diff --git a/tests/ui/scripts/Utils/utils.spec.qml b/tests/ui/scripts/Utils/utils.spec.qml index c88872f5f..bc6653799 100644 --- a/tests/ui/scripts/Utils/utils.spec.qml +++ b/tests/ui/scripts/Utils/utils.spec.qml @@ -117,11 +117,14 @@ TestCase { component: 'import QtQuick 2.7; ListModel {}', result: true, type: 'QQmlListModel' - }, - { + }, { component: 'import QtQuick 2.7; ListView {}', result: true, type: 'QQuickListView' + }, { + component: 'import QtQuick 2.7; MouseArea {}', + result: true, + type: 'QQuickMouseArea' } ] }