Move progress indicators out of mode bar.

This both allows the mode bar to be hidden optionally, and can give the
progress information a bit more room (e.g. for titles).

Progress information can either be shown in "pop up" windows in the
lower left corner of the main window (hiding window contents below),
or in a summary progress bar in the bottom right corner of the status bar.
Hovering the summary progress bar temporarily pops up the detailed
progress information. Keyboard can be used to switch between the two
views.

Change-Id: Ic6d6ab4fd43906e84b480c8ddf8eae5f5852e1f3
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Eike Ziller
2013-03-22 14:14:21 +01:00
parent c5f7cc62bb
commit 5a3dfb767f
13 changed files with 506 additions and 84 deletions

View File

@@ -32,18 +32,22 @@
#include <utils/qtcassert.h>
#include <QEvent>
#include <QVBoxLayout>
using namespace Core;
using namespace Core::Internal;
static const int PROGRESS_WIDTH = 100;
ProgressView::ProgressView(QWidget *parent)
: QWidget(parent)
: QWidget(parent), m_referenceWidget(0), m_hovered(false)
{
m_layout = new QVBoxLayout;
setLayout(m_layout);
m_layout->setMargin(0);
m_layout->setContentsMargins(0, 0, 0, 1);
m_layout->setSpacing(0);
m_layout->setSizeConstraint(QLayout::SetFixedSize);
setWindowTitle(tr("Processes"));
}
@@ -59,7 +63,7 @@ FutureProgress *ProgressView::addTask(const QFuture<void> &future,
ProgressManager::ProgressFlags flags)
{
removeOldTasks(type);
if (m_taskList.size() == 3)
if (m_taskList.size() == 10)
removeOneOldTask();
FutureProgress *progress = new FutureProgress(this);
progress->setTitle(title);
@@ -72,10 +76,76 @@ FutureProgress *ProgressView::addTask(const QFuture<void> &future,
progress->setKeepOnFinish(FutureProgress::KeepOnFinishTillUserInteraction);
else
progress->setKeepOnFinish(FutureProgress::HideOnFinish);
connect(progress, SIGNAL(hasErrorChanged()), this, SIGNAL(hasErrorChanged()));
connect(progress, SIGNAL(removeMe()), this, SLOT(slotRemoveTask()));
connect(progress, SIGNAL(fadeStarted()), this, SLOT(checkForLastProgressFading()));
return progress;
}
bool ProgressView::hasError() const
{
foreach (FutureProgress *progress, m_taskList)
if (progress->hasError())
return true;
return false;
}
bool ProgressView::isFading() const
{
if (m_taskList.isEmpty())
return false;
foreach (FutureProgress *progress, m_taskList) {
if (!progress->isFading()) // we still have progress bars that are not fading, do nothing
return false;
}
return true;
}
bool ProgressView::isEmpty() const
{
return m_taskList.isEmpty();
}
bool ProgressView::isHovered() const
{
return m_hovered;
}
void ProgressView::setReferenceWidget(QWidget *widget)
{
if (m_referenceWidget)
removeEventFilter(this);
m_referenceWidget = widget;
if (m_referenceWidget)
installEventFilter(this);
reposition();
}
bool ProgressView::event(QEvent *event)
{
if (event->type() == QEvent::ParentAboutToChange && parentWidget()) {
parentWidget()->removeEventFilter(this);
} else if (event->type() == QEvent::ParentChange && parentWidget()) {
parentWidget()->installEventFilter(this);
} else if (event->type() == QEvent::Resize) {
reposition();
} else if (event->type() == QEvent::Enter) {
m_hovered = true;
emit hoveredChanged(m_hovered);
} else if (event->type() == QEvent::Leave) {
m_hovered = false;
emit hoveredChanged(m_hovered);
}
return QWidget::event(event);
}
bool ProgressView::eventFilter(QObject *obj, QEvent *event)
{
if ((obj == parentWidget() || obj == m_referenceWidget) && event->type() == QEvent::Resize)
reposition();
return false;
}
void ProgressView::removeOldTasks(const QString &type, bool keepOne)
{
bool firstFound = !keepOne; // start with false if we want to keep one
@@ -99,6 +169,15 @@ void ProgressView::deleteTask(FutureProgress *progress)
progress->deleteLater();
}
void ProgressView::reposition()
{
if (!parentWidget() || !m_referenceWidget)
return;
QPoint topRightReferenceInParent =
m_referenceWidget->mapTo(parentWidget(), m_referenceWidget->rect().topRight());
move(topRightReferenceInParent - rect().bottomRight());
}
void ProgressView::removeOneOldTask()
{
if (m_taskList.isEmpty())
@@ -146,3 +225,9 @@ void ProgressView::slotRemoveTask()
removeTask(progress);
removeOldTasks(type, true);
}
void ProgressView::checkForLastProgressFading()
{
if (isEmpty() || isFading())
emit fadeOfLastProgressStarted();
}