diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-04-08 15:02:30 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-04-10 14:21:25 +0200 |
commit | 920e7ca1f113f1f4ecc204adff51e7254e87a56b (patch) | |
tree | 2aeef98ad892193112675a83287fde71ec223990 /src/plugins | |
parent | 9e714006eece70447679ed740958ecf5290deb4b (diff) | |
download | qt-creator-920e7ca1f113f1f4ecc204adff51e7254e87a56b.tar.gz |
Show build and search progress detail also in status bar.
A widget specifically layouted for the status bar can now be registered
with the progress information. The newest one is made visible next to
the summary progress bar. If a newer one vanishes, the older becomes
visible again.
Change-Id: Iedf0e88a542ea442ae86fa51c792c68fbc6eef3c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins')
8 files changed, 98 insertions, 13 deletions
diff --git a/src/plugins/coreplugin/progressmanager/futureprogress.cpp b/src/plugins/coreplugin/progressmanager/futureprogress.cpp index a064402173..917c3b3ec5 100644 --- a/src/plugins/coreplugin/progressmanager/futureprogress.cpp +++ b/src/plugins/coreplugin/progressmanager/futureprogress.cpp @@ -65,6 +65,7 @@ public: Internal::ProgressBar *m_progress; QWidget *m_widget; QHBoxLayout *m_widgetLayout; + QWidget *m_statusBarWidget; QString m_type; FutureProgress::KeepOnFinishType m_keep; bool m_waitingForUserInteraction; @@ -75,6 +76,7 @@ public: FutureProgressPrivate::FutureProgressPrivate(FutureProgress *q) : m_progress(new Internal::ProgressBar), m_widget(0), m_widgetLayout(new QHBoxLayout), + m_statusBarWidget(0), m_keep(FutureProgress::HideOnFinish), m_waitingForUserInteraction(false), m_q(q), m_fadeStarting(false), m_isFading(false) { @@ -341,6 +343,20 @@ QWidget *FutureProgress::widget() const return d->m_widget; } +void FutureProgress::setStatusBarWidget(QWidget *widget) +{ + if (widget == d->m_statusBarWidget) + return; + delete d->m_statusBarWidget; + d->m_statusBarWidget = widget; + emit statusBarWidgetChanged(); +} + +QWidget *FutureProgress::statusBarWidget() const +{ + return d->m_statusBarWidget; +} + bool FutureProgress::isFading() const { return d->m_isFading; diff --git a/src/plugins/coreplugin/progressmanager/futureprogress.h b/src/plugins/coreplugin/progressmanager/futureprogress.h index cbc3a25ba3..4cf58b203a 100644 --- a/src/plugins/coreplugin/progressmanager/futureprogress.h +++ b/src/plugins/coreplugin/progressmanager/futureprogress.h @@ -71,6 +71,9 @@ public: void setWidget(QWidget *widget); QWidget *widget() const; + void setStatusBarWidget(QWidget *widget); + QWidget *statusBarWidget() const; + bool isFading() const; QSize sizeHint() const; @@ -83,6 +86,8 @@ signals: void hasErrorChanged(); void fadeStarted(); + void statusBarWidgetChanged(); + protected: void mousePressEvent(QMouseEvent *event); void paintEvent(QPaintEvent *); diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index 578e3cb00d..f5e401b05f 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -263,6 +263,7 @@ using namespace Core::Internal; ProgressManagerPrivate::ProgressManagerPrivate(QObject *parent) : ProgressManager(parent), m_applicationTask(0), + m_currentStatusDetailsWidget(0), m_opacityEffect(new QGraphicsOpacityEffect(this)), m_progressViewPinned(false), m_hovered(false) @@ -290,14 +291,20 @@ void ProgressManagerPrivate::init() layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); m_statusBarWidget->setLayout(layout); - m_summaryProgressBar = new ProgressBar(m_statusBarWidget); + m_summaryProgressWidget = new QWidget(m_statusBarWidget); + m_summaryProgressWidget->setVisible(!m_progressViewPinned); + m_summaryProgressWidget->setGraphicsEffect(m_opacityEffect); + m_summaryProgressLayout = new QHBoxLayout(m_summaryProgressWidget); + m_summaryProgressLayout->setContentsMargins(0, 0, 0, 0); + m_summaryProgressLayout->setSpacing(0); + m_summaryProgressWidget->setLayout(m_summaryProgressLayout); + m_summaryProgressBar = new ProgressBar(m_summaryProgressWidget); m_summaryProgressBar->setMinimumWidth(70); m_summaryProgressBar->setTitleVisible(false); m_summaryProgressBar->setSeparatorVisible(false); m_summaryProgressBar->setCancelEnabled(false); - m_summaryProgressBar->setGraphicsEffect(m_opacityEffect); - m_summaryProgressBar->setVisible(!m_progressViewPinned); - layout->addWidget(m_summaryProgressBar); + m_summaryProgressLayout->addWidget(m_summaryProgressBar); + layout->addWidget(m_summaryProgressWidget); ToggleButton *toggleButton = new ToggleButton(m_statusBarWidget); layout->addWidget(toggleButton); m_statusBarWidgetContainer->setWidget(m_statusBarWidget); @@ -420,6 +427,8 @@ FutureProgress *ProgressManagerPrivate::addTask(const QFuture<void> &future, con connect(progress, SIGNAL(hasErrorChanged()), this, SLOT(updateSummaryProgressBar())); connect(progress, SIGNAL(removeMe()), this, SLOT(slotRemoveTask())); connect(progress, SIGNAL(fadeStarted()), this, SLOT(updateSummaryProgressBar())); + connect(progress, SIGNAL(statusBarWidgetChanged()), this, SLOT(updateStatusDetailsWidget())); + updateStatusDetailsWidget(); emit taskStarted(type); return progress; @@ -545,6 +554,8 @@ void ProgressManagerPrivate::removeOldTasks(const QString &type, bool keepOne) firstFound = true; } } + updateSummaryProgressBar(); + updateStatusDetailsWidget(); } void ProgressManagerPrivate::removeOneOldTask() @@ -578,12 +589,16 @@ void ProgressManagerPrivate::removeOneOldTask() // no ended process, no type with multiple processes, just remove the oldest task FutureProgress *task = m_taskList.takeFirst(); deleteTask(task); + updateSummaryProgressBar(); + updateStatusDetailsWidget(); } void ProgressManagerPrivate::removeTask(FutureProgress *task) { m_taskList.removeAll(task); deleteTask(task); + updateSummaryProgressBar(); + updateStatusDetailsWidget(); } void ProgressManagerPrivate::deleteTask(FutureProgress *progress) @@ -596,7 +611,7 @@ void ProgressManagerPrivate::deleteTask(FutureProgress *progress) void ProgressManagerPrivate::updateVisibility() { m_progressView->setVisible(m_progressViewPinned || m_hovered || m_progressView->isHovered()); - m_summaryProgressBar->setVisible((!m_runningTasks.isEmpty() || !m_taskList.isEmpty()) + m_summaryProgressWidget->setVisible((!m_runningTasks.isEmpty() || !m_taskList.isEmpty()) && !m_progressViewPinned); } @@ -605,9 +620,37 @@ void ProgressManagerPrivate::updateVisibilityWithDelay() QTimer::singleShot(150, this, SLOT(updateVisibility())); } +void ProgressManagerPrivate::updateStatusDetailsWidget() +{ + QWidget *candidateWidget = 0; + // get newest progress with a status bar widget + QList<FutureProgress *>::iterator i = m_taskList.end(); + while (i != m_taskList.begin()) { + --i; + candidateWidget = (*i)->statusBarWidget(); + if (candidateWidget) + break; + } + + if (candidateWidget == m_currentStatusDetailsWidget) + return; + + if (m_currentStatusDetailsWidget) { + m_currentStatusDetailsWidget->hide(); + m_summaryProgressLayout->removeWidget(m_currentStatusDetailsWidget); + } + + if (candidateWidget) { + m_summaryProgressLayout->insertWidget(0, candidateWidget); + candidateWidget->show(); + } + + m_currentStatusDetailsWidget = candidateWidget; +} + void ProgressManagerPrivate::summaryProgressFinishedFading() { - m_summaryProgressBar->setVisible(false); + m_summaryProgressWidget->setVisible(false); m_opacityEffect->setOpacity(1.); } diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_p.h b/src/plugins/coreplugin/progressmanager/progressmanager_p.h index 8c8de807f3..44b572d0f2 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager_p.h +++ b/src/plugins/coreplugin/progressmanager/progressmanager_p.h @@ -35,6 +35,7 @@ #include <QFutureWatcher> #include <QList> #include <QGraphicsOpacityEffect> +#include <QHBoxLayout> #include <QPointer> #include <QPropertyAnimation> #include <QToolButton> @@ -82,6 +83,7 @@ private slots: void progressDetailsToggled(bool checked); void updateVisibility(); void updateVisibilityWithDelay(); + void updateStatusDetailsWidget(); void slotRemoveTask(); private: @@ -102,6 +104,9 @@ private: QFutureWatcher<void> *m_applicationTask; Core::StatusBarWidget *m_statusBarWidgetContainer; QWidget *m_statusBarWidget; + QWidget *m_summaryProgressWidget; + QHBoxLayout *m_summaryProgressLayout; + QWidget *m_currentStatusDetailsWidget; ProgressBar *m_summaryProgressBar; QGraphicsOpacityEffect *m_opacityEffect; QPointer<QPropertyAnimation> m_opacityAnimation; diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index f450f6727a..32e7455d85 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -303,6 +303,8 @@ void BuildManager::startBuildQueue(const QStringList &preambleMessage) Core::ProgressManager::KeepOnFinish | Core::ProgressManager::ShowInApplicationIcon); connect(d->m_futureProgress.data(), SIGNAL(clicked()), this, SLOT(showBuildResults())); d->m_futureProgress.data()->setWidget(new Internal::BuildProgress(d->m_taskWindow)); + d->m_futureProgress.data()->setStatusBarWidget(new Internal::BuildProgress(d->m_taskWindow, + Qt::Horizontal)); d->m_progress = 0; d->m_progressFutureInterface->setProgressRange(0, d->m_maxProgress * 100); diff --git a/src/plugins/projectexplorer/buildprogress.cpp b/src/plugins/projectexplorer/buildprogress.cpp index 1f83cbe0c9..9a6a673a0f 100644 --- a/src/plugins/projectexplorer/buildprogress.cpp +++ b/src/plugins/projectexplorer/buildprogress.cpp @@ -42,17 +42,27 @@ using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; -BuildProgress::BuildProgress(TaskWindow *taskWindow) - : m_errorIcon(new QLabel), +BuildProgress::BuildProgress(TaskWindow *taskWindow, Qt::Orientation orientation) + : m_contentWidget(new QWidget), + m_errorIcon(new QLabel), m_warningIcon(new QLabel), m_errorLabel(new QLabel), m_warningLabel(new QLabel), m_taskWindow(taskWindow) { - QVBoxLayout *layout = new QVBoxLayout; + QHBoxLayout *contentLayout = new QHBoxLayout; + contentLayout->setContentsMargins(0, 0, 0, 0); + contentLayout->setSpacing(0); + setLayout(contentLayout); + contentLayout->addWidget(m_contentWidget); + QBoxLayout *layout; + if (orientation == Qt::Horizontal) + layout = new QHBoxLayout; + else + layout = new QVBoxLayout; layout->setContentsMargins(8, 2, 0, 2); layout->setSpacing(2); - setLayout(layout); + m_contentWidget->setLayout(layout); QHBoxLayout *errorLayout = new QHBoxLayout; errorLayout->setSpacing(2); layout->addLayout(errorLayout); @@ -78,7 +88,7 @@ BuildProgress::BuildProgress(TaskWindow *taskWindow) m_errorIcon->setPixmap(QPixmap(QLatin1String(":/projectexplorer/images/compile_error.png"))); m_warningIcon->setPixmap(QPixmap(QLatin1String(":/projectexplorer/images/compile_warning.png"))); - hide(); + m_contentWidget->hide(); connect(m_taskWindow, SIGNAL(tasksChanged()), this, SLOT(updateState())); } @@ -105,5 +115,5 @@ void BuildProgress::updateState() m_warningLabel->setVisible(haveWarnings); m_errorIcon->setVisible(haveErrors); m_errorLabel->setVisible(haveErrors); - setVisible(haveWarnings || haveErrors); + m_contentWidget->setVisible(haveWarnings || haveErrors); } diff --git a/src/plugins/projectexplorer/buildprogress.h b/src/plugins/projectexplorer/buildprogress.h index 2535f5e541..31bf62c873 100644 --- a/src/plugins/projectexplorer/buildprogress.h +++ b/src/plugins/projectexplorer/buildprogress.h @@ -44,12 +44,13 @@ class BuildProgress : public QWidget { Q_OBJECT public: - BuildProgress(TaskWindow *taskWindow); + BuildProgress(TaskWindow *taskWindow, Qt::Orientation orientation = Qt::Vertical); private slots: void updateState(); private: + QWidget *m_contentWidget; QLabel *m_errorIcon; QLabel *m_warningIcon; QLabel *m_errorLabel; diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index ac7025a8d1..8f1ccf1e64 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -160,6 +160,8 @@ void BaseFileFind::runSearch(Find::SearchResult *search) FileFindParameters parameters = search->userData().value<FileFindParameters>(); CountingLabel *label = new CountingLabel; connect(search, SIGNAL(countChanged(int)), label, SLOT(updateCount(int))); + CountingLabel *statusLabel = new CountingLabel; + connect(search, SIGNAL(countChanged(int)), statusLabel, SLOT(updateCount(int))); Find::SearchResultWindow::instance()->popup(Core::IOutputPane::Flags(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus)); QFutureWatcher<FileSearchResultList> *watcher = new QFutureWatcher<FileSearchResultList>(); d->m_watchers.insert(watcher, search); @@ -182,6 +184,7 @@ void BaseFileFind::runSearch(Find::SearchResult *search) tr("Search"), QLatin1String(Constants::TASK_SEARCH)); progress->setWidget(label); + progress->setStatusBarWidget(statusLabel); connect(progress, SIGNAL(clicked()), search, SLOT(popup())); } |