From 35a09f2efe58adeb3fcb2001be19c5deb2457494 Mon Sep 17 00:00:00 2001
From: Jens Bache-Wiig <jbache@trolltech.com>
Date: Tue, 2 Mar 2010 18:38:58 +0100
Subject: [PATCH] Fix button toggle of the miniproject selector on Windows

The problem is that on windows, mouse events are replayed
if you click outside a popup to close it. If you hit the
project selector button to toggle it, this will cause
the popup to reopen on mouse release. Which we do not want.
Hence we set the DontReplay flag on mouseClick.

A similar workaround can be found in QComboBox.
---
 .../projectexplorer/miniprojecttargetselector.cpp   | 13 +++++++++++++
 .../projectexplorer/miniprojecttargetselector.h     |  1 +
 2 files changed, 14 insertions(+)

diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp
index 31b33d56737..030061f8bcb 100644
--- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp
+++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp
@@ -426,6 +426,19 @@ void MiniProjectTargetSelector::setVisible(bool visible)
     m_projectAction->setChecked(visible);
 }
 
+// This is a workaround for the problem that Windows
+// will let the mouse events through when you click
+// outside a popup to close it. This causes the popup
+// to open on mouse release if you hit the button, which
+//
+//
+// A similar case can be found in QComboBox
+void MiniProjectTargetSelector::mousePressEvent(QMouseEvent *e)
+{
+    setAttribute(Qt::WA_NoMouseReplay);
+    QWidget::mousePressEvent(e);
+}
+
 void MiniProjectTargetSelector::addProject(ProjectExplorer::Project* project)
 {
     QTC_ASSERT(project, return);
diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.h b/src/plugins/projectexplorer/miniprojecttargetselector.h
index 13f9d5427f5..0a529f0e46f 100644
--- a/src/plugins/projectexplorer/miniprojecttargetselector.h
+++ b/src/plugins/projectexplorer/miniprojecttargetselector.h
@@ -132,6 +132,7 @@ private slots:
     void changeStartupProject(ProjectExplorer::Project *project);
     void updateAction();
     void paintEvent(QPaintEvent *);
+    void mousePressEvent(QMouseEvent *);
 
 private:
     int indexFor(ProjectExplorer::Project *project) const;
-- 
GitLab