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:
@@ -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