summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@nokia.com>2010-10-15 17:22:45 +0200
committerTim Jenssen <tim.jenssen@nokia.com>2010-10-15 17:29:30 +0200
commit4af1d09535c12bc33a3aef6ec346567f8c82e197 (patch)
tree7542a991512a08dce5dd59f79da1b1297850597a
parent3051fd4c98d9680a657e1b9ca5b3844173d54228 (diff)
downloadqt-creator-4af1d09535c12bc33a3aef6ec346567f8c82e197.tar.gz
added possiblity to keep the progress widget
- the Nokia Qt SDK UpdateInfo plugin progress should stay in the progress view till the user clicks on it - now the futureprogress knows the difference between: KeepOnFinishTillUserInteraction and KeepOnFinish Reviewed-by: con
-rw-r--r--src/plugins/coreplugin/progressmanager/futureprogress.cpp46
-rw-r--r--src/plugins/coreplugin/progressmanager/futureprogress.h7
-rw-r--r--src/plugins/coreplugin/progressmanager/progressview.cpp6
-rw-r--r--src/plugins/debugger/debuggerengine.cpp2
4 files changed, 47 insertions, 14 deletions
diff --git a/src/plugins/coreplugin/progressmanager/futureprogress.cpp b/src/plugins/coreplugin/progressmanager/futureprogress.cpp
index 83690dcca1..bb86782bdd 100644
--- a/src/plugins/coreplugin/progressmanager/futureprogress.cpp
+++ b/src/plugins/coreplugin/progressmanager/futureprogress.cpp
@@ -84,20 +84,24 @@ void FadeWidgetHack::paintEvent(QPaintEvent *)
struct FutureProgressPrivate {
explicit FutureProgressPrivate(FutureProgress *q);
+ void tryToFadeAway();
+
QFutureWatcher<void> m_watcher;
Internal::ProgressBar *m_progress;
QWidget *m_widget;
QHBoxLayout *m_widgetLayout;
QString m_type;
- bool m_keep;
+ FutureProgress::KeepOnFinishType m_keep;
bool m_waitingForUserInteraction;
Internal::FadeWidgetHack *m_faderWidget;
+ FutureProgress *m_q;
+ bool m_isFading;
};
FutureProgressPrivate::FutureProgressPrivate(FutureProgress *q) :
m_progress(new Internal::ProgressBar), m_widget(0), m_widgetLayout(new QHBoxLayout),
- m_keep(false), m_waitingForUserInteraction(false),
- m_faderWidget(new Internal::FadeWidgetHack(q))
+ m_keep(FutureProgress::DontKeepOnFinish), m_waitingForUserInteraction(false),
+ m_faderWidget(new Internal::FadeWidgetHack(q)), m_q(q), m_isFading(false)
{
}
@@ -224,7 +228,7 @@ void FutureProgress::setStarted()
bool FutureProgress::eventFilter(QObject *, QEvent *e)
{
- if (d->m_waitingForUserInteraction
+ if (d->m_keep != KeepOnFinish && d->m_waitingForUserInteraction
&& (e->type() == QEvent::MouseMove || e->type() == QEvent::KeyPress)) {
qApp->removeEventFilter(this);
QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
@@ -248,14 +252,26 @@ void FutureProgress::setFinished()
d->m_progress->setError(false);
}
emit finished();
- if (d->m_keep) {
- d->m_waitingForUserInteraction = true;
- qApp->installEventFilter(this);
- } else if (!d->m_progress->hasError()) {
- QTimer::singleShot(shortNotificationTimeout, this, SLOT(fadeAway()));
+ d->tryToFadeAway();
+}
+
+void FutureProgressPrivate::tryToFadeAway()
+{
+ if (m_isFading)
+ return;
+ if (m_keep == FutureProgress::KeepOnFinishTillUserInteraction) {
+ m_waitingForUserInteraction = true;
+ //eventfilter is needed to get user interaction
+ //events to start QTimer::singleShot later
+ qApp->installEventFilter(m_q);
+ m_isFading = true;
+ } else if (m_keep == FutureProgress::DontKeepOnFinish && !m_progress->hasError()) {
+ QTimer::singleShot(shortNotificationTimeout, m_q, SLOT(fadeAway()));
+ m_isFading = true;
}
}
+
void FutureProgress::setProgressRange(int min, int max)
{
d->m_progress->setRange(min, max);
@@ -343,9 +359,17 @@ QString FutureProgress::type() const
return d->m_type;
}
-void FutureProgress::setKeepOnFinish(bool keep)
+void FutureProgress::setKeepOnFinish(KeepOnFinishType keepType)
{
- d->m_keep = keep;
+ if (d->m_keep == keepType) {
+ return;
+ }
+ d->m_keep = keepType;
+
+ //if it is not finished tryToFadeAway is called by setFinished at the end
+ if (d->m_watcher.isFinished()) {
+ d->tryToFadeAway();
+ }
}
bool FutureProgress::keepOnFinish() const
diff --git a/src/plugins/coreplugin/progressmanager/futureprogress.h b/src/plugins/coreplugin/progressmanager/futureprogress.h
index 31517a0174..97de028783 100644
--- a/src/plugins/coreplugin/progressmanager/futureprogress.h
+++ b/src/plugins/coreplugin/progressmanager/futureprogress.h
@@ -46,6 +46,11 @@ class CORE_EXPORT FutureProgress : public QWidget
Q_OBJECT
public:
+ enum KeepOnFinishType {
+ DontKeepOnFinish = 0,
+ KeepOnFinishTillUserInteraction = 1,
+ KeepOnFinish = 2
+ };
explicit FutureProgress(QWidget *parent = 0);
virtual ~FutureProgress();
@@ -60,7 +65,7 @@ public:
void setType(const QString &type);
QString type() const;
- void setKeepOnFinish(bool keep);
+ void setKeepOnFinish(KeepOnFinishType keepType);
bool keepOnFinish() const;
bool hasError() const;
diff --git a/src/plugins/coreplugin/progressmanager/progressview.cpp b/src/plugins/coreplugin/progressmanager/progressview.cpp
index 35d3032860..eef9e56a28 100644
--- a/src/plugins/coreplugin/progressmanager/progressview.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressview.cpp
@@ -69,7 +69,11 @@ FutureProgress *ProgressView::addTask(const QFuture<void> &future,
m_layout->insertWidget(0, progress);
m_taskList.append(progress);
progress->setType(type);
- progress->setKeepOnFinish(flags & ProgressManager::KeepOnFinish);
+ if (flags.testFlag(ProgressManager::KeepOnFinish)) {
+ progress->setKeepOnFinish(FutureProgress::KeepOnFinishTillUserInteraction);
+ } else {
+ progress->setKeepOnFinish(FutureProgress::DontKeepOnFinish);
+ }
connect(progress, SIGNAL(removeMe()), this, SLOT(slotRemoveTask()));
return progress;
}
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index 980b59e4e2..229e8355ff 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -786,7 +786,7 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
Core::FutureProgress *fp = Core::ICore::instance()->progressManager()
->addTask(d->m_progress.future(),
tr("Launching"), _("Debugger.Launcher"));
- fp->setKeepOnFinish(false);
+ fp->setKeepOnFinish(Core::FutureProgress::DontKeepOnFinish);
d->m_progress.reportStarted();
}
QTC_ASSERT(runControl, notifyEngineSetupFailed(); return);