summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin/progressmanager/futureprogress.cpp
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 /src/plugins/coreplugin/progressmanager/futureprogress.cpp
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
Diffstat (limited to 'src/plugins/coreplugin/progressmanager/futureprogress.cpp')
-rw-r--r--src/plugins/coreplugin/progressmanager/futureprogress.cpp46
1 files changed, 35 insertions, 11 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