summaryrefslogtreecommitdiff
path: root/src/plugins/qmlprofiler
diff options
context:
space:
mode:
authorChristiaan Janssen <christiaan.janssen@nokia.com>2011-04-06 12:26:19 +0200
committerChristiaan Janssen <christiaan.janssen@nokia.com>2011-04-06 12:59:29 +0200
commitfad891820d40893bae3dae0a4165fc27d732510b (patch)
tree34ffa75aae7a22a496a5f49b0aa4c6359101ed20 /src/plugins/qmlprofiler
parent360b2addb3ac9337cf4c2692dc4d1779815d2723 (diff)
downloadqt-creator-fad891820d40893bae3dae0a4165fc27d732510b.tar.gz
qQmlProfiler: independent start/stop/record buttons
Reviewed-by: Kai Koehne
Diffstat (limited to 'src/plugins/qmlprofiler')
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp2
-rw-r--r--src/plugins/qmlprofiler/qml/MainView.qml7
-rw-r--r--src/plugins/qmlprofiler/qml/analyzer_category_small.pngbin0 -> 705 bytes
-rw-r--r--src/plugins/qmlprofiler/qml/qml.qrc1
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerengine.cpp40
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerengine.h5
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.cpp42
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.h3
-rw-r--r--src/plugins/qmlprofiler/tracewindow.cpp5
-rw-r--r--src/plugins/qmlprofiler/tracewindow.h1
10 files changed, 84 insertions, 22 deletions
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp
index a98b707dbe..dfabe1f46c 100644
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp
+++ b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp
@@ -50,7 +50,7 @@
#include <QtGui/qapplication.h>
#include <QtGui/qgraphicseffect.h>
-#include <QImage>
+#include <QtGui/QImage>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml
index e8e3e5c7ff..297c6ceabf 100644
--- a/src/plugins/qmlprofiler/qml/MainView.qml
+++ b/src/plugins/qmlprofiler/qml/MainView.qml
@@ -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: {
diff --git a/src/plugins/qmlprofiler/qml/analyzer_category_small.png b/src/plugins/qmlprofiler/qml/analyzer_category_small.png
new file mode 100644
index 0000000000..5bc90fbf91
--- /dev/null
+++ b/src/plugins/qmlprofiler/qml/analyzer_category_small.png
Binary files differ
diff --git a/src/plugins/qmlprofiler/qml/qml.qrc b/src/plugins/qmlprofiler/qml/qml.qrc
index e60001311f..84e33bfc89 100644
--- a/src/plugins/qmlprofiler/qml/qml.qrc
+++ b/src/plugins/qmlprofiler/qml/qml.qrc
@@ -11,5 +11,6 @@
<file>RangeMover.qml</file>
<file>RecordButton.qml</file>
<file>ToolButton.qml</file>
+ <file>analyzer_category_small.png</file>
</qresource>
</RCC>
diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp
index 74f2e076cd..5ddeee44dd 100644
--- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp
@@ -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()
diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.h b/src/plugins/qmlprofiler/qmlprofilerengine.h
index b4d5122cf3..5fc49aa7cc 100644
--- a/src/plugins/qmlprofiler/qmlprofilerengine.h
+++ b/src/plugins/qmlprofiler/qmlprofilerengine.h
@@ -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;
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp
index 5c93421223..6992ffd8eb 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp
@@ -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)
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h
index ad347b143f..ee721d8bef 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.h
+++ b/src/plugins/qmlprofiler/qmlprofilertool.h
@@ -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
diff --git a/src/plugins/qmlprofiler/tracewindow.cpp b/src/plugins/qmlprofiler/tracewindow.cpp
index 8725406236..8c70afe0e2 100644
--- a/src/plugins/qmlprofiler/tracewindow.cpp
+++ b/src/plugins/qmlprofiler/tracewindow.cpp
@@ -322,4 +322,9 @@ void TraceWindow::setRecording(bool recording)
m_plugin->setRecording(recording);
}
+bool TraceWindow::isRecording() const
+{
+ return (m_plugin->recording());
+}
+
#include "tracewindow.moc"
diff --git a/src/plugins/qmlprofiler/tracewindow.h b/src/plugins/qmlprofiler/tracewindow.h
index c1b8085829..bdd5a546bb 100644
--- a/src/plugins/qmlprofiler/tracewindow.h
+++ b/src/plugins/qmlprofiler/tracewindow.h
@@ -66,6 +66,7 @@ public:
void setRecordAtStart(bool record);
void setRecording(bool recording);
+ bool isRecording() const;
public slots:
void updateCursorPosition();