forked from qt-creator/qt-creator
QmlProjectManager refactoring
Putting every class in it's own files + avoid "using namespace"
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmlprojectmanager/qmlproject.h>
|
||||
#include <qmlprojectmanager/qmlprojectrunconfiguration.h>
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QtPlugin>
|
||||
@@ -186,8 +186,8 @@ void QmlInspectorMode::connectToViewer()
|
||||
return;
|
||||
}
|
||||
|
||||
QmlProjectManager::QmlRunConfiguration* config =
|
||||
qobject_cast<QmlProjectManager::QmlRunConfiguration*>(project->activeTarget()->activeRunConfiguration());
|
||||
QmlProjectManager::QmlProjectRunConfiguration* config =
|
||||
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration*>(project->activeTarget()->activeRunConfiguration());
|
||||
if (!config) {
|
||||
emit statusMessage(tr("Cannot find project run configuration, debugging canceled."));
|
||||
return;
|
||||
|
||||
@@ -37,11 +37,8 @@
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
using namespace QmlProjectManager::Internal;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// QmlNewProjectWizardDialog
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QmlNewProjectWizardDialog::QmlNewProjectWizardDialog(QWidget *parent) :
|
||||
ProjectExplorer::BaseProjectWizardDialog(parent)
|
||||
@@ -168,3 +165,6 @@ bool QmlNewProjectWizard::postGenerateFiles(const Core::GeneratedFiles &l, QStri
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
|
||||
@@ -28,73 +28,33 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmlproject.h"
|
||||
#include "qmlprojectconstants.h"
|
||||
#include "qmltarget.h"
|
||||
#include "qmlprojectfile.h"
|
||||
#include "qmlprojectmanagerconstants.h"
|
||||
#include "fileformat/qmlprojectitem.h"
|
||||
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/persistentsettings.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
|
||||
#include <projectexplorer/filewatcher.h>
|
||||
#include <qmljseditor/qmljsmodelmanagerinterface.h>
|
||||
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <QTextStream>
|
||||
#include <QmlComponent>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <QtCore/QtDebug>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QCoreApplication>
|
||||
namespace QmlProjectManager {
|
||||
|
||||
#include <QtGui/QFormLayout>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QSpinBox>
|
||||
|
||||
#include <QtDeclarative/QmlComponent>
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
using namespace QmlProjectManager::Internal;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace {
|
||||
const char * const QML_RC_ID("QmlProjectManager.QmlRunConfiguration");
|
||||
const char * const QML_RC_DISPLAY_NAME(QT_TRANSLATE_NOOP("QmlProjectManager::Internal::QmlRunConfiguration", "QML Viewer"));
|
||||
|
||||
const char * const QML_VIEWER_KEY("QmlProjectManager.QmlRunConfiguration.QmlViewer");
|
||||
const char * const QML_VIEWER_ARGUMENTS_KEY("QmlProjectManager.QmlRunConfiguration.QmlViewerArguments");
|
||||
const char * const QML_MAINSCRIPT_KEY("QmlProjectManager.QmlRunConfiguration.MainScript");
|
||||
const char * const QML_DEBUG_SERVER_PORT_KEY("QmlProjectManager.QmlRunConfiguration.DebugServerPort");
|
||||
|
||||
const int DEFAULT_DEBUG_SERVER_PORT(3768);
|
||||
} // namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// QmlProject
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QmlProject::QmlProject(Manager *manager, const QString &fileName)
|
||||
QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName)
|
||||
: m_manager(manager),
|
||||
m_fileName(fileName),
|
||||
m_modelManager(ExtensionSystem::PluginManager::instance()->getObject<QmlJSEditor::ModelManagerInterface>()),
|
||||
m_fileWatcher(new ProjectExplorer::FileWatcher(this)),
|
||||
m_targetFactory(new QmlTargetFactory(this))
|
||||
m_targetFactory(new Internal::QmlProjectTargetFactory(this))
|
||||
{
|
||||
setSupportedTargetIds(QSet<QString>() << QLatin1String(VIEWER_TARGET_ID));
|
||||
setSupportedTargetIds(QSet<QString>() << QLatin1String(Constants::QML_VIEWER_TARGET_ID));
|
||||
QFileInfo fileInfo(m_fileName);
|
||||
m_projectName = fileInfo.completeBaseName();
|
||||
|
||||
m_file = new QmlProjectFile(this, fileName);
|
||||
m_rootNode = new QmlProjectNode(this, m_file);
|
||||
m_file = new Internal::QmlProjectFile(this, fileName);
|
||||
m_rootNode = new Internal::QmlProjectNode(this, m_file);
|
||||
|
||||
m_fileWatcher->addFile(fileName),
|
||||
connect(m_fileWatcher, SIGNAL(fileChanged(QString)),
|
||||
@@ -247,7 +207,7 @@ Core::IFile *QmlProject::file() const
|
||||
return m_file;
|
||||
}
|
||||
|
||||
Manager *QmlProject::projectManager() const
|
||||
Internal::Manager *QmlProject::projectManager() const
|
||||
{
|
||||
return m_manager;
|
||||
}
|
||||
@@ -272,17 +232,17 @@ QList<ProjectExplorer::BuildConfigWidget*> QmlProject::subConfigWidgets()
|
||||
return QList<ProjectExplorer::BuildConfigWidget*>();
|
||||
}
|
||||
|
||||
QmlTargetFactory *QmlProject::targetFactory() const
|
||||
Internal::QmlProjectTargetFactory *QmlProject::targetFactory() const
|
||||
{
|
||||
return m_targetFactory;
|
||||
}
|
||||
|
||||
QmlTarget *QmlProject::activeTarget() const
|
||||
Internal::QmlProjectTarget *QmlProject::activeTarget() const
|
||||
{
|
||||
return static_cast<QmlTarget *>(Project::activeTarget());
|
||||
return static_cast<Internal::QmlProjectTarget *>(Project::activeTarget());
|
||||
}
|
||||
|
||||
QmlProjectNode *QmlProject::rootProjectNode() const
|
||||
Internal::QmlProjectNode *QmlProject::rootProjectNode() const
|
||||
{
|
||||
return m_rootNode;
|
||||
}
|
||||
@@ -298,7 +258,7 @@ bool QmlProject::fromMap(const QVariantMap &map)
|
||||
return false;
|
||||
|
||||
if (targets().isEmpty()) {
|
||||
Internal::QmlTarget *target(targetFactory()->create(this, QLatin1String(VIEWER_TARGET_ID)));
|
||||
Internal::QmlProjectTarget *target(targetFactory()->create(this, QLatin1String(Constants::QML_VIEWER_TARGET_ID)));
|
||||
addTarget(target);
|
||||
}
|
||||
|
||||
@@ -306,434 +266,4 @@ bool QmlProject::fromMap(const QVariantMap &map)
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// QmlProjectFile
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QmlProjectFile::QmlProjectFile(QmlProject *parent, QString fileName)
|
||||
: Core::IFile(parent),
|
||||
m_project(parent),
|
||||
m_fileName(fileName)
|
||||
{ }
|
||||
|
||||
QmlProjectFile::~QmlProjectFile()
|
||||
{ }
|
||||
|
||||
bool QmlProjectFile::save(const QString &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString QmlProjectFile::fileName() const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
QString QmlProjectFile::defaultPath() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QmlProjectFile::suggestedFileName() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QmlProjectFile::mimeType() const
|
||||
{
|
||||
return Constants::QMLMIMETYPE;
|
||||
}
|
||||
|
||||
bool QmlProjectFile::isModified() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QmlProjectFile::isReadOnly() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QmlProjectFile::isSaveAsAllowed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void QmlProjectFile::modified(ReloadBehavior *)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// QmlRunConfiguration
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QmlRunConfiguration::QmlRunConfiguration(QmlTarget *parent) :
|
||||
ProjectExplorer::RunConfiguration(parent, QLatin1String(QML_RC_ID)),
|
||||
m_debugServerPort(DEFAULT_DEBUG_SERVER_PORT)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
QmlRunConfiguration::QmlRunConfiguration(QmlTarget *parent, QmlRunConfiguration *source) :
|
||||
ProjectExplorer::RunConfiguration(parent, source),
|
||||
m_scriptFile(source->m_scriptFile),
|
||||
m_qmlViewerCustomPath(source->m_qmlViewerCustomPath),
|
||||
m_qmlViewerArgs(source->m_qmlViewerArgs),
|
||||
m_debugServerPort(source->m_debugServerPort)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
void QmlRunConfiguration::ctor()
|
||||
{
|
||||
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
|
||||
|
||||
// prepend creator/bin dir to search path (only useful for special creator-qml package)
|
||||
const QString searchPath = QCoreApplication::applicationDirPath()
|
||||
+ Utils::SynchronousProcess::pathSeparator()
|
||||
+ QString(qgetenv("PATH"));
|
||||
m_qmlViewerDefaultPath = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer"));
|
||||
}
|
||||
|
||||
QmlRunConfiguration::~QmlRunConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
QmlTarget *QmlRunConfiguration::qmlTarget() const
|
||||
{
|
||||
return static_cast<Internal::QmlTarget *>(target());
|
||||
}
|
||||
|
||||
QString QmlRunConfiguration::viewerPath() const
|
||||
{
|
||||
if (!m_qmlViewerCustomPath.isEmpty())
|
||||
return m_qmlViewerCustomPath;
|
||||
return m_qmlViewerDefaultPath;
|
||||
}
|
||||
|
||||
QStringList QmlRunConfiguration::viewerArguments() const
|
||||
{
|
||||
QStringList args;
|
||||
|
||||
// arguments in .user file
|
||||
if (!m_qmlViewerArgs.isEmpty())
|
||||
args.append(m_qmlViewerArgs);
|
||||
|
||||
// arguments from .qmlproject file
|
||||
foreach (const QString &libraryPath, qmlTarget()->qmlProject()->libraryPaths()) {
|
||||
args.append(QLatin1String("-L"));
|
||||
args.append(libraryPath);
|
||||
}
|
||||
|
||||
const QString s = mainScript();
|
||||
if (! s.isEmpty())
|
||||
args.append(s);
|
||||
return args;
|
||||
}
|
||||
|
||||
QString QmlRunConfiguration::workingDirectory() const
|
||||
{
|
||||
QFileInfo projectFile(qmlTarget()->qmlProject()->file()->fileName());
|
||||
return projectFile.absolutePath();
|
||||
}
|
||||
|
||||
uint QmlRunConfiguration::debugServerPort() const
|
||||
{
|
||||
return m_debugServerPort;
|
||||
}
|
||||
|
||||
QWidget *QmlRunConfiguration::configurationWidget()
|
||||
{
|
||||
QWidget *config = new QWidget;
|
||||
QFormLayout *form = new QFormLayout(config);
|
||||
|
||||
QComboBox *combo = new QComboBox;
|
||||
|
||||
QDir projectDir = qmlTarget()->qmlProject()->projectDir();
|
||||
QStringList files;
|
||||
|
||||
files.append(tr("<Current File>"));
|
||||
|
||||
int currentIndex = -1;
|
||||
|
||||
foreach (const QString &fn, qmlTarget()->qmlProject()->files()) {
|
||||
QFileInfo fileInfo(fn);
|
||||
if (fileInfo.suffix() != QLatin1String("qml"))
|
||||
continue;
|
||||
|
||||
QString fileName = projectDir.relativeFilePath(fn);
|
||||
if (fileName == m_scriptFile)
|
||||
currentIndex = files.size();
|
||||
|
||||
files.append(fileName);
|
||||
}
|
||||
|
||||
combo->addItems(files);
|
||||
if (currentIndex != -1)
|
||||
combo->setCurrentIndex(currentIndex);
|
||||
|
||||
connect(combo, SIGNAL(activated(QString)), this, SLOT(setMainScript(QString)));
|
||||
|
||||
Utils::PathChooser *qmlViewer = new Utils::PathChooser;
|
||||
qmlViewer->setExpectedKind(Utils::PathChooser::Command);
|
||||
qmlViewer->setPath(viewerPath());
|
||||
connect(qmlViewer, SIGNAL(changed(QString)), this, SLOT(onQmlViewerChanged()));
|
||||
|
||||
QLineEdit *qmlViewerArgs = new QLineEdit;
|
||||
qmlViewerArgs->setText(m_qmlViewerArgs);
|
||||
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 arguments:"), qmlViewerArgs);
|
||||
form->addRow(tr("Main QML File:"), combo);
|
||||
form->addRow(tr("Debugging Port:"), debugPort);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
QString QmlRunConfiguration::mainScript() const
|
||||
{
|
||||
if (m_scriptFile.isEmpty() || m_scriptFile == tr("<Current File>")) {
|
||||
Core::EditorManager *editorManager = Core::ICore::instance()->editorManager();
|
||||
if (Core::IEditor *editor = editorManager->currentEditor()) {
|
||||
return editor->file()->fileName();
|
||||
}
|
||||
}
|
||||
|
||||
return qmlTarget()->qmlProject()->projectDir().absoluteFilePath(m_scriptFile);
|
||||
}
|
||||
|
||||
void QmlRunConfiguration::setMainScript(const QString &scriptFile)
|
||||
{
|
||||
m_scriptFile = scriptFile;
|
||||
}
|
||||
|
||||
void QmlRunConfiguration::onQmlViewerChanged()
|
||||
{
|
||||
if (Utils::PathChooser *chooser = qobject_cast<Utils::PathChooser *>(sender())) {
|
||||
m_qmlViewerCustomPath = chooser->path();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlRunConfiguration::onQmlViewerArgsChanged()
|
||||
{
|
||||
if (QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender()))
|
||||
m_qmlViewerArgs = lineEdit->text();
|
||||
}
|
||||
|
||||
void QmlRunConfiguration::onDebugServerPortChanged()
|
||||
{
|
||||
if (QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender())) {
|
||||
m_debugServerPort = spinBox->value();
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap QmlRunConfiguration::toMap() const
|
||||
{
|
||||
QVariantMap map(ProjectExplorer::RunConfiguration::toMap());
|
||||
|
||||
map.insert(QLatin1String(QML_VIEWER_KEY), m_qmlViewerCustomPath);
|
||||
map.insert(QLatin1String(QML_VIEWER_ARGUMENTS_KEY), m_qmlViewerArgs);
|
||||
map.insert(QLatin1String(QML_MAINSCRIPT_KEY), m_scriptFile);
|
||||
map.insert(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), m_debugServerPort);
|
||||
return map;
|
||||
}
|
||||
|
||||
bool QmlRunConfiguration::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_qmlViewerCustomPath = map.value(QLatin1String(QML_VIEWER_KEY)).toString();
|
||||
m_qmlViewerArgs = map.value(QLatin1String(QML_VIEWER_ARGUMENTS_KEY)).toString();
|
||||
m_scriptFile = map.value(QLatin1String(QML_MAINSCRIPT_KEY), tr("<Current File>")).toString();
|
||||
m_debugServerPort = map.value(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), DEFAULT_DEBUG_SERVER_PORT).toUInt();
|
||||
|
||||
return RunConfiguration::fromMap(map);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// QmlRunConfigurationFactory
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QmlRunConfigurationFactory::QmlRunConfigurationFactory(QObject *parent) :
|
||||
ProjectExplorer::IRunConfigurationFactory(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QmlRunConfigurationFactory::~QmlRunConfigurationFactory()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList QmlRunConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const
|
||||
{
|
||||
if (!qobject_cast<QmlTarget *>(parent))
|
||||
return QStringList();
|
||||
return QStringList() << QLatin1String(QML_RC_ID);
|
||||
}
|
||||
|
||||
QString QmlRunConfigurationFactory::displayNameForId(const QString &id) const
|
||||
{
|
||||
if (id == QLatin1String(QML_RC_ID))
|
||||
return tr("Run QML Script");
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QmlRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const QString &id) const
|
||||
{
|
||||
if (!qobject_cast<QmlTarget *>(parent))
|
||||
return false;
|
||||
return id == QLatin1String(QML_RC_ID);
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QmlRunConfigurationFactory::create(ProjectExplorer::Target *parent, const QString &id)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
QmlTarget *qmlparent(static_cast<QmlTarget *>(parent));
|
||||
return new QmlRunConfiguration(qmlparent);
|
||||
}
|
||||
|
||||
bool QmlRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
QString id(idFromMap(map));
|
||||
return canCreate(parent, id);
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QmlRunConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
QmlTarget *qmlparent(static_cast<QmlTarget *>(parent));
|
||||
QmlRunConfiguration *rc(new QmlRunConfiguration(qmlparent));
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
delete rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool QmlRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, RunConfiguration *source) const
|
||||
{
|
||||
return canCreate(parent, source->id());
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QmlRunConfigurationFactory::clone(ProjectExplorer::Target *parent, RunConfiguration *source)
|
||||
{
|
||||
if (!canClone(parent, source))
|
||||
return 0;
|
||||
QmlTarget *qmlparent(static_cast<QmlTarget *>(parent));
|
||||
return new QmlRunConfiguration(qmlparent, qobject_cast<QmlRunConfiguration *>(source));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// QmlRunControl
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QmlRunControl::QmlRunControl(QmlRunConfiguration *runConfiguration, bool debugMode)
|
||||
: RunControl(runConfiguration), m_debugMode(debugMode)
|
||||
{
|
||||
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_executable = runConfiguration->viewerPath();
|
||||
m_commandLineArguments = runConfiguration->viewerArguments();
|
||||
|
||||
connect(&m_applicationLauncher, SIGNAL(applicationError(QString)),
|
||||
this, SLOT(slotError(QString)));
|
||||
connect(&m_applicationLauncher, SIGNAL(appendOutput(QString)),
|
||||
this, SLOT(slotAddToOutputWindow(QString)));
|
||||
connect(&m_applicationLauncher, SIGNAL(processExited(int)),
|
||||
this, SLOT(processExited(int)));
|
||||
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
||||
this, SLOT(slotBringApplicationToForeground(qint64)));
|
||||
}
|
||||
|
||||
QmlRunControl::~QmlRunControl()
|
||||
{
|
||||
}
|
||||
|
||||
void QmlRunControl::start()
|
||||
{
|
||||
m_applicationLauncher.start(ApplicationLauncher::Gui, m_executable, m_commandLineArguments);
|
||||
emit started();
|
||||
emit addToOutputWindow(this, tr("Starting %1 %2").arg(QDir::toNativeSeparators(m_executable),
|
||||
m_commandLineArguments.join(QLatin1String(" "))));
|
||||
}
|
||||
|
||||
void QmlRunControl::stop()
|
||||
{
|
||||
m_applicationLauncher.stop();
|
||||
}
|
||||
|
||||
bool QmlRunControl::isRunning() const
|
||||
{
|
||||
return m_applicationLauncher.isRunning();
|
||||
}
|
||||
|
||||
void QmlRunControl::slotBringApplicationToForeground(qint64 pid)
|
||||
{
|
||||
bringApplicationToForeground(pid);
|
||||
}
|
||||
|
||||
void QmlRunControl::slotError(const QString &err)
|
||||
{
|
||||
emit error(this, err);
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void QmlRunControl::slotAddToOutputWindow(const QString &line)
|
||||
{
|
||||
if (m_debugMode && line.startsWith("QmlDebugServer: Waiting for connection")) {
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
core->modeManager()->activateMode(QLatin1String("QML_INSPECT_MODE"));
|
||||
}
|
||||
|
||||
emit addToOutputWindowInline(this, line);
|
||||
}
|
||||
|
||||
void QmlRunControl::processExited(int exitCode)
|
||||
{
|
||||
emit addToOutputWindow(this, tr("%1 exited with code %2").arg(QDir::toNativeSeparators(m_executable)).arg(exitCode));
|
||||
emit finished();
|
||||
}
|
||||
|
||||
QmlRunControlFactory::QmlRunControlFactory(QObject *parent)
|
||||
: IRunControlFactory(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QmlRunControlFactory::~QmlRunControlFactory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool QmlRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
|
||||
{
|
||||
Q_UNUSED(mode);
|
||||
return (qobject_cast<QmlRunConfiguration*>(runConfiguration) != 0);
|
||||
}
|
||||
|
||||
RunControl *QmlRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode)
|
||||
{
|
||||
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
|
||||
return new QmlRunControl(qobject_cast<QmlRunConfiguration *>(runConfiguration),
|
||||
mode == ProjectExplorer::Constants::DEBUGMODE);
|
||||
}
|
||||
|
||||
QString QmlRunControlFactory::displayName() const
|
||||
{
|
||||
return tr("Run");
|
||||
}
|
||||
|
||||
QWidget *QmlRunControlFactory::configurationWidget(RunConfiguration *runConfiguration)
|
||||
{
|
||||
Q_UNUSED(runConfiguration)
|
||||
return new QLabel("TODO add Configuration widget");
|
||||
}
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -31,113 +31,30 @@
|
||||
#define QMLPROJECT_H
|
||||
|
||||
#include "qmlprojectmanager.h"
|
||||
#include "qmlprojectnodes.h"
|
||||
#include "qmlprojectmanager_global.h"
|
||||
#include "qmltarget.h"
|
||||
#include "fileformat/qmlprojectitem.h"
|
||||
#include "qmlprojectnodes.h"
|
||||
#include "qmlprojecttarget.h"
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/applicationrunconfiguration.h>
|
||||
#include <projectexplorer/filewatcher.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtDeclarative/QmlEngine>
|
||||
|
||||
namespace QmlJSEditor {
|
||||
class ModelManagerInterface;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class FileWatcher;
|
||||
}
|
||||
|
||||
namespace QmlProjectManager {
|
||||
class QmlProject;
|
||||
class QmlRunConfiguration;
|
||||
|
||||
class QmlProjectItem;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QmlProjectFile : public Core::IFile
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlProjectFile(QmlProject *parent, QString fileName);
|
||||
virtual ~QmlProjectFile();
|
||||
|
||||
virtual bool save(const QString &fileName = QString());
|
||||
virtual QString fileName() const;
|
||||
|
||||
virtual QString defaultPath() const;
|
||||
virtual QString suggestedFileName() const;
|
||||
virtual QString mimeType() const;
|
||||
|
||||
virtual bool isModified() const;
|
||||
virtual bool isReadOnly() const;
|
||||
virtual bool isSaveAsAllowed() const;
|
||||
|
||||
virtual void modified(ReloadBehavior *behavior);
|
||||
|
||||
private:
|
||||
QmlProject *m_project;
|
||||
QString m_fileName;
|
||||
};
|
||||
|
||||
class QmlRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QmlRunConfigurationFactory(QObject *parent = 0);
|
||||
~QmlRunConfigurationFactory();
|
||||
|
||||
QStringList availableCreationIds(ProjectExplorer::Target *parent) const;
|
||||
QString displayNameForId(const QString &id) const;
|
||||
|
||||
bool canCreate(ProjectExplorer::Target *parent, const QString &id) const;
|
||||
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const QString &id);
|
||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
|
||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
|
||||
};
|
||||
|
||||
class QmlRunControl : public ProjectExplorer::RunControl {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlRunControl(QmlRunConfiguration *runConfiguration, bool debugMode);
|
||||
virtual ~QmlRunControl ();
|
||||
|
||||
// RunControl
|
||||
virtual void start();
|
||||
virtual void stop();
|
||||
virtual bool isRunning() const;
|
||||
|
||||
private slots:
|
||||
void processExited(int exitCode);
|
||||
void slotBringApplicationToForeground(qint64 pid);
|
||||
void slotAddToOutputWindow(const QString &line);
|
||||
void slotError(const QString & error);
|
||||
|
||||
private:
|
||||
ProjectExplorer::ApplicationLauncher m_applicationLauncher;
|
||||
|
||||
QString m_executable;
|
||||
QStringList m_commandLineArguments;
|
||||
bool m_debugMode;
|
||||
};
|
||||
|
||||
class QmlRunControlFactory : public ProjectExplorer::IRunControlFactory {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlRunControlFactory(QObject *parent = 0);
|
||||
virtual ~QmlRunControlFactory();
|
||||
|
||||
// IRunControlFactory
|
||||
virtual bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode) const;
|
||||
virtual ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode);
|
||||
virtual QString displayName() const;
|
||||
virtual QWidget *configurationWidget(ProjectExplorer::RunConfiguration *runConfiguration);
|
||||
};
|
||||
class QmlProjectFile;
|
||||
class QmlProjectNode;
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -155,8 +72,8 @@ public:
|
||||
QString id() const;
|
||||
Core::IFile *file() const;
|
||||
Internal::Manager *projectManager() const;
|
||||
Internal::QmlTargetFactory *targetFactory() const;
|
||||
Internal::QmlTarget *activeTarget() const;
|
||||
Internal::QmlProjectTargetFactory *targetFactory() const;
|
||||
Internal::QmlProjectTarget *activeTarget() const;
|
||||
|
||||
QList<ProjectExplorer::Project *> dependsOn();
|
||||
|
||||
@@ -209,49 +126,7 @@ private:
|
||||
ProjectExplorer::FileWatcher *m_fileWatcher;
|
||||
|
||||
Internal::QmlProjectNode *m_rootNode;
|
||||
Internal::QmlTargetFactory *m_targetFactory;
|
||||
};
|
||||
|
||||
class QMLPROJECTMANAGER_EXPORT QmlRunConfiguration : public ProjectExplorer::RunConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class Internal::QmlRunConfigurationFactory;
|
||||
|
||||
public:
|
||||
QmlRunConfiguration(Internal::QmlTarget *parent);
|
||||
virtual ~QmlRunConfiguration();
|
||||
|
||||
Internal::QmlTarget *qmlTarget() const;
|
||||
|
||||
QString viewerPath() const;
|
||||
QStringList viewerArguments() const;
|
||||
QString workingDirectory() const;
|
||||
uint debugServerPort() const;
|
||||
|
||||
// RunConfiguration
|
||||
virtual QWidget *configurationWidget();
|
||||
|
||||
QVariantMap toMap() const;
|
||||
|
||||
private slots:
|
||||
QString mainScript() const;
|
||||
void setMainScript(const QString &scriptFile);
|
||||
void onQmlViewerChanged();
|
||||
void onQmlViewerArgsChanged();
|
||||
void onDebugServerPortChanged();
|
||||
|
||||
protected:
|
||||
QmlRunConfiguration(Internal::QmlTarget *parent, QmlRunConfiguration *source);
|
||||
virtual bool fromMap(const QVariantMap &map);
|
||||
|
||||
private:
|
||||
void ctor();
|
||||
|
||||
QString m_scriptFile;
|
||||
QString m_qmlViewerCustomPath;
|
||||
QString m_qmlViewerDefaultPath;
|
||||
QString m_qmlViewerArgs;
|
||||
uint m_debugServerPort;
|
||||
Internal::QmlProjectTargetFactory *m_targetFactory;
|
||||
};
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmlprojectfile.h"
|
||||
#include "qmlproject.h"
|
||||
#include "qmlprojectconstants.h"
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QmlProjectFile::QmlProjectFile(QmlProject *parent, QString fileName)
|
||||
: Core::IFile(parent),
|
||||
m_project(parent),
|
||||
m_fileName(fileName)
|
||||
{ }
|
||||
|
||||
QmlProjectFile::~QmlProjectFile()
|
||||
{ }
|
||||
|
||||
bool QmlProjectFile::save(const QString &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString QmlProjectFile::fileName() const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
QString QmlProjectFile::defaultPath() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QmlProjectFile::suggestedFileName() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QmlProjectFile::mimeType() const
|
||||
{
|
||||
return Constants::QMLMIMETYPE;
|
||||
}
|
||||
|
||||
bool QmlProjectFile::isModified() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QmlProjectFile::isReadOnly() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QmlProjectFile::isSaveAsAllowed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void QmlProjectFile::modified(ReloadBehavior *)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
@@ -0,0 +1,70 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QMLPROJECTFILE_H
|
||||
#define QMLPROJECTFILE_H
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
|
||||
class QmlProject;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QmlProjectFile : public Core::IFile
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlProjectFile(QmlProject *parent, QString fileName);
|
||||
virtual ~QmlProjectFile();
|
||||
|
||||
virtual bool save(const QString &fileName = QString());
|
||||
virtual QString fileName() const;
|
||||
|
||||
virtual QString defaultPath() const;
|
||||
virtual QString suggestedFileName() const;
|
||||
virtual QString mimeType() const;
|
||||
|
||||
virtual bool isModified() const;
|
||||
virtual bool isReadOnly() const;
|
||||
virtual bool isSaveAsAllowed() const;
|
||||
|
||||
virtual void modified(ReloadBehavior *behavior);
|
||||
|
||||
private:
|
||||
QmlProject *m_project;
|
||||
QString m_fileName;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
#endif // QMLPROJECTFILE_H
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "qmlproject.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -40,8 +41,8 @@
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
using namespace QmlProjectManager::Internal;
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
Manager::Manager()
|
||||
{
|
||||
@@ -101,3 +102,6 @@ void Manager::notifyChanged(const QString &fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -14,18 +14,27 @@ HEADERS += qmlproject.h \
|
||||
qmlprojectconstants.h \
|
||||
qmlprojectnodes.h \
|
||||
qmlprojectwizard.h \
|
||||
qmlprojectfile.h \
|
||||
qmlprojectruncontrol.h \
|
||||
qmlprojectrunconfiguration.h \
|
||||
qmlprojectrunconfigurationfactory.h \
|
||||
qmlnewprojectwizard.h \
|
||||
qmltaskmanager.h \
|
||||
qmlprojectmanager_global.h \
|
||||
qmltarget.h
|
||||
qmlprojectmanagerconstants.h \
|
||||
qmlprojecttarget.h
|
||||
SOURCES += qmlproject.cpp \
|
||||
qmlprojectplugin.cpp \
|
||||
qmlprojectmanager.cpp \
|
||||
qmlprojectnodes.cpp \
|
||||
qmlprojectwizard.cpp \
|
||||
qmlprojectfile.cpp \
|
||||
qmlprojectruncontrol.cpp \
|
||||
qmlprojectrunconfiguration.cpp \
|
||||
qmlprojectrunconfigurationfactory.cpp \
|
||||
qmlnewprojectwizard.cpp \
|
||||
qmltaskmanager.cpp \
|
||||
qmltarget.cpp
|
||||
qmlprojecttarget.cpp
|
||||
RESOURCES += qmlproject.qrc
|
||||
|
||||
OTHER_FILES += QmlProjectManager.pluginspec
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Constants {
|
||||
|
||||
const char * const QML_RC_ID("QmlProjectManager.QmlRunConfiguration");
|
||||
const char * const QML_RC_DISPLAY_NAME(QT_TRANSLATE_NOOP("QmlProjectManager::Internal::QmlRunConfiguration", "QML Viewer"));
|
||||
const char * const QML_VIEWER_KEY("QmlProjectManager.QmlRunConfiguration.QmlViewer");
|
||||
const char * const QML_VIEWER_ARGUMENTS_KEY("QmlProjectManager.QmlRunConfiguration.QmlViewerArguments");
|
||||
const char * const QML_VIEWER_TARGET_ID("QmlProjectManager.QmlTarget");
|
||||
const char * const QML_VIEWER_TARGET_DISPLAY_NAME("QML Viewer");
|
||||
const char * const QML_MAINSCRIPT_KEY("QmlProjectManager.QmlRunConfiguration.MainScript");
|
||||
const char * const QML_DEBUG_SERVER_PORT_KEY("QmlProjectManager.QmlRunConfiguration.DebugServerPort");
|
||||
|
||||
const int QML_DEFAULT_DEBUG_SERVER_PORT(3768);
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace QmlProjectManager
|
||||
@@ -36,9 +36,10 @@
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
using namespace QmlProjectManager::Internal;
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QmlProjectNode::QmlProjectNode(QmlProject *project, Core::IFile *projectFile)
|
||||
: ProjectExplorer::ProjectNode(QFileInfo(projectFile->fileName()).absoluteFilePath()),
|
||||
@@ -235,3 +236,6 @@ bool QmlProjectNode::renameFile(const ProjectExplorer::FileType fileType,
|
||||
Q_UNUSED(newFilePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QMLPROJECTNODE_H
|
||||
#define QMLPROJECTNODE_H
|
||||
#ifndef QMLPROJECTNODES_H
|
||||
#define QMLPROJECTNODES_H
|
||||
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
||||
@@ -89,4 +89,4 @@ private:
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
#endif // QMLPROJECTNODE_H
|
||||
#endif // QMLPROJECTNODES_H
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "qmlnewprojectwizard.h"
|
||||
#include "qmlprojectconstants.h"
|
||||
#include "qmlproject.h"
|
||||
#include "qmlprojectrunconfigurationfactory.h"
|
||||
#include "qmlprojectruncontrol.h"
|
||||
#include "qmltaskmanager.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
@@ -47,8 +49,8 @@
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
using namespace QmlProjectManager::Internal;
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QmlProjectPlugin::QmlProjectPlugin() :
|
||||
m_qmlTaskManager(0)
|
||||
@@ -75,8 +77,8 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
|
||||
m_qmlTaskManager = new QmlTaskManager(this);
|
||||
|
||||
addAutoReleasedObject(manager);
|
||||
addAutoReleasedObject(new QmlRunConfigurationFactory);
|
||||
addAutoReleasedObject(new QmlRunControlFactory);
|
||||
addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory);
|
||||
addAutoReleasedObject(new Internal::QmlRunControlFactory);
|
||||
addAutoReleasedObject(new QmlNewProjectWizard);
|
||||
addAutoReleasedObject(new QmlProjectWizard);
|
||||
return true;
|
||||
@@ -94,4 +96,7 @@ void QmlProjectPlugin::extensionsInitialized()
|
||||
m_qmlTaskManager, SLOT(documentUpdated(QmlJS::Document::Ptr)));
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(QmlProjectPlugin)
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
Q_EXPORT_PLUGIN(QmlProjectManager::Internal::QmlProjectPlugin)
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmlproject.h"
|
||||
#include "qmlprojectmanagerconstants.h"
|
||||
#include "qmlprojectrunconfiguration.h"
|
||||
#include "qmlprojecttarget.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QComboBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
|
||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent) :
|
||||
ProjectExplorer::RunConfiguration(parent, QLatin1String(Constants::QML_RC_ID)),
|
||||
m_debugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent, QmlProjectRunConfiguration *source) :
|
||||
ProjectExplorer::RunConfiguration(parent, source),
|
||||
m_scriptFile(source->m_scriptFile),
|
||||
m_qmlViewerCustomPath(source->m_qmlViewerCustomPath),
|
||||
m_qmlViewerArgs(source->m_qmlViewerArgs),
|
||||
m_debugServerPort(source->m_debugServerPort)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
void QmlProjectRunConfiguration::ctor()
|
||||
{
|
||||
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
|
||||
|
||||
// prepend creator/bin dir to search path (only useful for special creator-qml package)
|
||||
const QString searchPath = QCoreApplication::applicationDirPath()
|
||||
+ Utils::SynchronousProcess::pathSeparator()
|
||||
+ QString(qgetenv("PATH"));
|
||||
m_qmlViewerDefaultPath = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer"));
|
||||
}
|
||||
|
||||
QmlProjectRunConfiguration::~QmlProjectRunConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
Internal::QmlProjectTarget *QmlProjectRunConfiguration::qmlTarget() const
|
||||
{
|
||||
return static_cast<Internal::QmlProjectTarget *>(target());
|
||||
}
|
||||
|
||||
QString QmlProjectRunConfiguration::viewerPath() const
|
||||
{
|
||||
if (!m_qmlViewerCustomPath.isEmpty())
|
||||
return m_qmlViewerCustomPath;
|
||||
return m_qmlViewerDefaultPath;
|
||||
}
|
||||
|
||||
QStringList QmlProjectRunConfiguration::viewerArguments() const
|
||||
{
|
||||
QStringList args;
|
||||
|
||||
// arguments in .user file
|
||||
if (!m_qmlViewerArgs.isEmpty())
|
||||
args.append(m_qmlViewerArgs);
|
||||
|
||||
// arguments from .qmlproject file
|
||||
foreach (const QString &libraryPath, qmlTarget()->qmlProject()->libraryPaths()) {
|
||||
args.append(QLatin1String("-L"));
|
||||
args.append(libraryPath);
|
||||
}
|
||||
|
||||
const QString s = mainScript();
|
||||
if (! s.isEmpty())
|
||||
args.append(s);
|
||||
return args;
|
||||
}
|
||||
|
||||
QString QmlProjectRunConfiguration::workingDirectory() const
|
||||
{
|
||||
QFileInfo projectFile(qmlTarget()->qmlProject()->file()->fileName());
|
||||
return projectFile.absolutePath();
|
||||
}
|
||||
|
||||
uint QmlProjectRunConfiguration::debugServerPort() const
|
||||
{
|
||||
return m_debugServerPort;
|
||||
}
|
||||
|
||||
QWidget *QmlProjectRunConfiguration::configurationWidget()
|
||||
{
|
||||
QWidget *config = new QWidget;
|
||||
QFormLayout *form = new QFormLayout(config);
|
||||
|
||||
QComboBox *combo = new QComboBox;
|
||||
|
||||
QDir projectDir = qmlTarget()->qmlProject()->projectDir();
|
||||
QStringList files;
|
||||
|
||||
files.append(tr("<Current File>"));
|
||||
|
||||
int currentIndex = -1;
|
||||
|
||||
foreach (const QString &fn, qmlTarget()->qmlProject()->files()) {
|
||||
QFileInfo fileInfo(fn);
|
||||
if (fileInfo.suffix() != QLatin1String("qml"))
|
||||
continue;
|
||||
|
||||
QString fileName = projectDir.relativeFilePath(fn);
|
||||
if (fileName == m_scriptFile)
|
||||
currentIndex = files.size();
|
||||
|
||||
files.append(fileName);
|
||||
}
|
||||
|
||||
combo->addItems(files);
|
||||
if (currentIndex != -1)
|
||||
combo->setCurrentIndex(currentIndex);
|
||||
|
||||
connect(combo, SIGNAL(activated(QString)), this, SLOT(setMainScript(QString)));
|
||||
|
||||
Utils::PathChooser *qmlViewer = new Utils::PathChooser;
|
||||
qmlViewer->setExpectedKind(Utils::PathChooser::Command);
|
||||
qmlViewer->setPath(viewerPath());
|
||||
connect(qmlViewer, SIGNAL(changed(QString)), this, SLOT(onQmlViewerChanged()));
|
||||
|
||||
QLineEdit *qmlViewerArgs = new QLineEdit;
|
||||
qmlViewerArgs->setText(m_qmlViewerArgs);
|
||||
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 arguments:"), qmlViewerArgs);
|
||||
form->addRow(tr("Main QML File:"), combo);
|
||||
form->addRow(tr("Debugging Port:"), debugPort);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
QString QmlProjectRunConfiguration::mainScript() const
|
||||
{
|
||||
if (m_scriptFile.isEmpty() || m_scriptFile == tr("<Current File>")) {
|
||||
Core::EditorManager *editorManager = Core::ICore::instance()->editorManager();
|
||||
if (Core::IEditor *editor = editorManager->currentEditor()) {
|
||||
return editor->file()->fileName();
|
||||
}
|
||||
}
|
||||
|
||||
return qmlTarget()->qmlProject()->projectDir().absoluteFilePath(m_scriptFile);
|
||||
}
|
||||
|
||||
void QmlProjectRunConfiguration::setMainScript(const QString &scriptFile)
|
||||
{
|
||||
m_scriptFile = scriptFile;
|
||||
}
|
||||
|
||||
void QmlProjectRunConfiguration::onQmlViewerChanged()
|
||||
{
|
||||
if (Utils::PathChooser *chooser = qobject_cast<Utils::PathChooser *>(sender())) {
|
||||
m_qmlViewerCustomPath = chooser->path();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProjectRunConfiguration::onQmlViewerArgsChanged()
|
||||
{
|
||||
if (QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender()))
|
||||
m_qmlViewerArgs = lineEdit->text();
|
||||
}
|
||||
|
||||
void QmlProjectRunConfiguration::onDebugServerPortChanged()
|
||||
{
|
||||
if (QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender())) {
|
||||
m_debugServerPort = spinBox->value();
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap QmlProjectRunConfiguration::toMap() const
|
||||
{
|
||||
QVariantMap map(ProjectExplorer::RunConfiguration::toMap());
|
||||
|
||||
map.insert(QLatin1String(Constants::QML_VIEWER_KEY), m_qmlViewerCustomPath);
|
||||
map.insert(QLatin1String(Constants::QML_VIEWER_ARGUMENTS_KEY), m_qmlViewerArgs);
|
||||
map.insert(QLatin1String(Constants::QML_MAINSCRIPT_KEY), m_scriptFile);
|
||||
map.insert(QLatin1String(Constants::QML_DEBUG_SERVER_PORT_KEY), m_debugServerPort);
|
||||
return map;
|
||||
}
|
||||
|
||||
bool QmlProjectRunConfiguration::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_qmlViewerCustomPath = map.value(QLatin1String(Constants::QML_VIEWER_KEY)).toString();
|
||||
m_qmlViewerArgs = map.value(QLatin1String(Constants::QML_VIEWER_ARGUMENTS_KEY)).toString();
|
||||
m_scriptFile = map.value(QLatin1String(Constants::QML_MAINSCRIPT_KEY), tr("<Current File>")).toString();
|
||||
m_debugServerPort = map.value(QLatin1String(Constants::QML_DEBUG_SERVER_PORT_KEY), Constants::QML_DEFAULT_DEBUG_SERVER_PORT).toUInt();
|
||||
|
||||
return RunConfiguration::fromMap(map);
|
||||
}
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
@@ -0,0 +1,87 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QMLPROJECTRUNCONFIGURATION_H
|
||||
#define QMLPROJECTRUNCONFIGURATION_H
|
||||
|
||||
#include "qmlprojectmanager_global.h"
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
|
||||
namespace Internal {
|
||||
class QmlProjectTarget;
|
||||
class QmlProjectRunConfigurationFactory;
|
||||
}
|
||||
|
||||
class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplorer::RunConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class Internal::QmlProjectRunConfigurationFactory;
|
||||
|
||||
public:
|
||||
QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent);
|
||||
virtual ~QmlProjectRunConfiguration();
|
||||
|
||||
Internal::QmlProjectTarget *qmlTarget() const;
|
||||
|
||||
QString viewerPath() const;
|
||||
QStringList viewerArguments() const;
|
||||
QString workingDirectory() const;
|
||||
uint debugServerPort() const;
|
||||
|
||||
// RunConfiguration
|
||||
virtual QWidget *configurationWidget();
|
||||
|
||||
QVariantMap toMap() const;
|
||||
|
||||
private slots:
|
||||
QString mainScript() const;
|
||||
void setMainScript(const QString &scriptFile);
|
||||
void onQmlViewerChanged();
|
||||
void onQmlViewerArgsChanged();
|
||||
void onDebugServerPortChanged();
|
||||
|
||||
protected:
|
||||
QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent, QmlProjectRunConfiguration *source);
|
||||
virtual bool fromMap(const QVariantMap &map);
|
||||
|
||||
private:
|
||||
void ctor();
|
||||
|
||||
QString m_scriptFile;
|
||||
QString m_qmlViewerCustomPath;
|
||||
QString m_qmlViewerDefaultPath;
|
||||
QString m_qmlViewerArgs;
|
||||
uint m_debugServerPort;
|
||||
};
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
#endif // QMLPROJECTRUNCONFIGURATION_H
|
||||
@@ -0,0 +1,113 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmlprojectmanagerconstants.h"
|
||||
#include "qmlprojectrunconfiguration.h"
|
||||
#include "qmlprojectrunconfigurationfactory.h"
|
||||
#include "qmlprojecttarget.h"
|
||||
|
||||
#include <projectexplorer/projectconfiguration.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory(QObject *parent) :
|
||||
ProjectExplorer::IRunConfigurationFactory(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QmlProjectRunConfigurationFactory::~QmlProjectRunConfigurationFactory()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList QmlProjectRunConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const
|
||||
{
|
||||
if (!qobject_cast<QmlProjectTarget *>(parent))
|
||||
return QStringList();
|
||||
return QStringList() << QLatin1String(Constants::QML_RC_ID);
|
||||
}
|
||||
|
||||
QString QmlProjectRunConfigurationFactory::displayNameForId(const QString &id) const
|
||||
{
|
||||
if (id == QLatin1String(Constants::QML_RC_ID))
|
||||
return tr("Run QML Script");
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QmlProjectRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const QString &id) const
|
||||
{
|
||||
if (!qobject_cast<QmlProjectTarget *>(parent))
|
||||
return false;
|
||||
return id == QLatin1String(Constants::QML_RC_ID);
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::create(ProjectExplorer::Target *parent, const QString &id)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
QmlProjectTarget *qmlparent(static_cast<QmlProjectTarget *>(parent));
|
||||
return new QmlProjectRunConfiguration(qmlparent);
|
||||
}
|
||||
|
||||
bool QmlProjectRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
QString id(ProjectExplorer::idFromMap(map));
|
||||
return canCreate(parent, id);
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
QmlProjectTarget *qmlparent(static_cast<QmlProjectTarget *>(parent));
|
||||
QmlProjectRunConfiguration *rc(new QmlProjectRunConfiguration(qmlparent));
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
delete rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool QmlProjectRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const
|
||||
{
|
||||
return canCreate(parent, source->id());
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::clone(ProjectExplorer::Target *parent,
|
||||
ProjectExplorer::RunConfiguration *source)
|
||||
{
|
||||
if (!canClone(parent, source))
|
||||
return 0;
|
||||
QmlProjectTarget *qmlparent(static_cast<QmlProjectTarget *>(parent));
|
||||
return new QmlProjectRunConfiguration(qmlparent, qobject_cast<QmlProjectRunConfiguration *>(source));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QMLPROJECTRUNCONFIGURATIONFACTORY_H
|
||||
#define QMLPROJECTRUNCONFIGURATIONFACTORY_H
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class QmlProjectRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QmlProjectRunConfigurationFactory(QObject *parent = 0);
|
||||
~QmlProjectRunConfigurationFactory();
|
||||
|
||||
QStringList availableCreationIds(ProjectExplorer::Target *parent) const;
|
||||
QString displayNameForId(const QString &id) const;
|
||||
|
||||
bool canCreate(ProjectExplorer::Target *parent, const QString &id) const;
|
||||
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const QString &id);
|
||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
|
||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
|
||||
#endif // QMLPROJECTRUNCONFIGURATIONFACTORY_H
|
||||
@@ -0,0 +1,159 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmlprojectruncontrol.h"
|
||||
#include "qmlprojectrunconfiguration.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <projectexplorer/environment.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/applicationlauncher.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QLabel>
|
||||
|
||||
using ProjectExplorer::RunConfiguration;
|
||||
using ProjectExplorer::RunControl;
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QmlRunControl::QmlRunControl(QmlProjectRunConfiguration *runConfiguration, bool debugMode)
|
||||
: RunControl(runConfiguration), m_debugMode(debugMode)
|
||||
{
|
||||
ProjectExplorer::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_executable = runConfiguration->viewerPath();
|
||||
m_commandLineArguments = runConfiguration->viewerArguments();
|
||||
|
||||
connect(&m_applicationLauncher, SIGNAL(applicationError(QString)),
|
||||
this, SLOT(slotError(QString)));
|
||||
connect(&m_applicationLauncher, SIGNAL(appendOutput(QString)),
|
||||
this, SLOT(slotAddToOutputWindow(QString)));
|
||||
connect(&m_applicationLauncher, SIGNAL(processExited(int)),
|
||||
this, SLOT(processExited(int)));
|
||||
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
||||
this, SLOT(slotBringApplicationToForeground(qint64)));
|
||||
}
|
||||
|
||||
QmlRunControl::~QmlRunControl()
|
||||
{
|
||||
}
|
||||
|
||||
void QmlRunControl::start()
|
||||
{
|
||||
m_applicationLauncher.start(ProjectExplorer::ApplicationLauncher::Gui, m_executable,
|
||||
m_commandLineArguments);
|
||||
emit started();
|
||||
emit addToOutputWindow(this, tr("Starting %1 %2").arg(QDir::toNativeSeparators(m_executable),
|
||||
m_commandLineArguments.join(QLatin1String(" "))));
|
||||
}
|
||||
|
||||
void QmlRunControl::stop()
|
||||
{
|
||||
m_applicationLauncher.stop();
|
||||
}
|
||||
|
||||
bool QmlRunControl::isRunning() const
|
||||
{
|
||||
return m_applicationLauncher.isRunning();
|
||||
}
|
||||
|
||||
void QmlRunControl::slotBringApplicationToForeground(qint64 pid)
|
||||
{
|
||||
bringApplicationToForeground(pid);
|
||||
}
|
||||
|
||||
void QmlRunControl::slotError(const QString &err)
|
||||
{
|
||||
emit error(this, err);
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void QmlRunControl::slotAddToOutputWindow(const QString &line)
|
||||
{
|
||||
if (m_debugMode && line.startsWith("QmlDebugServer: Waiting for connection")) {
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
core->modeManager()->activateMode(QLatin1String("QML_INSPECT_MODE"));
|
||||
}
|
||||
|
||||
emit addToOutputWindowInline(this, line);
|
||||
}
|
||||
|
||||
void QmlRunControl::processExited(int exitCode)
|
||||
{
|
||||
emit addToOutputWindow(this, tr("%1 exited with code %2").arg(QDir::toNativeSeparators(m_executable)).arg(exitCode));
|
||||
emit finished();
|
||||
}
|
||||
|
||||
QmlRunControlFactory::QmlRunControlFactory(QObject *parent)
|
||||
: IRunControlFactory(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QmlRunControlFactory::~QmlRunControlFactory()
|
||||
{
|
||||
}
|
||||
|
||||
bool QmlRunControlFactory::canRun(RunConfiguration *runConfiguration,
|
||||
const QString &mode) const
|
||||
{
|
||||
Q_UNUSED(mode);
|
||||
return (qobject_cast<QmlProjectRunConfiguration*>(runConfiguration) != 0);
|
||||
}
|
||||
|
||||
RunControl *QmlRunControlFactory::create(RunConfiguration *runConfiguration,
|
||||
const QString &mode)
|
||||
{
|
||||
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
|
||||
return new QmlRunControl(qobject_cast<QmlProjectRunConfiguration *>(runConfiguration),
|
||||
mode == ProjectExplorer::Constants::DEBUGMODE);
|
||||
}
|
||||
|
||||
QString QmlRunControlFactory::displayName() const
|
||||
{
|
||||
return tr("Run");
|
||||
}
|
||||
|
||||
QWidget *QmlRunControlFactory::configurationWidget(RunConfiguration *runConfiguration)
|
||||
{
|
||||
Q_UNUSED(runConfiguration)
|
||||
return new QLabel("TODO add Configuration widget");
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QMLPROJECTRUNCONTROL_H
|
||||
#define QMLPROJECTRUNCONTROL_H
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/applicationlauncher.h>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
|
||||
class QmlProjectRunConfiguration;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QmlRunControl : public ProjectExplorer::RunControl {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlRunControl(QmlProjectRunConfiguration *runConfiguration, bool debugMode);
|
||||
virtual ~QmlRunControl ();
|
||||
|
||||
// RunControl
|
||||
virtual void start();
|
||||
virtual void stop();
|
||||
virtual bool isRunning() const;
|
||||
|
||||
private slots:
|
||||
void processExited(int exitCode);
|
||||
void slotBringApplicationToForeground(qint64 pid);
|
||||
void slotAddToOutputWindow(const QString &line);
|
||||
void slotError(const QString & error);
|
||||
|
||||
private:
|
||||
ProjectExplorer::ApplicationLauncher m_applicationLauncher;
|
||||
|
||||
QString m_executable;
|
||||
QStringList m_commandLineArguments;
|
||||
bool m_debugMode;
|
||||
};
|
||||
|
||||
class QmlRunControlFactory : public ProjectExplorer::IRunControlFactory {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlRunControlFactory(QObject *parent = 0);
|
||||
virtual ~QmlRunControlFactory();
|
||||
|
||||
// IRunControlFactory
|
||||
virtual bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode) const;
|
||||
virtual ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode);
|
||||
virtual QString displayName() const;
|
||||
virtual QWidget *configurationWidget(ProjectExplorer::RunConfiguration *runConfiguration);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
#endif // QMLPROJECTRUNCONTROL_H
|
||||
+31
-38
@@ -27,122 +27,115 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmltarget.h"
|
||||
#include "qmlprojecttarget.h"
|
||||
|
||||
#include "qmlproject.h"
|
||||
#include "qmlprojectmanagerconstants.h"
|
||||
#include "qmlprojectrunconfiguration.h"
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QStyle>
|
||||
|
||||
namespace {
|
||||
const char * const VIEWER_TARGET_DISPLAY_NAME("QML Viewer");
|
||||
}
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
using namespace QmlProjectManager::Internal;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// QmlTarget
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QmlTarget::QmlTarget(QmlProject *parent) :
|
||||
ProjectExplorer::Target(parent, QLatin1String(VIEWER_TARGET_ID))
|
||||
QmlProjectTarget::QmlProjectTarget(QmlProject *parent) :
|
||||
ProjectExplorer::Target(parent, QLatin1String(Constants::QML_VIEWER_TARGET_ID))
|
||||
{
|
||||
setDisplayName(QApplication::translate("QmlProjectManager::QmlTarget",
|
||||
VIEWER_TARGET_DISPLAY_NAME,
|
||||
Constants::QML_VIEWER_TARGET_DISPLAY_NAME,
|
||||
"Qml Viewer target display name"));
|
||||
setIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon));
|
||||
}
|
||||
|
||||
QmlTarget::~QmlTarget()
|
||||
QmlProjectTarget::~QmlProjectTarget()
|
||||
{
|
||||
}
|
||||
|
||||
QmlProject *QmlTarget::qmlProject() const
|
||||
QmlProject *QmlProjectTarget::qmlProject() const
|
||||
{
|
||||
return static_cast<QmlProject *>(project());
|
||||
}
|
||||
|
||||
ProjectExplorer::IBuildConfigurationFactory *QmlTarget::buildConfigurationFactory(void) const
|
||||
ProjectExplorer::IBuildConfigurationFactory *QmlProjectTarget::buildConfigurationFactory(void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool QmlTarget::fromMap(const QVariantMap &map)
|
||||
bool QmlProjectTarget::fromMap(const QVariantMap &map)
|
||||
{
|
||||
if (!Target::fromMap(map))
|
||||
return false;
|
||||
|
||||
setDisplayName(QApplication::translate("QmlProjectManager::QmlTarget",
|
||||
VIEWER_TARGET_DISPLAY_NAME,
|
||||
Constants::QML_VIEWER_TARGET_DISPLAY_NAME,
|
||||
"Qml Viewer target display name"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// QmlTargetFactory
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QmlTargetFactory::QmlTargetFactory(QObject *parent) :
|
||||
QmlProjectTargetFactory::QmlProjectTargetFactory(QObject *parent) :
|
||||
ITargetFactory(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QmlTargetFactory::~QmlTargetFactory()
|
||||
QmlProjectTargetFactory::~QmlProjectTargetFactory()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList QmlTargetFactory::availableCreationIds(ProjectExplorer::Project *parent) const
|
||||
QStringList QmlProjectTargetFactory::availableCreationIds(ProjectExplorer::Project *parent) const
|
||||
{
|
||||
if (!qobject_cast<QmlProject *>(parent))
|
||||
return QStringList();
|
||||
return QStringList() << QLatin1String(VIEWER_TARGET_ID);
|
||||
return QStringList() << QLatin1String(Constants::QML_VIEWER_TARGET_ID);
|
||||
}
|
||||
|
||||
QString QmlTargetFactory::displayNameForId(const QString &id) const
|
||||
QString QmlProjectTargetFactory::displayNameForId(const QString &id) const
|
||||
{
|
||||
if (id == QLatin1String(VIEWER_TARGET_ID))
|
||||
if (id == QLatin1String(Constants::QML_VIEWER_TARGET_ID))
|
||||
return QCoreApplication::translate("QmlProjectManager::QmlTarget",
|
||||
VIEWER_TARGET_DISPLAY_NAME,
|
||||
Constants::QML_VIEWER_TARGET_DISPLAY_NAME,
|
||||
"Qml Viewer target display name");
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QmlTargetFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const
|
||||
bool QmlProjectTargetFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const
|
||||
{
|
||||
if (!qobject_cast<QmlProject *>(parent))
|
||||
return false;
|
||||
return id == QLatin1String(VIEWER_TARGET_ID);
|
||||
return id == QLatin1String(Constants::QML_VIEWER_TARGET_ID);
|
||||
}
|
||||
|
||||
QmlTarget *QmlTargetFactory::create(ProjectExplorer::Project *parent, const QString &id)
|
||||
QmlProjectTarget *QmlProjectTargetFactory::create(ProjectExplorer::Project *parent, const QString &id)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
QmlProject *qmlproject(static_cast<QmlProject *>(parent));
|
||||
QmlTarget *t(new QmlTarget(qmlproject));
|
||||
QmlProjectTarget *t(new QmlProjectTarget(qmlproject));
|
||||
|
||||
// Add RunConfiguration (Qml does not have BuildConfigurations)
|
||||
QmlRunConfiguration *runConf(new QmlRunConfiguration(t));
|
||||
QmlProjectRunConfiguration *runConf(new QmlProjectRunConfiguration(t));
|
||||
t->addRunConfiguration(runConf);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
bool QmlTargetFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const
|
||||
bool QmlProjectTargetFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const
|
||||
{
|
||||
return canCreate(parent, ProjectExplorer::idFromMap(map));
|
||||
}
|
||||
|
||||
QmlTarget *QmlTargetFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map)
|
||||
QmlProjectTarget *QmlProjectTargetFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
QmlProject *qmlproject(static_cast<QmlProject *>(parent));
|
||||
QmlTarget *target(new QmlTarget(qmlproject));
|
||||
QmlProjectTarget *target(new QmlProjectTarget(qmlproject));
|
||||
if (target->fromMap(map))
|
||||
return target;
|
||||
delete target;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
+14
-17
@@ -27,8 +27,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QMLTARGET_H
|
||||
#define QMLTARGET_H
|
||||
#ifndef QMLPROJECTTARGET_H
|
||||
#define QMLPROJECTTARGET_H
|
||||
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
@@ -37,22 +37,20 @@
|
||||
|
||||
namespace QmlProjectManager {
|
||||
class QmlProject;
|
||||
class QmlRunConfiguration;
|
||||
class QmlProjectRunConfiguration;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
const char * const VIEWER_TARGET_ID("QmlProjectManager.QmlTarget");
|
||||
class QmlProjectTargetFactory;
|
||||
|
||||
class QmlTargetFactory;
|
||||
|
||||
class QmlTarget : public ProjectExplorer::Target
|
||||
class QmlProjectTarget : public ProjectExplorer::Target
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class QmlTargetFactory;
|
||||
friend class QmlProjectTargetFactory;
|
||||
|
||||
public:
|
||||
explicit QmlTarget(QmlProject *parent);
|
||||
~QmlTarget();
|
||||
explicit QmlProjectTarget(QmlProject *parent);
|
||||
~QmlProjectTarget();
|
||||
|
||||
QmlProject *qmlProject() const;
|
||||
|
||||
@@ -62,25 +60,24 @@ protected:
|
||||
bool fromMap(const QVariantMap &map);
|
||||
};
|
||||
|
||||
class QmlTargetFactory : public ProjectExplorer::ITargetFactory
|
||||
class QmlProjectTargetFactory : public ProjectExplorer::ITargetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QmlTargetFactory(QObject *parent = 0);
|
||||
~QmlTargetFactory();
|
||||
explicit QmlProjectTargetFactory(QObject *parent = 0);
|
||||
~QmlProjectTargetFactory();
|
||||
|
||||
QStringList availableCreationIds(ProjectExplorer::Project *parent) const;
|
||||
QString displayNameForId(const QString &id) const;
|
||||
|
||||
bool canCreate(ProjectExplorer::Project *parent, const QString &id) const;
|
||||
QmlTarget *create(ProjectExplorer::Project *parent, const QString &id);
|
||||
QmlProjectTarget *create(ProjectExplorer::Project *parent, const QString &id);
|
||||
bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const;
|
||||
QmlTarget *restore(ProjectExplorer::Project *parent, const QVariantMap &map);
|
||||
QmlProjectTarget *restore(ProjectExplorer::Project *parent, const QVariantMap &map);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
#endif // QMLTARGET_H
|
||||
#endif // QMLPROJECTTARGET_H
|
||||
@@ -43,9 +43,12 @@
|
||||
#include <QtCore/QtDebug>
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
using namespace QmlProjectManager::Internal;
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// QmlProjectWizardDialog
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -174,3 +177,5 @@ bool QmlProjectWizard::postGenerateFiles(const Core::GeneratedFiles &l, QString
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -48,7 +48,7 @@ void QmlTaskManager::setTaskWindow(ProjectExplorer::TaskWindow *taskWindow)
|
||||
m_taskWindow->addCategory(Constants::TASK_CATEGORY_QML, "Qml");
|
||||
}
|
||||
|
||||
void QmlTaskManager::documentUpdated(QmlJS::Document::Ptr doc)
|
||||
void QmlTaskManager::documentUpdated(QmlJS::Document::Ptr /*doc*/)
|
||||
{
|
||||
#if 0 // This will give way too many flickering errors in the build-results pane *when you're typing*
|
||||
m_taskWindow->clearTasks(Constants::TASK_CATEGORY_QML);
|
||||
@@ -66,4 +66,4 @@ void QmlTaskManager::documentUpdated(QmlJS::Document::Ptr doc)
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // QmlEditor
|
||||
} // QmlProjectManager
|
||||
|
||||
Reference in New Issue
Block a user