forked from qt-creator/qt-creator
QmlDesigner: Prevent showing preview tooltip when button is pressed
On some platforms, drag will stop deliving mouse events to MouseArea. Disallowed showing the tooltip when a mouse button is pressed. Fixes: QDS-6481 Change-Id: I8777d57be1bfef8470571027d9257d3a10eb5a7a Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -665,15 +665,23 @@ Item {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
|
||||||
|
property bool allowTooltip: true
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
|
||||||
onExited: tooltipBackend.hideTooltip()
|
onExited: tooltipBackend.hideTooltip()
|
||||||
onCanceled: tooltipBackend.hideTooltip()
|
onEntered: allowTooltip = true
|
||||||
|
onCanceled: {
|
||||||
|
tooltipBackend.hideTooltip()
|
||||||
|
allowTooltip = true
|
||||||
|
}
|
||||||
onPositionChanged: tooltipBackend.reposition()
|
onPositionChanged: tooltipBackend.reposition()
|
||||||
onPressed: (mouse)=> {
|
onPressed: (mouse)=> {
|
||||||
forceActiveFocus()
|
forceActiveFocus()
|
||||||
|
allowTooltip = false
|
||||||
|
tooltipBackend.hideTooltip()
|
||||||
var ctrlDown = mouse.modifiers & Qt.ControlModifier
|
var ctrlDown = mouse.modifiers & Qt.ControlModifier
|
||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
if (!root.selectedAssets[filePath] && !ctrlDown)
|
if (!root.selectedAssets[filePath] && !ctrlDown)
|
||||||
@@ -698,12 +706,12 @@ Item {
|
|||||||
root.contextDir = model.fileDir
|
root.contextDir = model.fileDir
|
||||||
root.isDirContextMenu = false
|
root.isDirContextMenu = false
|
||||||
|
|
||||||
tooltipBackend.hideTooltip()
|
|
||||||
contextMenu.popup()
|
contextMenu.popup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: (mouse)=> {
|
onReleased: (mouse)=> {
|
||||||
|
allowTooltip = true
|
||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
if (!(mouse.modifiers & Qt.ControlModifier))
|
if (!(mouse.modifiers & Qt.ControlModifier))
|
||||||
root.selectedAssets = {}
|
root.selectedAssets = {}
|
||||||
@@ -720,7 +728,7 @@ Item {
|
|||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: 1000
|
interval: 1000
|
||||||
running: mouseArea.containsMouse
|
running: mouseArea.containsMouse && mouseArea.allowTooltip
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (suffix === ".ttf" || suffix === ".otf") {
|
if (suffix === ".ttf" || suffix === ".otf") {
|
||||||
tooltipBackend.name = fileName
|
tooltipBackend.name = fileName
|
||||||
|
@@ -88,6 +88,8 @@ Item {
|
|||||||
|
|
||||||
onShowContextMenu: delegateRoot.showContextMenu()
|
onShowContextMenu: delegateRoot.showContextMenu()
|
||||||
onPressed: (mouse)=> {
|
onPressed: (mouse)=> {
|
||||||
|
allowTooltip = false
|
||||||
|
hide()
|
||||||
if (mouse.button === Qt.LeftButton)
|
if (mouse.button === Qt.LeftButton)
|
||||||
rootView.startDragAndDrop(itemLibraryEntry, mapToGlobal(mouse.x, mouse.y))
|
rootView.startDragAndDrop(itemLibraryEntry, mapToGlobal(mouse.x, mouse.y))
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,8 @@ import HelperWidgets 2.0
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
|
||||||
|
property bool allowTooltip: true
|
||||||
|
|
||||||
signal showContextMenu()
|
signal showContextMenu()
|
||||||
|
|
||||||
function hide()
|
function hide()
|
||||||
@@ -38,7 +40,12 @@ MouseArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onExited: tooltipBackend.hideTooltip()
|
onExited: tooltipBackend.hideTooltip()
|
||||||
onCanceled: tooltipBackend.hideTooltip()
|
onEntered: allowTooltip = true
|
||||||
|
onCanceled: {
|
||||||
|
tooltipBackend.hideTooltip()
|
||||||
|
allowTooltip = true
|
||||||
|
}
|
||||||
|
onReleased: allowTooltip = true
|
||||||
onPositionChanged: tooltipBackend.reposition()
|
onPositionChanged: tooltipBackend.reposition()
|
||||||
onClicked: function(mouse) {
|
onClicked: function(mouse) {
|
||||||
forceActiveFocus()
|
forceActiveFocus()
|
||||||
@@ -51,7 +58,7 @@ MouseArea {
|
|||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: 1000
|
interval: 1000
|
||||||
running: mouseArea.containsMouse
|
running: mouseArea.containsMouse && mouseArea.allowTooltip
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
tooltipBackend.name = itemName
|
tooltipBackend.name = itemName
|
||||||
tooltipBackend.path = componentPath
|
tooltipBackend.path = componentPath
|
||||||
|
@@ -293,8 +293,15 @@ void NavigatorTreeView::mousePressEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
void NavigatorTreeView::startDrag(Qt::DropActions supportedActions)
|
void NavigatorTreeView::startDrag(Qt::DropActions supportedActions)
|
||||||
{
|
{
|
||||||
if (m_dragAllowed)
|
if (m_dragAllowed) {
|
||||||
|
if (m_previewToolTip) {
|
||||||
|
// Workaround to ensure tooltip doesn't linger during drag, as drag grabs all mouse
|
||||||
|
// events on some platforms (e.g. mac)
|
||||||
|
m_previewToolTip->hide();
|
||||||
|
m_previewToolTipNodeId = -1;
|
||||||
|
}
|
||||||
QTreeView::startDrag(supportedActions);
|
QTreeView::startDrag(supportedActions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user