summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2011-04-04 15:03:31 +0200
committerKai Koehne <kai.koehne@nokia.com>2011-04-04 15:59:31 +0200
commit12a02c75341745777487574775b299193af6c2d7 (patch)
tree0f2a0a83b8f0fca854b86de64c3e77603c2c7b4a /src/plugins
parent02ea91442678362ba2edae5662c87dad7f46dab6 (diff)
downloadqt-creator-12a02c75341745777487574775b299193af6c2d7.tar.gz
QmlProfiler: Add attach/detach menu entry
This allows one to also profile apps on device (as long as there is a working TCP/IP connection).
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/qmlprofiler/qmlprofiler.pro9
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp40
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerattachdialog.h34
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerattachdialog.ui109
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerconstants.h6
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerengine.cpp19
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.cpp64
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.h2
8 files changed, 275 insertions, 8 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro
index 261ea8e30e..304da3d5dd 100644
--- a/src/plugins/qmlprofiler/qmlprofiler.pro
+++ b/src/plugins/qmlprofiler/qmlprofiler.pro
@@ -18,7 +18,8 @@ SOURCES += \
qmlprofilertool.cpp \
qmlprofilerengine.cpp \
tracewindow.cpp \
- timelineview.cpp
+ timelineview.cpp \
+ qmlprofilerattachdialog.cpp
HEADERS += \
qmlprofilerconstants.h \
@@ -27,7 +28,8 @@ HEADERS += \
qmlprofilertool.h \
qmlprofilerengine.h \
tracewindow.h \
- timelineview.h
+ timelineview.h \
+ qmlprofilerattachdialog.h
RESOURCES += \
qml/qml.qrc
@@ -42,3 +44,6 @@ OTHER_FILES += \
RecordButton.qml \
ToolButton.qml \
MainView.js
+
+FORMS += \
+ qmlprofilerattachdialog.ui
diff --git a/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp b/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp
new file mode 100644
index 0000000000..d4d08180b7
--- /dev/null
+++ b/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp
@@ -0,0 +1,40 @@
+#include "qmlprofilerattachdialog.h"
+#include "ui_qmlprofilerattachdialog.h"
+
+namespace QmlProfiler {
+namespace Internal {
+
+QmlProfilerAttachDialog::QmlProfilerAttachDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::QmlProfilerAttachDialog)
+{
+ ui->setupUi(this);
+}
+
+QmlProfilerAttachDialog::~QmlProfilerAttachDialog()
+{
+ delete ui;
+}
+
+QString QmlProfilerAttachDialog::address() const
+{
+ return ui->addressLineEdit->text();
+}
+
+uint QmlProfilerAttachDialog::port() const
+{
+ return ui->portSpinBox->value();
+}
+
+void QmlProfilerAttachDialog::setAddress(const QString &address)
+{
+ ui->addressLineEdit->setText(address);
+}
+
+void QmlProfilerAttachDialog::setPort(uint port)
+{
+ ui->portSpinBox->setValue(port);
+}
+
+} // namespace Internal
+} // namespace QmlProfiler
diff --git a/src/plugins/qmlprofiler/qmlprofilerattachdialog.h b/src/plugins/qmlprofiler/qmlprofilerattachdialog.h
new file mode 100644
index 0000000000..ac85df7918
--- /dev/null
+++ b/src/plugins/qmlprofiler/qmlprofilerattachdialog.h
@@ -0,0 +1,34 @@
+#ifndef QMLPROFILERATTACHDIALOG_H
+#define QMLPROFILERATTACHDIALOG_H
+
+#include <QDialog>
+
+namespace QmlProfiler {
+namespace Internal {
+
+namespace Ui {
+ class QmlProfilerAttachDialog;
+}
+
+class QmlProfilerAttachDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit QmlProfilerAttachDialog(QWidget *parent = 0);
+ ~QmlProfilerAttachDialog();
+
+ QString address() const;
+ uint port() const;
+
+ void setAddress(const QString &address);
+ void setPort(uint port);
+
+private:
+ Ui::QmlProfilerAttachDialog *ui;
+};
+
+} // namespace Internal
+} // namespace QmlProfiler
+
+#endif // QMLPROFILERATTACHDIALOG_H
diff --git a/src/plugins/qmlprofiler/qmlprofilerattachdialog.ui b/src/plugins/qmlprofiler/qmlprofilerattachdialog.ui
new file mode 100644
index 0000000000..5bae9fee4c
--- /dev/null
+++ b/src/plugins/qmlprofiler/qmlprofilerattachdialog.ui
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QmlProfiler::Internal::QmlProfilerAttachDialog</class>
+ <widget class="QDialog" name="QmlProfiler::Internal::QmlProfilerAttachDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>164</width>
+ <height>96</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="addressLabel">
+ <property name="text">
+ <string>Address:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="addressLineEdit">
+ <property name="text">
+ <string>127.0.0.1</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="portLabel">
+ <property name="text">
+ <string>Port:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="portSpinBox">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ <property name="value">
+ <number>3768</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>QmlProfiler::Internal::QmlProfilerAttachDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>QmlProfiler::Internal::QmlProfilerAttachDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/plugins/qmlprofiler/qmlprofilerconstants.h b/src/plugins/qmlprofiler/qmlprofilerconstants.h
index 453df79393..dbb2b0c9ee 100644
--- a/src/plugins/qmlprofiler/qmlprofilerconstants.h
+++ b/src/plugins/qmlprofiler/qmlprofilerconstants.h
@@ -37,11 +37,9 @@
namespace QmlProfiler {
namespace Constants {
- const char * const ACTION_ID = "QmlProfilerPlugin.Action";
- const char * const MENU_ID = "QmlProfilerPlugin.Menu";
+const char * const ATTACH = "Menu.Analyzer.Attach";
-} // namespace QmlProfiler
} // namespace Constants
+} // namespace QmlProfiler
#endif // QMLPROFILERCONSTANTS_H
-
diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp
index 357d5588ca..74f2e076cd 100644
--- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp
@@ -69,6 +69,7 @@ public:
~QmlProfilerEnginePrivate() {}
bool launchperfmonitor();
+ bool attach(const QString &address, uint port);
QmlProfilerEngine *q;
@@ -178,3 +179,21 @@ bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
return true;
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp
index 67a0e5a8f4..3a4b858baf 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp
@@ -34,6 +34,8 @@
#include "qmlprofilertool.h"
#include "qmlprofilerengine.h"
#include "qmlprofilerplugin.h"
+#include "qmlprofilerconstants.h"
+#include "qmlprofilerattachdialog.h"
#include "tracewindow.h"
#include <private/qdeclarativedebugclient_p.h>
@@ -56,7 +58,11 @@
#include <projectexplorer/target.h>
#include <texteditor/itexteditor.h>
+#include <coreplugin/actionmanager/actioncontainer.h>
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/icore.h>
#include <QtCore/QFile>
@@ -107,6 +113,9 @@ public:
QmlProfilerOutputPaneAdapter *m_outputPaneAdapter;
ProjectExplorer::Project *m_project;
Utils::FileInProjectFinder m_projectFinder;
+ ProjectExplorer::RunConfiguration *m_runConfiguration;
+ bool m_isAttached;
+ QAction *m_attachAction;
};
QmlProfilerTool::QmlProfilerTool(QObject *parent)
@@ -116,6 +125,9 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
d->m_traceWindow = 0;
d->m_outputPaneAdapter = 0;
d->m_project = 0;
+ d->m_runConfiguration = 0;
+ d->m_isAttached = false;
+ d->m_attachAction = 0;
}
QmlProfilerTool::~QmlProfilerTool()
@@ -148,6 +160,7 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
{
QmlProfilerEngine *engine = new QmlProfilerEngine(sp, runConfiguration);
+ d->m_runConfiguration = runConfiguration;
d->m_project = runConfiguration->target()->project();
if (d->m_project) {
d->m_projectFinder.setProjectDirectory(d->m_project->projectDirectory());
@@ -159,8 +172,6 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
connect(engine, SIGNAL(processTerminated()), this, SLOT(disconnectClient()));
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;
}
@@ -178,6 +189,22 @@ void QmlProfilerTool::initialize(ExtensionSystem::IPlugin */*plugin*/)
d->m_client = new QDeclarativeDebugConnection;
d->m_traceWindow = new TraceWindow();
d->m_traceWindow->reset(d->m_client);
+
+ connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
+ connect(d->m_traceWindow, SIGNAL(timeChanged(qreal)), this, SLOT(updateTimer(qreal)));
+
+ Core::ICore *core = Core::ICore::instance();
+ Core::ActionManager *am = core->actionManager();
+ Core::ActionContainer *manalyzer = am->actionContainer(Analyzer::Constants::M_DEBUG_ANALYZER);
+ const Core::Context globalcontext(Core::Constants::C_GLOBAL);
+
+ d->m_attachAction = new QAction(tr("Attach ..."), manalyzer);
+ Core::Command *command = am->registerAction(d->m_attachAction,
+ Constants::ATTACH, globalcontext);
+ command->setAttribute(Core::Command::CA_UpdateText);
+ manalyzer->addAction(command, Analyzer::Constants::G_ANALYZER_STARTSTOP);
+ connect(d->m_attachAction, SIGNAL(triggered()), this, SLOT(attach()));
+ updateAttachAction();
}
void QmlProfilerTool::extensionsInitialized()
@@ -285,3 +312,36 @@ bool QmlProfilerTool::canRunRemotely() const
// TODO: Is this correct?
return true;
}
+
+void QmlProfilerTool::attach()
+{
+ if (!d->m_isAttached) {
+ QmlProfilerAttachDialog dialog;
+ int result = dialog.exec();
+
+ if (result == QDialog::Rejected)
+ return;
+
+ port = dialog.port();
+ host = dialog.address();
+
+ connectClient();
+ AnalyzerManager::instance()->showMode();
+ } else {
+ stopRecording();
+ }
+
+ d->m_isAttached = !d->m_isAttached;
+ updateAttachAction();
+}
+
+void QmlProfilerTool::updateAttachAction()
+{
+ if (d->m_attachAction) {
+ if (d->m_isAttached) {
+ d->m_attachAction->setText(tr("Detach"));
+ } else {
+ d->m_attachAction->setText(tr("Attach..."));
+ }
+ }
+}
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h
index 8663e974d8..ad347b143f 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.h
+++ b/src/plugins/qmlprofiler/qmlprofilertool.h
@@ -82,6 +82,8 @@ public:
private slots:
void updateProjectFileList();
+ void attach();
+ void updateAttachAction();
private:
class QmlProfilerToolPrivate;