forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -143,6 +143,9 @@ public:
|
||||
QmlProfilerTraceTime *traceTime;
|
||||
|
||||
int numRegisteredModels;
|
||||
int numFinishedFinalizers;
|
||||
|
||||
uint numLoadedEvents;
|
||||
quint64 availableFeatures;
|
||||
quint64 visibleFeatures;
|
||||
quint64 recordedFeatures;
|
||||
@@ -156,6 +159,8 @@ QmlProfilerModelManager::QmlProfilerModelManager(Utils::FileInProjectFinder *fin
|
||||
QObject(parent), d(new QmlProfilerModelManagerPrivate)
|
||||
{
|
||||
d->numRegisteredModels = 0;
|
||||
d->numFinishedFinalizers = 0;
|
||||
d->numLoadedEvents = 0;
|
||||
d->availableFeatures = 0;
|
||||
d->visibleFeatures = 0;
|
||||
d->recordedFeatures = 0;
|
||||
@@ -192,15 +197,31 @@ bool QmlProfilerModelManager::isEmpty() const
|
||||
return d->model->isEmpty();
|
||||
}
|
||||
|
||||
uint QmlProfilerModelManager::numLoadedEvents() const
|
||||
{
|
||||
return d->numLoadedEvents;
|
||||
}
|
||||
|
||||
int QmlProfilerModelManager::registerModelProxy()
|
||||
{
|
||||
return d->numRegisteredModels++;
|
||||
}
|
||||
|
||||
int QmlProfilerModelManager::numFinishedFinalizers() const
|
||||
{
|
||||
return d->numFinishedFinalizers;
|
||||
}
|
||||
|
||||
int QmlProfilerModelManager::numRegisteredFinalizers() const
|
||||
{
|
||||
return d->finalizers.count();
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::dispatch(const QmlEvent &event, const QmlEventType &type)
|
||||
{
|
||||
foreach (const EventLoader &loader, d->eventLoaders[type.feature()])
|
||||
loader(event, type);
|
||||
++d->numLoadedEvents;
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::announceFeatures(quint64 features, EventLoader eventLoader,
|
||||
@@ -278,8 +299,10 @@ void QmlProfilerModelManager::processingDone()
|
||||
// Load notes after the timeline models have been initialized ...
|
||||
// which happens on stateChanged(Done).
|
||||
|
||||
foreach (const Finalizer &finalizer, d->finalizers)
|
||||
foreach (const Finalizer &finalizer, d->finalizers) {
|
||||
finalizer();
|
||||
++d->numFinishedFinalizers;
|
||||
}
|
||||
|
||||
d->notesModel->loadData();
|
||||
setState(Done);
|
||||
@@ -412,6 +435,8 @@ QmlProfilerModelManager::State QmlProfilerModelManager::state() const
|
||||
void QmlProfilerModelManager::clear()
|
||||
{
|
||||
setState(ClearingData);
|
||||
d->numLoadedEvents = 0;
|
||||
d->numFinishedFinalizers = 0;
|
||||
d->model->clear();
|
||||
d->traceTime->clear();
|
||||
d->notesModel->clear();
|
||||
|
||||
@@ -99,10 +99,14 @@ public:
|
||||
QmlProfilerNotesModel *notesModel() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
uint numLoadedEvents() const;
|
||||
|
||||
int registerModelProxy();
|
||||
void announceFeatures(quint64 features, EventLoader eventLoader, Finalizer finalizer);
|
||||
|
||||
int numFinishedFinalizers() const;
|
||||
int numRegisteredFinalizers() const;
|
||||
|
||||
void dispatch(const QmlEvent &event, const QmlEventType &type);
|
||||
|
||||
quint64 availableFeatures() const;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -42,8 +42,9 @@ public:
|
||||
~QmlProfilerStateWidget();
|
||||
|
||||
private slots:
|
||||
void showText(const QString &text, bool showProgress = false);
|
||||
void showText(const QString &text);
|
||||
void updateDisplay();
|
||||
void update();
|
||||
void reposition();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user