diff --git a/tests/assets/images/tooltip_arrow_bottom.svg b/tests/assets/images/tooltip_arrow_bottom.svg new file mode 100644 index 000000000..3205ed696 --- /dev/null +++ b/tests/assets/images/tooltip_arrow_bottom.svg @@ -0,0 +1,12 @@ + + + + tooltip + Created with Sketch. + + + + + + + diff --git a/tests/assets/images/tooltip_arrow_left.svg b/tests/assets/images/tooltip_arrow_left.svg new file mode 100644 index 000000000..c36e5603e --- /dev/null +++ b/tests/assets/images/tooltip_arrow_left.svg @@ -0,0 +1,12 @@ + + + + tooltip + Created with Sketch. + + + + + + + diff --git a/tests/assets/images/tooltip_arrow_right.svg b/tests/assets/images/tooltip_arrow_right.svg new file mode 100644 index 000000000..d0b37ee47 --- /dev/null +++ b/tests/assets/images/tooltip_arrow_right.svg @@ -0,0 +1,12 @@ + + + + tooltip + Created with Sketch. + + + + + + + diff --git a/tests/assets/images/tooltip_arrow.svg b/tests/assets/images/tooltip_arrow_top.svg similarity index 100% rename from tests/assets/images/tooltip_arrow.svg rename to tests/assets/images/tooltip_arrow_top.svg diff --git a/tests/resources.qrc b/tests/resources.qrc index debd8b59e..25a283df0 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -40,7 +40,10 @@ assets/images/lost_outgoing_call.svg assets/images/outgoing_call.svg assets/images/search.svg - assets/images/tooltip_arrow.svg + assets/images/tooltip_arrow_bottom.svg + assets/images/tooltip_arrow_left.svg + assets/images/tooltip_arrow_right.svg + assets/images/tooltip_arrow_top.svg assets/images/video_call_hovered.svg assets/images/video_call_normal.svg assets/images/video_call_pressed.svg diff --git a/tests/ui/modules/Common/Tooltip/Tooltip.qml b/tests/ui/modules/Common/Tooltip/Tooltip.qml index c95a6306a..dfd62b904 100644 --- a/tests/ui/modules/Common/Tooltip/Tooltip.qml +++ b/tests/ui/modules/Common/Tooltip/Tooltip.qml @@ -3,22 +3,31 @@ import QtQuick.Controls 2.0 import Common 1.0 import Common.Styles 1.0 +import Utils 1.0 // =================================================================== ToolTip { id: tooltip + property string _edge: 'left' + + // ----------------------------------------------------------------- + function _getArrowHeightMargin () { - return icon.height > icon.implicitHeight - ? (icon.height - icon.implicitHeight) / 2 - : icon.height + Utils.assert( + icon.height >= icon.implicitHeight, + '`icon.height` must be lower than `icon.implicitHeight`.' + ) + return (icon.height - icon.implicitHeight) / 2 } function _getArrowWidthMargin () { - return icon.width > icon.implicitWidth - ? (icon.width - icon.implicitWidth) / 2 - : icon.width + Utils.assert( + icon.width >= icon.implicitWidth, + '`icon.width` must be lower than `icon.implicitWidth`.' + ) + return (icon.width - icon.implicitWidth) / 2 } function _getRelativeXArrowCenter () { @@ -29,38 +38,41 @@ ToolTip { return tooltip.parent.height / 2 - icon.height / 2 } + function _setArrowEdge () { + var a = container.mapToItem(null, 0, 0) + var b = tooltip.parent.mapToItem(null, 0, 0) + + if (a.x + container.width < b.x) { + _edge = 'left' + } else if (a.x > b.x + container.width) { + _edge = 'right' + } else if (a.y + container.height < b.y) { + _edge = 'top' + } else if (a.y > b.y + b.height) { + _edge = 'bottom' + } else { + console.warn('Unable to get the tooltip arrow position.') + } + } + + // Called when new image is loaded. (When the is edge is updated.) function _setArrowPosition () { var a = container.mapToItem(null, 0, 0) var b = tooltip.parent.mapToItem(null, 0, 0) - // Left. - if (a.x + container.width < b.x) { + if (_edge === 'left') { icon.x = container.width - TooltipStyle.margins - _getArrowWidthMargin() icon.y = b.y - a.y + _getRelativeYArrowCenter() - } - - // Right. - else if (a.x > b.x + container.width) { + } else if (_edge === 'right') { icon.x = container.width + TooltipStyle.margins + _getArrowWidthMargin() icon.y = b.y - a.y + _getRelativeYArrowCenter() - } - - // Top. - else if (a.y + container.height < b.y) { + } else if (_edge === 'top') { icon.x = b.x - a.x + _getRelativeXArrowCenter() icon.y = container.height - TooltipStyle.margins - _getArrowHeightMargin() - } - - // Bottom. - else if (a.y > b.y + b.height) { + } else if (_edge === 'bottom') { icon.x = b.x - a.x + _getRelativeXArrowCenter() icon.y = container.height + TooltipStyle.margins + _getArrowHeightMargin() } - - // Error? - else { - throw new Error('Unable to get the tooltip arrow position') - } } // ----------------------------------------------------------------- @@ -84,10 +96,14 @@ ToolTip { fillMode: Image.PreserveAspectFit height: TooltipStyle.arrowSize - source: Constants.imagesPath + 'tooltip_arrow' + Constants.imagesFormat - visible: tooltip.visible + source: Constants.imagesPath + + 'tooltip_arrow_' + _edge + + Constants.imagesFormat + visible: tooltip.visible && _edge width: TooltipStyle.arrowSize z: Constants.zMax + + onStatusChanged: status === Image.Ready && _setArrowPosition() } } @@ -102,5 +118,5 @@ ToolTip { delay: TooltipStyle.delay - onVisibleChanged: visible && _setArrowPosition() + onVisibleChanged: visible && _setArrowEdge() } diff --git a/tests/ui/modules/Linphone/Chat/Chat.qml b/tests/ui/modules/Linphone/Chat/Chat.qml index c1c9a60af..ac3182b7b 100644 --- a/tests/ui/modules/Linphone/Chat/Chat.qml +++ b/tests/ui/modules/Linphone/Chat/Chat.qml @@ -162,7 +162,8 @@ ColumnLayout { // TMP model: ListModel { - ListElement { $dateSection: 1465389121000; $outgoing: true; $timestamp: 1465389121000; $type: 'message'; $content: 'This is it: fefe efzzzzzzzzzz aaaaaaaaa erfeezffeefzfzefzefzezfefez wfef efef e efeffefe fee efefefeefef fefefefefe eff fefefe fefeffww.linphone.org' } + ListElement { $dateSection: 1465389121000; $outgoing: true; $timestamp: 1465389121000; $type: 'message'; $content: "click here" } + ListElement { $dateSection: 1465389121000; $outgoing: true; $timestamp: 1465389121000; $type: 'message'; $content: "Contact mail" } ListElement { $dateSection: 1465389121000; $timestamp: 1465389133000; $type: 'event'; $content: 'incoming_call' } ListElement { $dateSection: 1465389121000; $timestamp: 1465389439000; $type: 'message'; $content: 'Perfect! bg g vg gv v g v hgv gv gv jhb jh b jb jh hg vg cfcy f v u uyg f tf tf ft f tf t t fy ft f tu ty f rd rd d d uu gu y gg y f r dr ' } ListElement { $dateSection: 1465389121000; $timestamp: 1465389500000; $type: 'event'; $content: 'end_call' } diff --git a/tests/ui/modules/Linphone/Chat/Message.qml b/tests/ui/modules/Linphone/Chat/Message.qml index 94e3181a2..2ce65eb84 100644 --- a/tests/ui/modules/Linphone/Chat/Message.qml +++ b/tests/ui/modules/Linphone/Chat/Message.qml @@ -41,6 +41,16 @@ Item { // Little fix. Text may disappear with scrolling. renderType: Text.NativeRendering + + onLinkActivated: Qt.openUrlExternally(link) + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton + cursorShape: parent.hoveredLink + ? Qt.PointingHandCursor + : Qt.ArrowCursor + } } Item {