forked from qt-creator/qt-creator
QmlProject: Support both qmlscene and qmlviewer in run configuration
Provide both qmlviewer and qmlscene as run configurations if the active Qt version is 5.0.0. Change-Id: Iaff1361921bdd2d6b2256c4c4cb51e96802c2519 Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
This commit is contained in:
@@ -33,7 +33,8 @@
|
||||
namespace QmlProjectManager {
|
||||
namespace Constants {
|
||||
|
||||
const char QML_RC_ID[] = "QmlProjectManager.QmlRunConfiguration";
|
||||
const char QML_VIEWER_RC_ID[] = "QmlProjectManager.QmlRunConfiguration";
|
||||
const char QML_SCENE_RC_ID[] = "QmlProjectManager.QmlRunConfiguration.QmlScene";
|
||||
const char QML_VIEWER_ARGUMENTS_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments";
|
||||
const char QML_VIEWER_TARGET_DISPLAY_NAME[] = "QML Viewer";
|
||||
const char QML_MAINSCRIPT_KEY[] = "QmlProjectManager.QmlRunConfiguration.MainScript";
|
||||
|
||||
@@ -57,8 +57,9 @@ namespace QmlProjectManager {
|
||||
|
||||
const char * const M_CURRENT_FILE = "CurrentFile";
|
||||
|
||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(ProjectExplorer::Target *parent) :
|
||||
ProjectExplorer::RunConfiguration(parent, Core::Id(Constants::QML_RC_ID)),
|
||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(ProjectExplorer::Target *parent,
|
||||
Core::Id id) :
|
||||
ProjectExplorer::RunConfiguration(parent, id),
|
||||
m_scriptFile(M_CURRENT_FILE),
|
||||
m_isEnabled(false)
|
||||
{
|
||||
@@ -84,7 +85,7 @@ bool QmlProjectRunConfiguration::isEnabled() const
|
||||
QString QmlProjectRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (!m_isEnabled)
|
||||
return tr("No qmlviewer or qmlobserver found.");
|
||||
return tr("No qmlviewer or qmlscene found.");
|
||||
return QString();
|
||||
}
|
||||
|
||||
@@ -101,7 +102,10 @@ void QmlProjectRunConfiguration::ctor()
|
||||
connect(target(), SIGNAL(profileChanged()),
|
||||
this, SLOT(updateEnabled()));
|
||||
|
||||
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
|
||||
if (id() == Constants::QML_SCENE_RC_ID)
|
||||
setDisplayName(tr("QML Scene", "QMLRunConfiguration display name."));
|
||||
else
|
||||
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
|
||||
}
|
||||
|
||||
QmlProjectRunConfiguration::~QmlProjectRunConfiguration()
|
||||
@@ -113,6 +117,9 @@ QString QmlProjectRunConfiguration::viewerPath() const
|
||||
QtSupport::BaseQtVersion *version = qtVersion();
|
||||
if (!version)
|
||||
return QString();
|
||||
|
||||
if (id() == Constants::QML_SCENE_RC_ID)
|
||||
return version->qmlsceneCommand();
|
||||
else
|
||||
return version->qmlviewerCommand();
|
||||
}
|
||||
@@ -123,6 +130,8 @@ QString QmlProjectRunConfiguration::observerPath() const
|
||||
if (!version) {
|
||||
return QString();
|
||||
} else {
|
||||
if (id() == Constants::QML_SCENE_RC_ID)
|
||||
return version->qmlsceneCommand();
|
||||
if (!version->needsQmlDebuggingLibrary())
|
||||
return version->qmlviewerCommand();
|
||||
return version->qmlObserverTool();
|
||||
|
||||
@@ -64,7 +64,7 @@ class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplor
|
||||
friend class Internal::QmlProjectRunConfigurationWidget;
|
||||
|
||||
public:
|
||||
QmlProjectRunConfiguration(ProjectExplorer::Target *parent);
|
||||
QmlProjectRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
|
||||
virtual ~QmlProjectRunConfiguration();
|
||||
|
||||
QString viewerPath() const;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <projectexplorer/projectconfiguration.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qtsupport/qtprofileinformation.h>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
@@ -55,40 +56,65 @@ QList<Core::Id> QmlProjectRunConfigurationFactory::availableCreationIds(ProjectE
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return QList<Core::Id>();
|
||||
return QList<Core::Id>() << Core::Id(Constants::QML_RC_ID);
|
||||
|
||||
QtSupport::BaseQtVersion *version
|
||||
= QtSupport::QtProfileInformation::qtVersion(parent->profile());
|
||||
|
||||
// put qmlscene first (so that it is the default) for Qt 5.0.0
|
||||
QList<Core::Id> list;
|
||||
if (version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0))
|
||||
list << Core::Id(Constants::QML_SCENE_RC_ID);
|
||||
|
||||
list << Core::Id(Constants::QML_VIEWER_RC_ID);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
QString QmlProjectRunConfigurationFactory::displayNameForId(const Core::Id id) const
|
||||
{
|
||||
if (id == Constants::QML_RC_ID)
|
||||
return tr("Run QML Script");
|
||||
if (id == Constants::QML_VIEWER_RC_ID)
|
||||
return tr("QML Viewer");
|
||||
if (id == Constants::QML_SCENE_RC_ID)
|
||||
return tr("QML Scene");
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QmlProjectRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const
|
||||
bool QmlProjectRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent,
|
||||
const Core::Id id) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return id == Constants::QML_RC_ID;
|
||||
|
||||
if (id == Constants::QML_VIEWER_RC_ID)
|
||||
return true;
|
||||
|
||||
if (id == Constants::QML_SCENE_RC_ID) {
|
||||
// only support qmlscene if it's Qt5
|
||||
QtSupport::BaseQtVersion *version
|
||||
= QtSupport::QtProfileInformation::qtVersion(parent->profile());
|
||||
return version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
return new QmlProjectRunConfiguration(parent);
|
||||
return new QmlProjectRunConfiguration(parent, id);
|
||||
}
|
||||
|
||||
bool QmlProjectRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
return canCreate(parent, ProjectExplorer::idFromMap(map));
|
||||
return parent && canCreate(parent, ProjectExplorer::idFromMap(map));
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
QmlProjectRunConfiguration *rc = new QmlProjectRunConfiguration(parent);
|
||||
|
||||
QmlProjectRunConfiguration *rc = new QmlProjectRunConfiguration(parent, id);
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
delete rc;
|
||||
|
||||
Reference in New Issue
Block a user