forked from qt-creator/qt-creator
QmlProjectRunConfiguration: update enabled state on adding to a project
Task-number: QTCREATORBUG-7980 Change-Id: I63fa4809772ce2f7169baf3270fe753b22ea4a04 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -74,6 +74,9 @@ QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName)
|
||||
Core::DocumentManager::addDocument(m_file, true);
|
||||
|
||||
m_manager->registerProject(this);
|
||||
|
||||
connect(this, SIGNAL(addedTarget(ProjectExplorer::Target*)),
|
||||
this, SLOT(addedTarget(ProjectExplorer::Target*)));
|
||||
}
|
||||
|
||||
QmlProject::~QmlProject()
|
||||
@@ -86,6 +89,23 @@ QmlProject::~QmlProject()
|
||||
delete m_rootNode;
|
||||
}
|
||||
|
||||
void QmlProject::addedTarget(ProjectExplorer::Target *target)
|
||||
{
|
||||
connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
||||
this, SLOT(addedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
||||
foreach (ProjectExplorer::RunConfiguration *rc, target->runConfigurations())
|
||||
addedRunConfiguration(rc);
|
||||
}
|
||||
|
||||
void QmlProject::addedRunConfiguration(ProjectExplorer::RunConfiguration *rc)
|
||||
{
|
||||
// The enabled state of qml runconfigurations can only be decided after
|
||||
// they have been added to a project
|
||||
QmlProjectRunConfiguration *qmlrc = qobject_cast<QmlProjectRunConfiguration *>(rc);
|
||||
if (qmlrc)
|
||||
qmlrc->updateEnabled();
|
||||
}
|
||||
|
||||
QDir QmlProject::projectDir() const
|
||||
{
|
||||
return QFileInfo(document()->fileName()).dir();
|
||||
@@ -309,13 +329,6 @@ bool QmlProject::fromMap(const QVariantMap &map)
|
||||
addTarget(createTarget(defaultKit));
|
||||
|
||||
refresh(Everything);
|
||||
// FIXME workaround to guarantee that run/debug actions are enabled if a valid file exists
|
||||
if (activeTarget()) {
|
||||
QmlProjectRunConfiguration *runConfig = qobject_cast<QmlProjectRunConfiguration*>(activeTarget()->activeRunConfiguration());
|
||||
if (runConfig)
|
||||
runConfig->changeCurrentFile(0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include <QDeclarativeEngine>
|
||||
|
||||
namespace ProjectExplorer { class RunConfiguration; }
|
||||
namespace QmlJS { class ModelManagerInterface; }
|
||||
namespace Utils { class FileSystemWatcher; }
|
||||
|
||||
@@ -94,6 +95,8 @@ public:
|
||||
|
||||
private slots:
|
||||
void refreshFiles(const QSet<QString> &added, const QSet<QString> &removed);
|
||||
void addedTarget(ProjectExplorer::Target *target);
|
||||
void addedRunConfiguration(ProjectExplorer::RunConfiguration *);
|
||||
|
||||
protected:
|
||||
bool fromMap(const QVariantMap &map);
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace Utils {
|
||||
namespace QtSupport { class BaseQtVersion; }
|
||||
|
||||
namespace QmlProjectManager {
|
||||
class QmlProject;
|
||||
|
||||
namespace Internal {
|
||||
class QmlProjectRunConfigurationFactory;
|
||||
@@ -61,6 +62,7 @@ class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplor
|
||||
Q_OBJECT
|
||||
friend class Internal::QmlProjectRunConfigurationFactory;
|
||||
friend class Internal::QmlProjectRunConfigurationWidget;
|
||||
friend class QmlProject; // to call updateEnabled()
|
||||
|
||||
public:
|
||||
QmlProjectRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
|
||||
@@ -93,10 +95,8 @@ public:
|
||||
|
||||
ProjectExplorer::Abi abi() const;
|
||||
|
||||
public slots:
|
||||
void changeCurrentFile(Core::IEditor*);
|
||||
|
||||
private slots:
|
||||
void changeCurrentFile(Core::IEditor*);
|
||||
void updateEnabled();
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user