Commit bfe5b520 authored by Aurindam Jana's avatar Aurindam Jana

QmlDebugger: Added dialog "Attach to QML Port..."

The dialog is added to Debug->Start Debugging menu option. It specifies the host
and port that the JSDebugClient connects to for listening to debug messages.

Change-Id: I7f828c169ff2338f4780025f72182c5fc8784c4a
Reviewed-on: http://codereview.qt-project.org/4824Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent f51efea4
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AttachToQmlPortDialog</class>
<widget class="QDialog" name="AttachToQmlPortDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>435</width>
<height>133</height>
</rect>
</property>
<property name="windowTitle">
<string>Start Debugger</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::FieldsStayAtSizeHint</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="hostLabel">
<property name="text">
<string>Host</string>
</property>
<property name="buddy">
<cstring>hostLineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="hostLineEdit">
<property name="text">
<string notr="true">localhost</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="maximum">
<number>65535</number>
</property>
<property name="value">
<number>3768</number>
</property>
</widget>
</item>
</layout>
</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/>
</ui>
......@@ -119,7 +119,8 @@ FORMS += attachexternaldialog.ui \
commonoptionspage.ui \
startexternaldialog.ui \
startremotedialog.ui \
startremoteenginedialog.ui
startremoteenginedialog.ui \
attachtoqmlportdialog.ui
RESOURCES += debugger.qrc
......
......@@ -126,6 +126,7 @@ enum DebuggerStartMode
AttachCrashedExternal, // Attach to crashed process by process id
AttachCore, // Attach to a core file
AttachToRemote, // Start and attach to a remote process
AttachToQmlPort, // Attach to QML debugging port
StartRemoteGdb, // Start gdb itself remotely
StartRemoteEngine // Start ipc guest engine on other machine
};
......
......@@ -40,6 +40,7 @@
#include "ui_startexternaldialog.h"
#include "ui_startremotedialog.h"
#include "ui_startremoteenginedialog.h"
#include "ui_attachtoqmlportdialog.h"
#ifdef Q_OS_WIN
# include "shared/dbgwinutils.h"
......@@ -805,6 +806,49 @@ void StartRemoteDialog::updateState()
m_ui->serverStartScript->setEnabled(enabled);
}
///////////////////////////////////////////////////////////////////////
//
// AttachToQmlPortDialog
//
///////////////////////////////////////////////////////////////////////
AttachToQmlPortDialog::AttachToQmlPortDialog(QWidget *parent)
: QDialog(parent),
m_ui(new Ui::AttachToQmlPortDialog)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
m_ui->setupUi(this);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
AttachToQmlPortDialog::~AttachToQmlPortDialog()
{
delete m_ui;
}
void AttachToQmlPortDialog::setHost(const QString &host)
{
m_ui->hostLineEdit->setText(host);
}
QString AttachToQmlPortDialog::host() const
{
return m_ui->hostLineEdit->text();
}
void AttachToQmlPortDialog::setPort(const int port)
{
m_ui->portSpinBox->setValue(port);
}
int AttachToQmlPortDialog::port() const
{
return m_ui->portSpinBox->value();
}
// --------- StartRemoteCdbDialog
static inline QString cdbRemoteHelp()
{
......
......@@ -47,6 +47,7 @@ class AttachCoreDialog;
class AttachExternalDialog;
class StartExternalDialog;
class StartRemoteDialog;
class AttachToQmlPortDialog;
class StartRemoteEngineDialog;
} // namespace Ui
......@@ -216,6 +217,24 @@ private:
Ui::StartRemoteDialog *m_ui;
};
class AttachToQmlPortDialog : public QDialog
{
Q_OBJECT
public:
explicit AttachToQmlPortDialog(QWidget *parent);
~AttachToQmlPortDialog();
QString host() const;
void setHost(const QString &host);
int port() const;
void setPort(const int port);
private:
Ui::AttachToQmlPortDialog *m_ui;
};
class StartRemoteCdbDialog : public QDialog
{
Q_OBJECT
......
......@@ -723,6 +723,7 @@ public slots:
void startExternalApplication();
void startRemoteCdbSession();
void startRemoteApplication();
void attachToQmlPort();
void startRemoteEngine();
void attachExternalApplication();
Q_SLOT void attachExternalApplication(ProjectExplorer::RunControl *rc);
......@@ -1021,6 +1022,7 @@ public:
QAction *m_startAction;
QAction *m_startExternalAction;
QAction *m_startRemoteAction;
QAction *m_attachToQmlPortAction;
QAction *m_startRemoteCdbAction;
QAction *m_startRemoteLldbAction;
QAction *m_attachExternalAction;
......@@ -1137,6 +1139,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) :
m_startAction = 0;
m_startExternalAction = 0;
m_startRemoteAction = 0;
m_attachToQmlPortAction = 0;
m_startRemoteCdbAction = 0;
m_startRemoteLldbAction = 0;
m_attachExternalAction = 0;
......@@ -1373,6 +1376,7 @@ void DebuggerPluginPrivate::languagesChanged()
m_attachCoreAction->setVisible(debuggerIsCPP);
m_startRemoteAction->setVisible(debuggerIsCPP);
m_detachAction->setVisible(debuggerIsCPP);
m_attachToQmlPortAction->setVisible(m_mainWindow->activeDebugLanguages() & QmlLanguage);
}
void DebuggerPluginPrivate::debugProject()
......@@ -1605,6 +1609,39 @@ void DebuggerPluginPrivate::startRemoteApplication()
startDebugger(rc);
}
void DebuggerPluginPrivate::attachToQmlPort()
{
DebuggerStartParameters sp;
AttachToQmlPortDialog dlg(mainWindow());
const QVariant qmlServerAddress = configValue(_("LastQmlServerAddress"));
if (qmlServerAddress.isValid()) {
dlg.setHost(qmlServerAddress.toString());
} else {
dlg.setHost(sp.qmlServerAddress);
}
const QVariant qmlServerPort = configValue(_("LastQmlServerPort"));
if (qmlServerPort.isValid()) {
dlg.setPort(qmlServerPort.toInt());
} else {
dlg.setPort(sp.qmlServerPort);
}
if (dlg.exec() != QDialog::Accepted)
return;
setConfigValue(_("LastQmlServerAddress"), dlg.host());
setConfigValue(_("LastQmlServerPort"), dlg.port());
sp.serverAddress = dlg.host();
sp.serverPort = dlg.port();
sp.startMode = AttachToQmlPort;
if (RunControl *rc = createDebugger(sp))
startDebugger(rc);
}
void DebuggerPluginPrivate::startRemoteEngine()
{
DebuggerStartParameters sp;
......@@ -1971,6 +2008,7 @@ void DebuggerPluginPrivate::setInitialState()
m_startExternalAction->setEnabled(true);
m_attachExternalAction->setEnabled(true);
m_attachToQmlPortAction->setEnabled(true);
m_attachCoreAction->setEnabled(true);
m_startRemoteAction->setEnabled(true);
m_detachAction->setEnabled(false);
......@@ -2086,6 +2124,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
}
m_startExternalAction->setEnabled(true);
m_attachToQmlPortAction->setEnabled(true);
m_attachExternalAction->setEnabled(true);
m_attachCoreAction->setEnabled(true);
m_startRemoteAction->setEnabled(true);
......@@ -2833,6 +2872,10 @@ void DebuggerPluginPrivate::extensionsInitialized()
act->setText(tr("Start and Attach to Remote Application..."));
connect(act, SIGNAL(triggered()), SLOT(startRemoteApplication()));
act = m_attachToQmlPortAction = new QAction(this);
act->setText(tr("Attach to QML Port..."));
connect(act, SIGNAL(triggered()), SLOT(attachToQmlPort()));
#ifdef Q_OS_WIN
m_startRemoteCdbAction = new QAction(tr("Attach to Remote CDB Session..."), this);
connect(m_startRemoteCdbAction, SIGNAL(triggered()),
......@@ -2882,6 +2925,11 @@ void DebuggerPluginPrivate::extensionsInitialized()
cmd->setAttribute(Command::CA_Hide);
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
cmd = am->registerAction(m_attachToQmlPortAction,
"Debugger.AttachToQmlPort", globalcontext);
cmd->setAttribute(Command::CA_Hide);
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
#ifdef WITH_LLDB
cmd = am->registerAction(m_startRemoteLldbAction,
"Debugger.RemoteLldb", globalcontext);
......
......@@ -475,6 +475,9 @@ static QList<DebuggerEngineType> enginesForMode(DebuggerStartMode startMode,
// For now thats the only supported IPC engine.
result.push_back(LldbEngineType);
break;
case AttachToQmlPort:
result.push_back(QmlEngineType); // Only QML can do this
break;
}
return result;
}
......
......@@ -39,6 +39,7 @@
#include <utils/ssh/sshconnection.h>
#include <utils/environment.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <QtCore/QMetaType>
......@@ -65,7 +66,7 @@ public:
useTerminal(false),
breakOnMain(false),
qmlServerAddress(QLatin1String("127.0.0.1")),
qmlServerPort(0),
qmlServerPort(ProjectExplorer::Constants::QML_DEFAULT_DEBUG_SERVER_PORT),
useServerStartScript(false),
connParams(Utils::SshConnectionParameters::NoProxy),
startMode(NoStartMode),
......
......@@ -331,7 +331,8 @@ void QmlEngine::runEngine()
{
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
if (!isSlaveEngine() && startParameters().startMode != AttachToRemote)
if (!isSlaveEngine() && startParameters().startMode != AttachToRemote
&& startParameters().startMode != AttachToQmlPort)
startApplicationLauncher();
d->m_noDebugOutputTimer.start();
}
......
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