From 08d16332f25082bed6d5bdfb77ce9aae27097866 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 26 Jun 2020 11:59:14 +0200 Subject: [PATCH] ProjectExplorer: Do not activate kits via right click ... in the target selector. When requesting the kit context menu by right-clicking, we get extra mouse events on Windows that activate the kit, which is annoying to users. Suppress these events. Fixes: QTCREATORBUG-24156 Change-Id: I8a5de927634dfdfafb54d265ab31763c6120a527 Reviewed-by: David Schulz --- src/plugins/projectexplorer/projectwindow.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index 41c719c9f75..e5ddfc4233b 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -341,11 +342,31 @@ public: setContextMenuPolicy(Qt::CustomContextMenu); } +private: // remove branch indicators void drawBranches(QPainter *, const QRect &, const QModelIndex &) const final { return; } + + bool userWantsContextMenu(const QMouseEvent *e) const + { + // On Windows, we get additional mouse events for the item view when right-clicking, + // causing unwanted kit activation (QTCREATORBUG-24156). Let's suppress these. + return HostOsInfo::isWindowsHost() && e->button() == Qt::RightButton; + } + + void mousePressEvent(QMouseEvent *e) + { + if (!userWantsContextMenu(e)) + BaseTreeView::mousePressEvent(e); + } + + void mouseReleaseEvent(QMouseEvent *e) + { + if (!userWantsContextMenu(e)) + BaseTreeView::mouseReleaseEvent(e); + } }; class ComboBoxItem : public TreeItem