From 075aa6f948eb5b0e89afcbe0b34fe4699b5ab71d Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 11 Aug 2021 12:34:09 +0200 Subject: [PATCH] Tooltip delay at 0 for avatar in chat --- .../ui/modules/Common/Tooltip/TooltipArea.qml | 112 +++++++++++------- .../ui/modules/Linphone/Chat/Chat.qml | 1 + .../modules/Linphone/Chat/IncomingMessage.qml | 1 + 3 files changed, 70 insertions(+), 44 deletions(-) diff --git a/linphone-app/ui/modules/Common/Tooltip/TooltipArea.qml b/linphone-app/ui/modules/Common/Tooltip/TooltipArea.qml index b575d18d2..99e29f085 100644 --- a/linphone-app/ui/modules/Common/Tooltip/TooltipArea.qml +++ b/linphone-app/ui/modules/Common/Tooltip/TooltipArea.qml @@ -6,48 +6,72 @@ import Common.Styles 1.0 // ============================================================================= MouseArea { - id: tooltipArea - - property alias text: tooltip.text - property int delay: TooltipStyle.delay - property bool force: false - property var tooltipParent: parent - property int maxWidth : tooltipParent.width - - property bool _visible: false - property int hoveringCursor : Qt.PointingHandCursor - - anchors.fill:parent - - hoverEnabled: true - scrollGestureEnabled: true - - onContainsMouseChanged: _visible = containsMouse - cursorShape: containsMouse ? hoveringCursor : Qt.ArrowCursor - - onPressed: mouse.accepted = false - onWheel: { - _visible = false - wheel.accepted = false - } - - Tooltip { - id: tooltip - - delay: tooltipArea.delay - parent: tooltipParent - visible: _visible || force - width: Math.min(tooltip.implicitWidth, Math.max(tooltipArea.maxWidth, TooltipStyle.minWidth)) - - //tooltipParent.width>TooltipStyle.minWidth?tooltipParent.width:TooltipStyle.minWidth - - timeout: -1 - - // Workaround to always display tooltip. - onVisibleChanged: { - if (!visible && force) { - tooltip.visible = true - } - } - } + id: tooltipArea + + property alias text: tooltip.text + property int delay: TooltipStyle.delay + property bool force: false + property var tooltipParent: parent + property int maxWidth : tooltipParent.width + + property bool _visible: false + property int hoveringCursor : Qt.PointingHandCursor + property bool isClickable : true + + anchors.fill:parent + + hoverEnabled: true + scrollGestureEnabled: true + + onContainsMouseChanged: _visible = containsMouse + cursorShape: containsMouse ? hoveringCursor : Qt.ArrowCursor + + onPressed: mouse.accepted = false + onWheel: { + _visible = false + wheel.accepted = false + } + onClicked:{ + console.log("Clicked") + if(isClickable){ + if(tooltip.delay>0) { + tooltip.oldDelay = tooltip.delay + tooltip.delay = 0 + } + tooltip.show(text, -1); + } + mouse.accepted = false + } + + Tooltip { + id: tooltip + + property int oldDelay : 0 + + delay: tooltipArea.delay + parent: tooltipParent + visible: _visible || force + width: Math.min(tooltip.implicitWidth, Math.max(tooltipArea.maxWidth, TooltipStyle.minWidth)) + + + //tooltipParent.width>TooltipStyle.minWidth?tooltipParent.width:TooltipStyle.minWidth + + timeout: -1 + + // Workaround to always display tooltip. + onVisibleChanged: { + if (!visible && force) { + tooltip.visible = true + } + } + MouseArea{ + anchors.fill:parent + visible: tooltipArea.isClickable + onClicked : { + tooltip.hide() + tooltip.delay = tooltip.oldDelay + mouse.accepted = false + } + } + } } diff --git a/linphone-app/ui/modules/Linphone/Chat/Chat.qml b/linphone-app/ui/modules/Linphone/Chat/Chat.qml index a7495540a..7eee6e6b0 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Chat.qml @@ -154,6 +154,7 @@ Rectangle { hoverEnabled: true implicitHeight: layout.height width: parent.width + parent.anchors.rightMargin + acceptedButtons: Qt.NoButton RowLayout { id: layout diff --git a/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml b/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml index cb697cb25..cdbbd56e2 100644 --- a/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml +++ b/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml @@ -46,6 +46,7 @@ RowLayout { $chatEntry.timestamp.getTime() - previousEntry.timestamp.getTime() > 3600 } TooltipArea{ + delay:0 text:avatar.username+'\n'+$chatEntry.fromSipAddress tooltipParent:mainRow }