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 {
|
||||
id: mouseArea
|
||||
|
||||
property bool allowTooltip: true
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
|
||||
onExited: tooltipBackend.hideTooltip()
|
||||
onCanceled: tooltipBackend.hideTooltip()
|
||||
onEntered: allowTooltip = true
|
||||
onCanceled: {
|
||||
tooltipBackend.hideTooltip()
|
||||
allowTooltip = true
|
||||
}
|
||||
onPositionChanged: tooltipBackend.reposition()
|
||||
onPressed: (mouse)=> {
|
||||
forceActiveFocus()
|
||||
allowTooltip = false
|
||||
tooltipBackend.hideTooltip()
|
||||
var ctrlDown = mouse.modifiers & Qt.ControlModifier
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
if (!root.selectedAssets[filePath] && !ctrlDown)
|
||||
@@ -698,12 +706,12 @@ Item {
|
||||
root.contextDir = model.fileDir
|
||||
root.isDirContextMenu = false
|
||||
|
||||
tooltipBackend.hideTooltip()
|
||||
contextMenu.popup()
|
||||
}
|
||||
}
|
||||
|
||||
onReleased: (mouse)=> {
|
||||
allowTooltip = true
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
if (!(mouse.modifiers & Qt.ControlModifier))
|
||||
root.selectedAssets = {}
|
||||
@@ -720,7 +728,7 @@ Item {
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: mouseArea.containsMouse
|
||||
running: mouseArea.containsMouse && mouseArea.allowTooltip
|
||||
onTriggered: {
|
||||
if (suffix === ".ttf" || suffix === ".otf") {
|
||||
tooltipBackend.name = fileName
|
||||
|
@@ -88,6 +88,8 @@ Item {
|
||||
|
||||
onShowContextMenu: delegateRoot.showContextMenu()
|
||||
onPressed: (mouse)=> {
|
||||
allowTooltip = false
|
||||
hide()
|
||||
if (mouse.button === Qt.LeftButton)
|
||||
rootView.startDragAndDrop(itemLibraryEntry, mapToGlobal(mouse.x, mouse.y))
|
||||
}
|
||||
|
@@ -30,6 +30,8 @@ import HelperWidgets 2.0
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
property bool allowTooltip: true
|
||||
|
||||
signal showContextMenu()
|
||||
|
||||
function hide()
|
||||
@@ -38,7 +40,12 @@ MouseArea {
|
||||
}
|
||||
|
||||
onExited: tooltipBackend.hideTooltip()
|
||||
onCanceled: tooltipBackend.hideTooltip()
|
||||
onEntered: allowTooltip = true
|
||||
onCanceled: {
|
||||
tooltipBackend.hideTooltip()
|
||||
allowTooltip = true
|
||||
}
|
||||
onReleased: allowTooltip = true
|
||||
onPositionChanged: tooltipBackend.reposition()
|
||||
onClicked: function(mouse) {
|
||||
forceActiveFocus()
|
||||
@@ -51,7 +58,7 @@ MouseArea {
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: mouseArea.containsMouse
|
||||
running: mouseArea.containsMouse && mouseArea.allowTooltip
|
||||
onTriggered: {
|
||||
tooltipBackend.name = itemName
|
||||
tooltipBackend.path = componentPath
|
||||
|
@@ -293,8 +293,15 @@ void NavigatorTreeView::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user