forked from qt-creator/qt-creator
Enable starting a qmlproject via Debug
This will right now wait for a qmldebugger connection.
This commit is contained in:
@@ -57,6 +57,7 @@
|
|||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QLineEdit>
|
#include <QtGui/QLineEdit>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
|
#include <QtGui/QSpinBox>
|
||||||
|
|
||||||
using namespace QmlProjectManager;
|
using namespace QmlProjectManager;
|
||||||
using namespace QmlProjectManager::Internal;
|
using namespace QmlProjectManager::Internal;
|
||||||
@@ -302,7 +303,8 @@ void QmlProjectFile::modified(ReloadBehavior *)
|
|||||||
QmlRunConfiguration::QmlRunConfiguration(QmlProject *pro)
|
QmlRunConfiguration::QmlRunConfiguration(QmlProject *pro)
|
||||||
: ProjectExplorer::RunConfiguration(pro),
|
: ProjectExplorer::RunConfiguration(pro),
|
||||||
m_project(pro),
|
m_project(pro),
|
||||||
m_type(Constants::QMLRUNCONFIGURATION)
|
m_type(Constants::QMLRUNCONFIGURATION),
|
||||||
|
m_debugServerPort(3768)
|
||||||
{
|
{
|
||||||
setName(tr("QML Viewer"));
|
setName(tr("QML Viewer"));
|
||||||
|
|
||||||
@@ -349,6 +351,11 @@ QString QmlRunConfiguration::workingDirectory() const
|
|||||||
return projectFile.absolutePath();
|
return projectFile.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint QmlRunConfiguration::debugServerPort() const
|
||||||
|
{
|
||||||
|
return m_debugServerPort;
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *QmlRunConfiguration::configurationWidget()
|
QWidget *QmlRunConfiguration::configurationWidget()
|
||||||
{
|
{
|
||||||
QWidget *config = new QWidget;
|
QWidget *config = new QWidget;
|
||||||
@@ -390,9 +397,16 @@ QWidget *QmlRunConfiguration::configurationWidget()
|
|||||||
qmlViewerArgs->setText(m_qmlViewerArgs);
|
qmlViewerArgs->setText(m_qmlViewerArgs);
|
||||||
connect(qmlViewerArgs, SIGNAL(textChanged(QString)), this, SLOT(onQmlViewerArgsChanged()));
|
connect(qmlViewerArgs, SIGNAL(textChanged(QString)), this, SLOT(onQmlViewerArgsChanged()));
|
||||||
|
|
||||||
|
QSpinBox *debugPort = new QSpinBox;
|
||||||
|
debugPort->setMinimum(1024); // valid registered/dynamic/free ports according to http://www.iana.org/assignments/port-numbers
|
||||||
|
debugPort->setMaximum(65535);
|
||||||
|
debugPort->setValue(m_debugServerPort);
|
||||||
|
connect(debugPort, SIGNAL(valueChanged(int)), this, SLOT(onDebugServerPortChanged()));
|
||||||
|
|
||||||
form->addRow(tr("QML Viewer"), qmlViewer);
|
form->addRow(tr("QML Viewer"), qmlViewer);
|
||||||
form->addRow(tr("QML Viewer arguments:"), qmlViewerArgs);
|
form->addRow(tr("QML Viewer arguments:"), qmlViewerArgs);
|
||||||
form->addRow(tr("Main QML File:"), combo);
|
form->addRow(tr("Main QML File:"), combo);
|
||||||
|
form->addRow(tr("Debugging Port:"), debugPort);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@@ -427,6 +441,13 @@ void QmlRunConfiguration::onQmlViewerArgsChanged()
|
|||||||
m_qmlViewerArgs = lineEdit->text();
|
m_qmlViewerArgs = lineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlRunConfiguration::onDebugServerPortChanged()
|
||||||
|
{
|
||||||
|
if (QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender())) {
|
||||||
|
m_debugServerPort = spinBox->value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QmlRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writer) const
|
void QmlRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writer) const
|
||||||
{
|
{
|
||||||
ProjectExplorer::RunConfiguration::save(writer);
|
ProjectExplorer::RunConfiguration::save(writer);
|
||||||
@@ -434,6 +455,7 @@ void QmlRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writer
|
|||||||
writer.saveValue(QLatin1String("qmlviewer"), m_qmlViewerCustomPath);
|
writer.saveValue(QLatin1String("qmlviewer"), m_qmlViewerCustomPath);
|
||||||
writer.saveValue(QLatin1String("qmlviewerargs"), m_qmlViewerArgs);
|
writer.saveValue(QLatin1String("qmlviewerargs"), m_qmlViewerArgs);
|
||||||
writer.saveValue(QLatin1String("mainscript"), m_scriptFile);
|
writer.saveValue(QLatin1String("mainscript"), m_scriptFile);
|
||||||
|
writer.saveValue(QLatin1String("debugserverport"), m_debugServerPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader)
|
void QmlRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader)
|
||||||
@@ -443,9 +465,12 @@ void QmlRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReade
|
|||||||
m_qmlViewerCustomPath = reader.restoreValue(QLatin1String("qmlviewer")).toString();
|
m_qmlViewerCustomPath = reader.restoreValue(QLatin1String("qmlviewer")).toString();
|
||||||
m_qmlViewerArgs = reader.restoreValue(QLatin1String("qmlviewerargs")).toString();
|
m_qmlViewerArgs = reader.restoreValue(QLatin1String("qmlviewerargs")).toString();
|
||||||
m_scriptFile = reader.restoreValue(QLatin1String("mainscript")).toString();
|
m_scriptFile = reader.restoreValue(QLatin1String("mainscript")).toString();
|
||||||
|
m_debugServerPort = reader.restoreValue(QLatin1String("debugserverport")).toUInt();
|
||||||
|
|
||||||
if (m_scriptFile.isEmpty())
|
if (m_scriptFile.isEmpty())
|
||||||
m_scriptFile = tr("<Current File>");
|
m_scriptFile = tr("<Current File>");
|
||||||
|
if (m_debugServerPort == 0)
|
||||||
|
m_debugServerPort = 3768;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlRunConfigurationFactory::QmlRunConfigurationFactory()
|
QmlRunConfigurationFactory::QmlRunConfigurationFactory()
|
||||||
@@ -482,10 +507,14 @@ ProjectExplorer::RunConfiguration *QmlRunConfigurationFactory::create(ProjectExp
|
|||||||
return new QmlRunConfiguration(pro);
|
return new QmlRunConfiguration(pro);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlRunControl::QmlRunControl(QmlRunConfiguration *runConfiguration)
|
QmlRunControl::QmlRunControl(QmlRunConfiguration *runConfiguration, bool debugMode)
|
||||||
: RunControl(runConfiguration)
|
: RunControl(runConfiguration)
|
||||||
{
|
{
|
||||||
m_applicationLauncher.setEnvironment(ProjectExplorer::Environment::systemEnvironment().toStringList());
|
Environment environment = ProjectExplorer::Environment::systemEnvironment();
|
||||||
|
if (debugMode)
|
||||||
|
environment.set("QML_DEBUG_SERVER_PORT", QString::number(runConfiguration->debugServerPort()));
|
||||||
|
|
||||||
|
m_applicationLauncher.setEnvironment(environment.toStringList());
|
||||||
m_applicationLauncher.setWorkingDirectory(runConfiguration->workingDirectory());
|
m_applicationLauncher.setWorkingDirectory(runConfiguration->workingDirectory());
|
||||||
|
|
||||||
m_executable = runConfiguration->viewerPath();
|
m_executable = runConfiguration->viewerPath();
|
||||||
@@ -551,14 +580,14 @@ QmlRunControlFactory::~QmlRunControlFactory()
|
|||||||
|
|
||||||
bool QmlRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
|
bool QmlRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
|
||||||
{
|
{
|
||||||
return (mode == ProjectExplorer::Constants::RUNMODE)
|
return (qobject_cast<QmlRunConfiguration*>(runConfiguration) != 0);
|
||||||
&& (qobject_cast<QmlRunConfiguration*>(runConfiguration) != 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RunControl *QmlRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode)
|
RunControl *QmlRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
|
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
|
||||||
return new QmlRunControl(qobject_cast<QmlRunConfiguration *>(runConfiguration));
|
return new QmlRunControl(qobject_cast<QmlRunConfiguration *>(runConfiguration),
|
||||||
|
mode == ProjectExplorer::Constants::DEBUGMODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlRunControlFactory::displayName() const
|
QString QmlRunControlFactory::displayName() const
|
||||||
|
@@ -146,6 +146,7 @@ public:
|
|||||||
QString viewerPath() const;
|
QString viewerPath() const;
|
||||||
QStringList viewerArguments() const;
|
QStringList viewerArguments() const;
|
||||||
QString workingDirectory() const;
|
QString workingDirectory() const;
|
||||||
|
uint debugServerPort() const;
|
||||||
|
|
||||||
// RunConfiguration
|
// RunConfiguration
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
@@ -159,9 +160,11 @@ private Q_SLOTS:
|
|||||||
void setMainScript(const QString &scriptFile);
|
void setMainScript(const QString &scriptFile);
|
||||||
void onQmlViewerChanged();
|
void onQmlViewerChanged();
|
||||||
void onQmlViewerArgsChanged();
|
void onQmlViewerArgsChanged();
|
||||||
|
void onDebugServerPortChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlProject *m_project;
|
QmlProject *m_project;
|
||||||
|
uint m_debugServerPort;
|
||||||
QString m_scriptFile;
|
QString m_scriptFile;
|
||||||
QString m_qmlViewerCustomPath;
|
QString m_qmlViewerCustomPath;
|
||||||
QString m_qmlViewerDefaultPath;
|
QString m_qmlViewerDefaultPath;
|
||||||
@@ -196,7 +199,7 @@ private:
|
|||||||
class QmlRunControl : public ProjectExplorer::RunControl {
|
class QmlRunControl : public ProjectExplorer::RunControl {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QmlRunControl(QmlRunConfiguration *runConfiguration);
|
explicit QmlRunControl(QmlRunConfiguration *runConfiguration, bool debugMode);
|
||||||
virtual ~QmlRunControl ();
|
virtual ~QmlRunControl ();
|
||||||
|
|
||||||
// RunControl
|
// RunControl
|
||||||
|
Reference in New Issue
Block a user