Commit fbe9925d authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlProfiler: ongoing work

parent 66413d9a
......@@ -96,10 +96,10 @@ public:
public slots:
void showStatusMessage(const QString &message, int timeoutMS = 10000);
void showPermanentStatusMessage(const QString &message);
private slots:
void startTool();
void stopTool();
private slots:
void handleToolFinished();
void toolSelected(int);
void toolSelected(QAction *);
......
import QtQuick 1.1
import Monitor 1.0
import "MainView.js" as Plotter
Text {
id: elapsed
color: "white"
Timer {
property date startDate
property bool reset: true
running: connection.recording
repeat: true
onRunningChanged: if (running) reset = true
interval: 100
triggeredOnStart: true
onTriggered: {
if (reset) {
startDate = new Date()
reset = false
}
var time = (new Date() - startDate)/1000
elapsed.text = time.toFixed(1) + "s"
}
}
}
......@@ -60,6 +60,29 @@ Rectangle {
}
// Elapsed
property real elapsedTime;
signal updateTimer;
Timer {
property date startDate
property bool reset: true
running: connection.recording
repeat: true
onRunningChanged: if (running) reset = true
interval: 100
triggeredOnStart: true
onTriggered: {
if (reset) {
startDate = new Date()
reset = false
}
var time = (new Date() - startDate)/1000
//elapsed.text = time.toFixed(1) + "s"
root.elapsedTime = time.toFixed(1);
root.updateTimer();
}
}
//timeline background
Item {
anchors.fill: flick
......@@ -246,17 +269,4 @@ Rectangle {
anchors.top: canvas.top
}
Rectangle {
width: 50
height: 30
anchors.right: root.right
anchors.top: root.top
radius: 4
color: "#606085"
Elapsed {
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
}
}
}
<RCC>
<qresource prefix="/qml">
<file>Detail.qml</file>
<file>Elapsed.qml</file>
<file>Label.qml</file>
<file>lock.png</file>
<file>MainView.js</file>
......
......@@ -3,6 +3,9 @@
#include "qmlprofilerplugin.h"
#include "qmlprofilertool.h"
#include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzerconstants.h>
#include <projectexplorer/applicationrunconfiguration.h>
#include <private/qdeclarativedebugclient_p.h>
......@@ -83,16 +86,27 @@ void QmlProfilerEngine::stop()
emit stopRecording();
}
void QmlProfilerEngine::spontaneousStop()
{
AnalyzerManager::instance()->stopTool();
}
void QmlProfilerEngine::viewUpdated()
{
d->m_process->terminate();
if (!d->m_process->waitForFinished(1000)) {
d->m_process->kill();
d->m_process->waitForFinished();
if (d->m_process) {
disconnect(d->m_process,SIGNAL(finished(int)),this,SLOT(spontaneousStop()));
if (d->m_process->state() == QProcess::Running) {
d->m_process->terminate();
if (!d->m_process->waitForFinished(1000)) {
d->m_process->kill();
d->m_process->waitForFinished();
}
}
delete d->m_process;
d->m_process = 0;
}
emit processTerminated();
delete d->m_process;
}
bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
......@@ -113,16 +127,18 @@ bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
m_process->setProcessChannelMode(QProcess::ForwardedChannels);
m_process->setWorkingDirectory(m_workingDirectory);
connect(m_process,SIGNAL(finished(int)),q,SLOT(spontaneousStop()));
m_process->start(m_executable, arguments);
// give the process time to start
sleep(1);
if (!m_process->waitForStarted()) {
if (QmlProfilerPlugin::debugOutput)
qWarning("QmlProfiler: %s failed to start", qPrintable(m_executable));
return false;
}
sleep(1);
if (QmlProfilerPlugin::debugOutput)
qWarning("QmlProfiler: Connecting to %s:%d", qPrintable(QmlProfilerTool::host), QmlProfilerTool::port);
......
......@@ -14,15 +14,16 @@ public:
explicit QmlProfilerEngine(ProjectExplorer::RunConfiguration *runConfiguration);
~QmlProfilerEngine();
void start();
void stop();
signals:
void processRunning();
void processTerminated();
void stopRecording();
public slots:
void start();
void stop();
void spontaneousStop();
void viewUpdated();
private:
......
......@@ -25,12 +25,15 @@
#include <QtCore/QFile>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
using namespace Analyzer;
using namespace Analyzer::Internal;
QString QmlProfilerTool::host = QLatin1String("localhost");
quint16 QmlProfilerTool::port = 33455;
quint16 QmlProfilerTool::port = 33456;
// Adapter for output pane.
......@@ -112,6 +115,7 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(ProjectExplorer::RunConfiguration
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(viewUpdated()));
connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
connect(d->m_traceWindow, SIGNAL(timeChanged(qreal)), this, SLOT(updateTimer(qreal)));
return engine;
......@@ -142,7 +146,23 @@ IAnalyzerOutputPaneAdapter *QmlProfilerTool::outputPaneAdapter()
QWidget *QmlProfilerTool::createToolBarWidget()
{
// custom toolbar (TODO)
return 0;
QWidget *toolbarWidget = new QWidget;
toolbarWidget->setObjectName(QLatin1String("QmlProfilerToolBarWidget"));
QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(0);
layout->setSpacing(0);
QLabel *timeLabel = new QLabel(tr("elapsed: 0 s"));
QPalette palette = timeLabel->palette();
palette.setColor(QPalette::WindowText, Qt::white);
timeLabel->setPalette(palette);
connect(this,SIGNAL(setTimeLabel(QString)),timeLabel,SLOT(setText(QString)));
layout->addWidget(timeLabel);
toolbarWidget->setLayout(layout);
return toolbarWidget;
}
QWidget *QmlProfilerTool::createTimeLineWidget()
......@@ -203,3 +223,10 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileName, int lineNumber
textEditor->widget()->setFocus();
}
}
void QmlProfilerTool::updateTimer(qreal elapsedSeconds)
{
QString timeString = QString::number(elapsedSeconds,'f',1);
timeString = QString(" ").left(6-timeString.length()) + timeString;
emit setTimeLabel(tr("elapsed: ")+timeString+QLatin1String(" s"));
}
......@@ -33,6 +33,10 @@ public slots:
void stopRecording();
void gotoSourceLocation(const QString &fileName, int lineNumber);
void updateTimer(qreal elapsedSeconds);
signals:
void setTimeLabel(const QString &);
public:
// Todo: configurable parameters
......
......@@ -288,6 +288,7 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn)
m_view->setSource(QUrl("qrc:/qml/MainView.qml"));
connect(m_view->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
connect(m_view->rootObject(), SIGNAL(updateTimer()), this, SLOT(updateTimer()));
}
void TraceWindow::updateCursorPosition()
......@@ -296,6 +297,11 @@ void TraceWindow::updateCursorPosition()
m_view->rootObject()->property("lineNumber").toInt());
}
void TraceWindow::updateTimer()
{
emit timeChanged(m_view->rootObject()->property("elapsedTime").toDouble());
}
void TraceWindow::setRecordAtStart(bool record)
{
m_recordAtStart = record;
......
......@@ -60,10 +60,12 @@ public:
public slots:
void updateCursorPosition();
void updateTimer();
signals:
void viewUpdated();
void gotoSourceLocation(const QString &fileName, int lineNumber);
void timeChanged(qreal newTime);
private:
TracePlugin *m_plugin;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment