aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-05-11 14:43:26 +0200
committerUlf Hermann <ulf.hermann@qt.io>2016-05-23 14:39:24 +0000
commitc39ed2a3b7f85b27aa867e9c3cbc1c8215bd564b (patch)
tree0dd90f1f8fde6f391c7e91db0b19ec943bb673ac /src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp
parent475e527cf0ef67a2e6101f310253870460597d6d (diff)
QmlProfiler: Make progress widget more expressive
Instead of the progress bar we can now show the number of events we have received, and the number of finished finalizers. This should give a the user a better idea of what is going on. Change-Id: I324fefbe6d5e3c24b080bfbc103c4317fa585215 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp49
1 files changed, 32 insertions, 17 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp
index cb54d1bf55c..fdf117c9c6b 100644
--- a/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp
@@ -34,6 +34,7 @@
#include <QProgressBar>
#include <QTime>
#include <QDebug>
+#include <QTimer>
namespace QmlProfiler {
namespace Internal {
@@ -44,10 +45,10 @@ class QmlProfilerStateWidget::QmlProfilerStateWidgetPrivate
QmlProfilerStateWidgetPrivate(QmlProfilerStateWidget *qq) { Q_UNUSED(qq); }
QLabel *text;
- QProgressBar *progressBar;
QmlProfilerStateManager *m_profilerState;
QmlProfilerModelManager *m_modelManager;
+ QTimer timer;
};
QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateManager,
@@ -66,24 +67,21 @@ QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateMan
setAutoFillBackground(true);
layout->addWidget(d->text);
- d->progressBar = new QProgressBar(this);
- layout->addWidget(d->progressBar);
- d->progressBar->setRange(0, 0);
- d->progressBar->setVisible(false);
-
setLayout(layout);
// profiler state
d->m_modelManager = modelManager;
connect(d->m_modelManager, &QmlProfilerModelManager::stateChanged,
- this, &QmlProfilerStateWidget::updateDisplay);
+ this, &QmlProfilerStateWidget::update);
d->m_profilerState = stateManager;
connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged,
- this, &QmlProfilerStateWidget::updateDisplay);
+ this, &QmlProfilerStateWidget::update);
connect(d->m_profilerState, &QmlProfilerStateManager::serverRecordingChanged,
- this, &QmlProfilerStateWidget::updateDisplay);
+ this, &QmlProfilerStateWidget::update);
+ connect(&d->timer, &QTimer::timeout, this, &QmlProfilerStateWidget::updateDisplay);
- updateDisplay();
+ d->timer.setInterval(1000);
+ update();
}
QmlProfilerStateWidget::~QmlProfilerStateWidget()
@@ -98,10 +96,9 @@ void QmlProfilerStateWidget::reposition()
move(parentWidget->width()/2 - width()/2, parentWidget->height()/3 - height()/2);
}
-void QmlProfilerStateWidget::showText(const QString &text, bool showProgress)
+void QmlProfilerStateWidget::showText(const QString &text)
{
setVisible(true);
- d->progressBar->setVisible(showProgress);
d->text->setText(text);
resize(300, 70);
reposition();
@@ -111,7 +108,11 @@ void QmlProfilerStateWidget::updateDisplay()
{
// When application is being profiled
if (d->m_profilerState->serverRecording()) {
- showText(tr("Profiling application"));
+ // Heuristic to not show the number if the application will only send the events when it
+ // stops. The number is still > 0 then because we get some StartTrace etc.
+ uint numEvents = d->m_modelManager->numLoadedEvents();
+ showText(numEvents > 256 ? tr("Profiling application: %1 events").arg(numEvents) :
+ tr("Profiling application"));
return;
}
@@ -125,18 +126,21 @@ void QmlProfilerStateWidget::updateDisplay()
} else if (!d->m_modelManager->isEmpty()) {
// When datamodel is acquiring or processing data
if (state == QmlProfilerModelManager::ProcessingData) {
- showText(tr("Processing data"), true);
+ showText(tr("Processing data: %1 / %2").arg(d->m_modelManager->numFinishedFinalizers())
+ .arg(d->m_modelManager->numRegisteredFinalizers()));
} else if (d->m_profilerState->currentState() != QmlProfilerStateManager::Idle) {
if (state == QmlProfilerModelManager::AcquiringData) {
// we don't know how much more, so progress numbers are strange here
- showText(tr("Loading buffered data"));
+ showText(tr("Loading buffered data: %1 events")
+ .arg(d->m_modelManager->numLoadedEvents()));
} else if (state == QmlProfilerModelManager::ClearingData) {
// when starting a second recording from the same process without aggregation
showText(tr("Clearing old trace"));
}
} else if (state == QmlProfilerModelManager::AcquiringData) {
// Application died before all data could be read
- showText(tr("Loading offline data"));
+ showText(tr("Loading offline data: %1 events")
+ .arg(d->m_modelManager->numLoadedEvents()));
} else if (state == QmlProfilerModelManager::ClearingData) {
showText(tr("Clearing old trace"));
}
@@ -147,9 +151,20 @@ void QmlProfilerStateWidget::updateDisplay()
}
// There is a trace on view, hide this dialog
- d->progressBar->setVisible(false);
setVisible(false);
}
+void QmlProfilerStateWidget::update()
+{
+ QmlProfilerModelManager::State state = d->m_modelManager->state();
+ if (state == QmlProfilerModelManager::AcquiringData
+ || state == QmlProfilerModelManager::ProcessingData) {
+ d->timer.start();
+ } else {
+ d->timer.stop();
+ }
+ updateDisplay();
+}
+
} // namespace Internal
} // namespace QmlProfiler