From 07c0a8348c59945465e9f2330a40f625543f7f8a Mon Sep 17 00:00:00 2001
From: Eike Ziller <eike.ziller@digia.com>
Date: Mon, 8 Jul 2013 13:45:05 +0200
Subject: [PATCH] Progress summary: Forward click to "current" progress
 details.

It was annoying that it wasn't possible to click on the summary progress
bar to e.g. open the compile output or issues pane, even when you had
only a build running.

This change forwards the click to either the progress that currently
shows a details widget in the status bar (like the build errors/warnings
from the build progress), or to the last progress that was started.

Change-Id: I4b50dd4b43bdc12fac329d33e158fa759bee4d28
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
---
 .../progressmanager/progressmanager.cpp        | 18 +++++++++++++++++-
 .../progressmanager/progressmanager_p.h        |  1 +
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
index b155834317b..fc15be7944f 100644
--- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
@@ -46,6 +46,7 @@
 #include <QAction>
 #include <QEvent>
 #include <QHBoxLayout>
+#include <QMouseEvent>
 #include <QPainter>
 #include <QPropertyAnimation>
 #include <QStyle>
@@ -379,6 +380,19 @@ bool ProgressManagerPrivate::eventFilter(QObject *obj, QEvent *event)
         m_hovered = false;
         // give the progress view the chance to get the mouse enter event
         updateVisibilityWithDelay();
+    } else if (obj == m_statusBarWidget && event->type() == QEvent::MouseButtonPress
+               && !m_taskList.isEmpty()) {
+        QMouseEvent *me = static_cast<QMouseEvent *>(event);
+        if (me->button() == Qt::LeftButton && !me->modifiers()) {
+            FutureProgress *progress = m_currentStatusDetailsProgress;
+            if (!progress)
+                progress = m_taskList.last();
+            // don't send signal directly from an event filter, event filters should
+            // do as little a possible
+            QTimer::singleShot(0, progress, SIGNAL(clicked()));
+            event->accept();
+            return true;
+        }
     }
     return false;
 }
@@ -643,8 +657,10 @@ void ProgressManagerPrivate::updateStatusDetailsWidget()
     while (i != m_taskList.begin()) {
         --i;
         candidateWidget = (*i)->statusBarWidget();
-        if (candidateWidget)
+        if (candidateWidget) {
+            m_currentStatusDetailsProgress = *i;
             break;
+        }
     }
 
     if (candidateWidget == m_currentStatusDetailsWidget)
diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_p.h b/src/plugins/coreplugin/progressmanager/progressmanager_p.h
index dabd525a792..ac99df10332 100644
--- a/src/plugins/coreplugin/progressmanager/progressmanager_p.h
+++ b/src/plugins/coreplugin/progressmanager/progressmanager_p.h
@@ -108,6 +108,7 @@ private:
     QWidget *m_summaryProgressWidget;
     QHBoxLayout *m_summaryProgressLayout;
     QWidget *m_currentStatusDetailsWidget;
+    QPointer<FutureProgress> m_currentStatusDetailsProgress;
     ProgressBar *m_summaryProgressBar;
     QGraphicsOpacityEffect *m_opacityEffect;
     QPointer<QPropertyAnimation> m_opacityAnimation;
-- 
GitLab