From 22fcb71a8e2d31064d4f9622a09c42e784cdba02 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Fri, 26 Apr 2013 10:23:14 +0200 Subject: [PATCH] QmlProfiling: Attach to QML application Redo the Attach dialog to use Kits. This is in sync with the Valgrind Attach dialog. Change-Id: Iaf0c8bc2c5a912b6a93ed21b9757a074a60041c0 Reviewed-by: Christiaan Janssen --- src/plugins/qmlprofiler/qmlprofiler.pro | 3 - src/plugins/qmlprofiler/qmlprofiler.qbs | 1 - .../qmlprofiler/qmlprofilerattachdialog.cpp | 74 +++++++++++++------ .../qmlprofiler/qmlprofilerattachdialog.h | 20 +++-- src/plugins/qmlprofiler/qmlprofilertool.cpp | 36 +++++---- 5 files changed, 82 insertions(+), 52 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index 208b4df8ab2..c1c2308e974 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -59,6 +59,3 @@ OTHER_FILES += \ qml/SelectionRange.qml \ qml/SelectionRangeDetails.qml \ qml/Overview.qml - -FORMS += \ - qmlprofilerattachdialog.ui diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs index 7a58efc55b9..ff518734fe1 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.qbs +++ b/src/plugins/qmlprofiler/qmlprofiler.qbs @@ -30,7 +30,6 @@ QtcPlugin { "qmlprofiler_global.h", "qmlprofilerattachdialog.cpp", "qmlprofilerattachdialog.h", - "qmlprofilerattachdialog.ui", "qmlprofilerclientmanager.cpp", "qmlprofilerclientmanager.h", "qmlprofilerconstants.h", diff --git a/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp b/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp index 4b61843f4ac..53eb3f68a06 100644 --- a/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerattachdialog.cpp @@ -28,51 +28,81 @@ ****************************************************************************/ #include "qmlprofilerattachdialog.h" -#include "ui_qmlprofilerattachdialog.h" + +#include + +#include + +#include +#include +#include +#include + +using namespace ProjectExplorer; namespace QmlProfiler { namespace Internal { +class QmlProfilerAttachDialogPrivate +{ +public: + QSpinBox *portSpinBox; + KitChooser *kitChooser; +}; + QmlProfilerAttachDialog::QmlProfilerAttachDialog(QWidget *parent) : QDialog(parent), - ui(new Ui::QmlProfilerAttachDialog) + d(new QmlProfilerAttachDialogPrivate) { - ui->setupUi(this); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + setWindowTitle(tr("Start QML Profiler")); + + d->kitChooser = new KitChooser(this); + d->kitChooser->populate(); + + d->portSpinBox = new QSpinBox(this); + d->portSpinBox->setMaximum(65535); + d->portSpinBox->setValue(3768); + + QDialogButtonBox *buttonBox = new QDialogButtonBox(this); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); + + QFormLayout *formLayout = new QFormLayout(); + formLayout->addRow(tr("Kit:"), d->kitChooser); + formLayout->addRow(tr("&Port:"), d->portSpinBox); + + QVBoxLayout *verticalLayout = new QVBoxLayout(this); + verticalLayout->addLayout(formLayout); + verticalLayout->addWidget(buttonBox); + + connect(buttonBox, SIGNAL(accepted()), SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), SLOT(reject())); } QmlProfilerAttachDialog::~QmlProfilerAttachDialog() { - delete ui; + delete d; } -QString QmlProfilerAttachDialog::address() const +int QmlProfilerAttachDialog::port() const { - return ui->addressLineEdit->text(); + return d->portSpinBox->value(); } -uint QmlProfilerAttachDialog::port() const +void QmlProfilerAttachDialog::setPort(const int port) { - return ui->portSpinBox->value(); + d->portSpinBox->setValue(port); } -QString QmlProfilerAttachDialog::sysroot() const +ProjectExplorer::Kit *QmlProfilerAttachDialog::kit() const { - return ui->sysrootChooser->path(); + return d->kitChooser->currentKit(); } -void QmlProfilerAttachDialog::setAddress(const QString &address) +void QmlProfilerAttachDialog::setKitId(const Core::Id &id) { - ui->addressLineEdit->setText(address); -} - -void QmlProfilerAttachDialog::setPort(uint port) -{ - ui->portSpinBox->setValue(port); -} - -void QmlProfilerAttachDialog::setSysroot(const QString &sysroot) -{ - ui->sysrootChooser->setPath(sysroot); + d->kitChooser->setCurrentKitId(id); } } // namespace Internal diff --git a/src/plugins/qmlprofiler/qmlprofilerattachdialog.h b/src/plugins/qmlprofiler/qmlprofilerattachdialog.h index efb810a133a..739ba8bd1f2 100644 --- a/src/plugins/qmlprofiler/qmlprofilerattachdialog.h +++ b/src/plugins/qmlprofiler/qmlprofilerattachdialog.h @@ -32,13 +32,13 @@ #include +namespace Core { class Id; } +namespace ProjectExplorer { class Kit; } + namespace QmlProfiler { namespace Internal { -namespace Ui { - class QmlProfilerAttachDialog; -} - +class QmlProfilerAttachDialogPrivate; class QmlProfilerAttachDialog : public QDialog { Q_OBJECT @@ -47,16 +47,14 @@ public: explicit QmlProfilerAttachDialog(QWidget *parent = 0); ~QmlProfilerAttachDialog(); - QString address() const; - uint port() const; - QString sysroot() const; + int port() const; + void setPort(const int port); - void setAddress(const QString &address); - void setPort(uint port); - void setSysroot(const QString &sysroot); + ProjectExplorer::Kit *kit() const; + void setKitId(const Core::Id &id); private: - Ui::QmlProfilerAttachDialog *ui; + QmlProfilerAttachDialogPrivate *d; }; } // namespace Internal diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 6ed3a677430..669fdfcad59 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -60,6 +60,8 @@ #include #include +#include + #include #include #include @@ -519,42 +521,46 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode) { Q_UNUSED(tool); - QString host; + Id kitId; quint16 port; - QString sysroot; + Kit *kit = 0; { QSettings *settings = ICore::settings(); - host = settings->value(QLatin1String("AnalyzerQmlAttachDialog/host"), QLatin1String("localhost")).toString(); - port = settings->value(QLatin1String("AnalyzerQmlAttachDialog/port"), 3768).toInt(); - sysroot = settings->value(QLatin1String("AnalyzerQmlAttachDialog/sysroot")).toString(); + kitId = Id::fromSetting(settings->value(QLatin1String("AnalyzerQmlAttachDialog/kitId"))); + port = settings->value(QLatin1String("AnalyzerQmlAttachDialog/port"), 3768).toUInt(); QmlProfilerAttachDialog dialog; - dialog.setAddress(host); + dialog.setKitId(kitId); dialog.setPort(port); - dialog.setSysroot(sysroot); if (dialog.exec() != QDialog::Accepted) return; - host = dialog.address(); + kit = dialog.kit(); port = dialog.port(); - sysroot = dialog.sysroot(); - settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/host"), host); + settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/kitId"), kit->id().toSetting()); settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/port"), port); - settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/sysroot"), sysroot); } AnalyzerStartParameters sp; sp.toolId = tool->id(); sp.startMode = mode; - sp.connParams.host = host; - sp.connParams.port = port; - sp.sysroot = sysroot; - sp.analyzerHost = host; + + IDevice::ConstPtr device = DeviceKitInformation::device(kit); + if (device) { + sp.connParams = device->sshParameters(); + if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE + || device->type() == Android::Constants::ANDROID_DEVICE_TYPE) { + sp.analyzerHost = QLatin1String("localhost"); + } else { + sp.analyzerHost = sp.connParams.host; + } + } + sp.sysroot = SysRootKitInformation::sysRoot(kit).toString(); sp.analyzerPort = port; AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);