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

qQmlProfiler: independent start/stop/record buttons

Reviewed-by: Kai Koehne
parent 360b2add
......@@ -50,7 +50,7 @@
#include <QtGui/qapplication.h>
#include <QtGui/qgraphicseffect.h>
#include <QImage>
#include <QtGui/QImage>
QT_BEGIN_NAMESPACE
......
......@@ -205,7 +205,12 @@ Rectangle {
preferredX = rangeDetails.parent.width - rangeDetails.width
rangeDetails.x = preferredX
rangeDetails.y = pos.y + 10
var preferredY = pos.y - rangeDetails.height/2;
if (preferredY + rangeDetails.height > root.height - 10)
preferredY = root.height - 10 - rangeDetails.height;
if (preferredY < 10)
preferredY=10;
rangeDetails.y = preferredY;
rangeDetails.visible = true
}
onExited: {
......
......@@ -11,5 +11,6 @@
<file>RangeMover.qml</file>
<file>RecordButton.qml</file>
<file>ToolButton.qml</file>
<file>analyzer_category_small.png</file>
</qresource>
</RCC>
......@@ -80,6 +80,7 @@ public:
QProcess *m_process;
bool m_running;
bool m_fetchingData;
};
QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration)
......@@ -98,6 +99,7 @@ QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp
d->m_environment = localAppConfig->environment();
d->m_process = 0;
d->m_running = false;
d->m_fetchingData = false;
}
QmlProfilerEngine::~QmlProfilerEngine()
......@@ -118,30 +120,42 @@ void QmlProfilerEngine::start()
void QmlProfilerEngine::stop()
{
d->m_running = false;
emit stopRecording();
if (d->m_fetchingData)
emit stopRecording();
else
finishProcess();
}
void QmlProfilerEngine::spontaneousStop()
{
d->m_running = false;
Analyzer::AnalyzerManager::instance()->stopTool();
emit finished();
}
void QmlProfilerEngine::viewUpdated()
void QmlProfilerEngine::setFetchingData(bool b) {
d->m_fetchingData = b;
}
void QmlProfilerEngine::finishProcess()
{
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();
// user stop?
if (!d->m_running) {
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;
}
delete d->m_process;
d->m_process = 0;
}
emit processTerminated();
emit finished();
}
}
bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
......
......@@ -49,7 +49,7 @@ public:
signals:
void processRunning();
void processTerminated();
//void finished();
void stopRecording();
public slots:
......@@ -57,7 +57,8 @@ public slots:
void stop();
void spontaneousStop();
void viewUpdated();
void setFetchingData(bool);
void finishProcess();
private:
class QmlProfilerEnginePrivate;
......
......@@ -68,6 +68,7 @@
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QToolButton>
using namespace Analyzer;
using namespace QmlProfiler::Internal;
......@@ -116,6 +117,7 @@ public:
ProjectExplorer::RunConfiguration *m_runConfiguration;
bool m_isAttached;
QAction *m_attachAction;
QToolButton *m_recordButton;
};
QmlProfilerTool::QmlProfilerTool(QObject *parent)
......@@ -169,9 +171,11 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
}
connect(engine, SIGNAL(processRunning()), this, SLOT(connectClient()));
connect(engine, SIGNAL(processTerminated()), this, SLOT(disconnectClient()));
connect(engine, SIGNAL(finished()), this, SLOT(disconnectClient()));
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(viewUpdated()));
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(finishProcess()));
connect(this, SIGNAL(fetchingData(bool)), engine, SLOT(setFetchingData(bool)));
emit fetchingData(d->m_recordButton->isChecked());
return engine;
}
......@@ -233,6 +237,15 @@ QWidget *QmlProfilerTool::createToolBarWidget()
layout->setMargin(0);
layout->setSpacing(0);
d->m_recordButton = new QToolButton(toolbarWidget);
d->m_recordButton->setIcon(QIcon(QLatin1String(":/qmlprofiler/analyzer_category_small.png")));
d->m_recordButton->setCheckable(true);
connect(d->m_recordButton,SIGNAL(toggled(bool)), this, SLOT(setRecording(bool)));
d->m_recordButton->setChecked(true);
layout->addWidget(d->m_recordButton);
QLabel *timeLabel = new QLabel(tr("elapsed: 0 s"));
QPalette palette = timeLabel->palette();
palette.setColor(QPalette::WindowText, Qt::white);
......@@ -260,8 +273,7 @@ void QmlProfilerTool::connectClient()
d->m_client->connectToHost(host, port);
d->m_client->waitForConnected();
if (d->m_client->state() == QDeclarativeDebugConnection::ConnectedState) {
d->m_traceWindow->setRecording(true);
if (d->m_client->isConnected()) {
if (QmlProfilerPlugin::debugOutput)
qWarning("QmlProfiler: connected and running");
} else {
......@@ -275,9 +287,29 @@ void QmlProfilerTool::disconnectClient()
d->m_client->disconnectFromHost();
}
void QmlProfilerTool::startRecording()
{
d->m_traceWindow->setRecordAtStart(true);
if (d->m_client->isConnected())
d->m_traceWindow->setRecording(true);
emit fetchingData(true);
}
void QmlProfilerTool::stopRecording()
{
d->m_traceWindow->setRecording(false);
d->m_traceWindow->setRecordAtStart(d->m_recordButton->isChecked());
if (d->m_client->isConnected())
d->m_traceWindow->setRecording(false);
emit fetchingData(false);
}
void QmlProfilerTool::setRecording(bool recording)
{
if (recording)
startRecording();
else
stopRecording();
}
void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber)
......
......@@ -67,13 +67,16 @@ public slots:
void connectClient();
void disconnectClient();
void startRecording();
void stopRecording();
void setRecording(bool recording);
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
void updateTimer(qreal elapsedSeconds);
signals:
void setTimeLabel(const QString &);
void fetchingData(bool);
public:
// Todo: configurable parameters
......
......@@ -322,4 +322,9 @@ void TraceWindow::setRecording(bool recording)
m_plugin->setRecording(recording);
}
bool TraceWindow::isRecording() const
{
return (m_plugin->recording());
}
#include "tracewindow.moc"
......@@ -66,6 +66,7 @@ public:
void setRecordAtStart(bool record);
void setRecording(bool recording);
bool isRecording() const;
public slots:
void updateCursorPosition();
......
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