diff options
author | Christiaan Janssen <christiaan.janssen@nokia.com> | 2012-05-16 12:16:45 +0200 |
---|---|---|
committer | Christiaan Janssen <christiaan.janssen@nokia.com> | 2012-05-21 12:15:21 +0200 |
commit | f1f87065780eb5d262abf2b5462070f4ce3f0b39 (patch) | |
tree | 54e8f1eb5b4368156092035e485b0592b265f7f9 /src/plugins | |
parent | a4f486b8fb4285fae19f8035c1c86c55d00e2072 (diff) | |
download | qt-creator-f1f87065780eb5d262abf2b5462070f4ce3f0b39.tar.gz |
QmlProfiler: state dialog as floating widget
Change-Id: I48ff1d729e49347881c82c7bd066d30ecaca47a5
Reviewed-by: Simjees Abraham <simjees.abraham@nokia.com>
Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qmlprofiler/qml/MainView.qml | 6 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qml/StatusDisplay.qml | 137 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qml/qmlprofiler.qrc | 1 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofiler.pro | 7 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilereventview.cpp | 6 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilereventview.h | 2 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp | 255 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerstatewidget.h | 37 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertraceview.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertraceview.h | 2 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp | 6 |
11 files changed, 313 insertions, 148 deletions
diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index 33d0763aa6..972efb71bd 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -548,12 +548,6 @@ Rectangle { color: labels.color } - StatusDisplay { - anchors.horizontalCenter: flick.horizontalCenter - anchors.verticalCenter: labels.verticalCenter - z:3 - } - // Gradient borders Item { anchors.left: labels.right diff --git a/src/plugins/qmlprofiler/qml/StatusDisplay.qml b/src/plugins/qmlprofiler/qml/StatusDisplay.qml deleted file mode 100644 index 8a434f8356..0000000000 --- a/src/plugins/qmlprofiler/qml/StatusDisplay.qml +++ /dev/null @@ -1,137 +0,0 @@ -import QtQuick 1.0 - -Item { - id: statusDisplay - - property real percentage : root.progress - - width: Math.max(200, statusText.width+20) - height: displayColumn.height + 20 - - visible: false; - - // shadow - BorderImage { - property int px: 4 - source: "dialog_shadow.png" - - border { - left: px; top: px - right: px; bottom: px - } - width: parent.width + 2*px - 1 - height: parent.height - x: -px + 1 - y: px + 1 - } - - // background - Rectangle { - color: "#E0E0E0" - border.width: 1 - border.color: "#666666" - radius: 4 - anchors.fill: parent - } - - Column { - id: displayColumn - y: 10 - spacing: 5 - width: parent.width - Text { - id: statusText - horizontalAlignment: "AlignHCenter" - anchors.horizontalCenter: parent.horizontalCenter - } - - Rectangle { - id: progressBar - - visible: false - - width: statusDisplay.width - 20 - height: 20 - x: 10 - color: "transparent" - border.width: 1 - border.color: "#AAAEAA" - Rectangle { - x: 1 - y: 1 - width: (parent.width-1) * statusDisplay.percentage - color: Qt.rgba(0.37 + 0.2*(1 - statusDisplay.percentage), 0.58, 0.37, 1) - height: parent.height-1 - } - } - } - - states: [ - // no data available - State { - when: (root.eventCount == 0) && (elapsedTime > 0) && !root.recordingEnabled - PropertyChanges { - target: statusDisplay - visible: true - } - - PropertyChanges { - target: statusText - text: qsTr("No QML events recorded") - } - onCompleted: { - root.clearDisplay(); - } - }, - // running app - State { - when: root.recordingEnabled - PropertyChanges { - target: statusDisplay - visible: true - } - - PropertyChanges { - target: statusText - text: qsTr("Profiling application") - } - }, - // loading data - State { - name: "loading" - when: !root.dataAvailable && (root.eventCount > 0) && !root.appKilled - PropertyChanges { - target: statusDisplay - visible: true - } - - PropertyChanges { - target: statusText - text: qsTr("Loading data") - } - - PropertyChanges { - target: progressBar - visible: true - } - }, - // application died - State { - name: "deadApp" - when: !root.dataAvailable && (root.eventCount > 0) && root.appKilled - PropertyChanges { - target: statusDisplay - visible: true - } - PropertyChanges { - target: statusText - text: qsTr("Application stopped before loading all data") - } - PropertyChanges { - target: progressBar - visible: true - } - } - ] - -} diff --git a/src/plugins/qmlprofiler/qml/qmlprofiler.qrc b/src/plugins/qmlprofiler/qml/qmlprofiler.qrc index 5bf597bd5a..ab3f8598da 100644 --- a/src/plugins/qmlprofiler/qml/qmlprofiler.qrc +++ b/src/plugins/qmlprofiler/qml/qmlprofiler.qrc @@ -9,7 +9,6 @@ <file>clean_pane_small.png</file> <file>recordOff.png</file> <file>recordOn.png</file> - <file>StatusDisplay.qml</file> <file>lock_closed.png</file> <file>lock_open.png</file> <file>TimeMarks.qml</file> diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index b7adadcd8e..1f6bf5c694 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -36,7 +36,8 @@ SOURCES += \ qv8profilerdatamodel.cpp \ qmlprofilerdatamodel.cpp \ qmlprofilerclientmanager.cpp \ - qmlprofilerviewmanager.cpp + qmlprofilerviewmanager.cpp \ + qmlprofilerstatewidget.cpp HEADERS += \ qmlprofilerconstants.h \ @@ -57,7 +58,8 @@ HEADERS += \ qv8profilerdatamodel.h \ qmlprofilerdatamodel.h \ qmlprofilerclientmanager.h \ - qmlprofilerviewmanager.h + qmlprofilerviewmanager.h \ + qmlprofilerstatewidget.h RESOURCES += \ qml/qmlprofiler.qrc @@ -70,7 +72,6 @@ OTHER_FILES += \ qml/RangeMover.qml \ qml/TimeDisplay.qml \ qml/TimeMarks.qml \ - qml/StatusDisplay.qml \ qml/SelectionRange.qml \ qml/SelectionRangeDetails.qml \ qml/Overview.qml diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp index 1f6957ff5f..954f3c38e0 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp @@ -275,6 +275,12 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev) } } +void QmlProfilerEventsWidget::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + emit resized(); +} + bool QmlProfilerEventsWidget::mouseOnTable(const QPoint &position) const { QPoint tableTopLeft = d->m_eventTree->mapToGlobal(QPoint(0,0)); diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.h b/src/plugins/qmlprofiler/qmlprofilereventview.h index aa60d5684b..0369075c04 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.h +++ b/src/plugins/qmlprofiler/qmlprofilereventview.h @@ -85,6 +85,7 @@ public: signals: void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber); void showEventInTimeline(int eventId); + void resized(); public slots: void updateSelectedEvent(int eventId) const; @@ -95,6 +96,7 @@ private slots: protected: void contextMenuEvent(QContextMenuEvent *ev); + virtual void resizeEvent(QResizeEvent *event); private: class QmlProfilerEventsWidgetPrivate; diff --git a/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp new file mode 100644 index 0000000000..b39fb0d5ac --- /dev/null +++ b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp @@ -0,0 +1,255 @@ +#include "qmlprofilerstatewidget.h" + +#include <QPainter> + +#include <QVBoxLayout> +#include <QLabel> +#include <QProgressBar> +#include <QTime> + +namespace QmlProfiler { +namespace Internal { + +class QmlProfilerStateWidget::QmlProfilerStateWidgetPrivate +{ + public: + QmlProfilerStateWidgetPrivate(QmlProfilerStateWidget *qq) { Q_UNUSED(qq); } + + QLabel *text; + QProgressBar *progressBar; + QPixmap shadowPic; + + QmlProfilerStateManager *m_profilerState; + QmlProfilerDataModel *m_profilerDataModel; + + bool isRecording; + bool appKilled; + bool emptyList; + bool traceAvailable; + bool loadingDone; + QTime profilingTimer; + qint64 estimatedProfilingTime; +}; + + + +QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateManager, + QmlProfilerDataModel *dataModel, QWidget *parent) : + QWidget(parent), d(new QmlProfilerStateWidgetPrivate(this)) +{ + setObjectName("QML Profiler State Display"); + + // UI elements + QVBoxLayout *layout = new QVBoxLayout(this); + resize(200,70); + + d->shadowPic.load(QLatin1String(":/qmlprofiler/dialog_shadow.png")); + + d->text = new QLabel(this); + d->text->setAlignment(Qt::AlignCenter); + layout->addWidget(d->text); + + d->progressBar = new QProgressBar(this); + layout->addWidget(d->progressBar); + d->progressBar->setVisible(false); + + setLayout(layout); + + // internal state + d->isRecording = false; + d->appKilled = false; + d->traceAvailable = false; + d->loadingDone = true; + d->emptyList = true; + + // profiler state + d->m_profilerDataModel = dataModel; + connect(d->m_profilerDataModel,SIGNAL(stateChanged()), this, SLOT(dataStateChanged())); + connect(d->m_profilerDataModel,SIGNAL(countChanged()), this, SLOT(dataStateChanged())); + d->m_profilerState = stateManager; + connect(d->m_profilerState,SIGNAL(stateChanged()), this, SLOT(profilerStateChanged())); + connect(d->m_profilerState, SIGNAL(serverRecordingChanged()), + this, SLOT(profilerStateChanged())); + + updateDisplay(); + connect(parent,SIGNAL(resized()),this,SLOT(reposition())); +} + +QmlProfilerStateWidget::~QmlProfilerStateWidget() +{ + delete d; +} + +void QmlProfilerStateWidget::reposition() +{ + QWidget *parentWidget = qobject_cast<QWidget *>(parent()); + // positioning it at 2/3 height (it looks better) + move(parentWidget->width()/2 - width()/2, parentWidget->height()/3 - height()/2); +} + +void QmlProfilerStateWidget::paintEvent(QPaintEvent *event) +{ + QWidget::paintEvent(event); + + QPainter painter(this); + painter.save(); + + // Shadow + // there is no actual qpainter borderimage, hacking it here + int borderWidth = 4; + + // topleft + painter.drawPixmap(QRect(0, 0, borderWidth, borderWidth), + d->shadowPic, + QRect(0, 0, borderWidth, borderWidth)); + // topright + painter.drawPixmap(QRect(width()-borderWidth, 0, borderWidth, borderWidth), + d->shadowPic, + QRect(d->shadowPic.width()-borderWidth, 0, borderWidth, borderWidth)); + // bottomleft + painter.drawPixmap(QRect(0, height()-borderWidth, borderWidth, borderWidth), + d->shadowPic, + QRect(0, d->shadowPic.height()-borderWidth, borderWidth, borderWidth)); + // bottomright + painter.drawPixmap(QRect(width()-borderWidth, height()-borderWidth, borderWidth, borderWidth), + d->shadowPic, + QRect(d->shadowPic.width()-borderWidth, + d->shadowPic.height()-borderWidth, + borderWidth, + borderWidth)); + // top + painter.drawPixmap(QRect(borderWidth, 0, width()-2*borderWidth, borderWidth), + d->shadowPic, + QRect(borderWidth, 0, d->shadowPic.width()-2*borderWidth, borderWidth)); + // bottom + painter.drawPixmap(QRect(borderWidth, height()-borderWidth, width()-2*borderWidth, borderWidth), + d->shadowPic, + QRect(borderWidth, + d->shadowPic.height()-borderWidth, + d->shadowPic.width()-2*borderWidth, + borderWidth)); + // left + painter.drawPixmap(QRect(0, borderWidth, borderWidth, height()-2*borderWidth), + d->shadowPic, + QRect(0, borderWidth, borderWidth, d->shadowPic.height()-2*borderWidth)); + // right + painter.drawPixmap(QRect(width()-borderWidth, borderWidth, borderWidth, height()-2*borderWidth), + d->shadowPic, + QRect(d->shadowPic.width()-borderWidth, + borderWidth, + borderWidth, + d->shadowPic.height()-2*borderWidth)); + // center + painter.drawPixmap(QRect(borderWidth, borderWidth, width()-2*borderWidth, height()-2*borderWidth), + d->shadowPic, + QRect(borderWidth, + borderWidth, + d->shadowPic.width()-2*borderWidth, + d->shadowPic.height()-2*borderWidth)); + + + // Background + painter.setBrush(QColor("#E0E0E0")); + painter.setPen(QColor("#666666")); + painter.drawRoundedRect(QRect(borderWidth, 0, width()-2*borderWidth, height()-borderWidth), 6, 6); + + // restore painter + painter.restore(); + +} + +void QmlProfilerStateWidget::updateDisplay() +{ + // When datamodel is acquiring data + if (!d->loadingDone && !d->emptyList && !d->appKilled) { + setVisible(true); + d->text->setText(tr("Loading data")); + if (d->isRecording) { + d->isRecording = false; + d->estimatedProfilingTime = d->profilingTimer.elapsed(); + } + d->progressBar->setMaximum(d->estimatedProfilingTime); + d->progressBar->setValue(d->m_profilerDataModel->lastTimeMark() * 1e-6); + d->progressBar->setVisible(true); + resize(300,70); + reposition(); + return; + } + + // When application is being profiled + if (d->isRecording) { + setVisible(true); + d->progressBar->setVisible(false); + d->text->setText(tr("Profiling application")); + resize(200,70); + reposition(); + return; + } + + // After profiling, there is an empty trace + if (d->traceAvailable && d->loadingDone && d->emptyList) { + setVisible(true); + d->progressBar->setVisible(false); + d->text->setText(tr("No QML events recorded")); + resize(200,70); + reposition(); + return; + } + + // Application died before all data could be read + if (!d->loadingDone && !d->emptyList && d->appKilled) { + setVisible(true); + d->text->setText(tr("Application stopped before loading all data")); + if (d->isRecording) { + d->isRecording = false; + d->estimatedProfilingTime = d->profilingTimer.elapsed(); + } + d->progressBar->setMaximum(d->estimatedProfilingTime); + d->progressBar->setValue(d->m_profilerDataModel->lastTimeMark() * 1e-6); + d->progressBar->setVisible(true); + resize(300,70); + reposition(); + return; + } + + // Everything empty (base state), commented out now but needed in the future. +// if (d->emptyList && d->loadingDone) { +// setVisible(true); +// d->progressBar->setVisible(false); +// d->text->setText(tr("Profiler ready")); +// resize(200,70); +// parentResized(); +// return; +// } + + // There is a trace on view, hide this dialog + setVisible(false); +} + +void QmlProfilerStateWidget::dataStateChanged() +{ + d->loadingDone = d->m_profilerDataModel->currentState() == QmlProfilerDataModel::Done || + d->m_profilerDataModel->currentState() == QmlProfilerDataModel::Empty; + d->traceAvailable = d->m_profilerDataModel->traceDuration() > 0; + d->emptyList = d->m_profilerDataModel->count() == 0; + updateDisplay(); +} + +void QmlProfilerStateWidget::profilerStateChanged() +{ + if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppKilled) + d->appKilled = true; + else + if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppStarting) + d->appKilled = false; + + d->isRecording = d->m_profilerState->serverRecording(); + if (d->isRecording) + d->profilingTimer.start(); + else + d->estimatedProfilingTime = d->profilingTimer.elapsed(); + updateDisplay(); +} + +} +} diff --git a/src/plugins/qmlprofiler/qmlprofilerstatewidget.h b/src/plugins/qmlprofiler/qmlprofilerstatewidget.h new file mode 100644 index 0000000000..06c2914174 --- /dev/null +++ b/src/plugins/qmlprofiler/qmlprofilerstatewidget.h @@ -0,0 +1,37 @@ +#ifndef QMLPROFILERSTATEWIDGET_H +#define QMLPROFILERSTATEWIDGET_H + +#include <QWidget> + +#include "qmlprofilerstatemanager.h" +#include "qmlprofilerdatamodel.h" + +namespace QmlProfiler { +namespace Internal { + +class QmlProfilerStateWidget : public QWidget +{ + Q_OBJECT +public: + explicit QmlProfilerStateWidget(QmlProfilerStateManager *stateManager, + QmlProfilerDataModel *dataModel, QWidget *parent = 0); + ~QmlProfilerStateWidget(); + +private slots: + void updateDisplay(); + void dataStateChanged(); + void profilerStateChanged(); + void reposition(); + +protected: + void paintEvent(QPaintEvent *event); + +private: + class QmlProfilerStateWidgetPrivate; + QmlProfilerStateWidgetPrivate *d; +}; + +} +} + +#endif // QMLPROFILERSTATEWIDGET_H diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp index 5cd35c2418..5e4ec106db 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp @@ -478,11 +478,13 @@ void QmlProfilerTraceView::updateVerticalScroll(int newPosition) void QmlProfilerTraceView::resizeEvent(QResizeEvent *event) { + QWidget::resizeEvent(event); if (d->m_mainView->rootObject()) { d->m_mainView->rootObject()->setProperty("width", QVariant(event->size().width())); int newHeight = event->size().height() - d->m_timebar->height() - d->m_overview->height(); d->m_mainView->rootObject()->setProperty("candidateHeight", QVariant(newHeight)); } + emit resized(); } //////////////////////////////////////////////////////////////// diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.h b/src/plugins/qmlprofiler/qmlprofilertraceview.h index 6b61380882..6798343588 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.h +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.h @@ -138,6 +138,8 @@ signals: void enableToolbar(bool); void zoomLevelChanged(int); + void resized(); + private: void contextMenuEvent(QContextMenuEvent *); QWidget *createToolbar(); diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp index b243174104..29ee0403c4 100644 --- a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp @@ -37,12 +37,12 @@ #include "qmlprofilertool.h" #include "qmlprofilerstatemanager.h" #include "qmlprofilerdatamodel.h" +#include "qmlprofilerstatewidget.h" #include <utils/qtcassert.h> #include <utils/fancymainwindow.h> #include <analyzerbase/analyzermanager.h> - #include <QDockWidget> using namespace Analyzer; @@ -134,6 +134,10 @@ void QmlProfilerViewManager::createViews() mw->splitDockWidget(mw->toolBarDockWidget(), timelineDock, Qt::Vertical); mw->tabifyDockWidget(timelineDock, eventsDock); mw->tabifyDockWidget(eventsDock, v8profilerDock); + + new QmlProfilerStateWidget(d->profilerState, d->profilerDataModel, d->traceView); + new QmlProfilerStateWidget(d->profilerState, d->profilerDataModel, d->eventsView); + new QmlProfilerStateWidget(d->profilerState, d->profilerDataModel, d->v8profilerView); } bool QmlProfilerViewManager::hasValidSelection() const |