QmakeProjectManager: Rework run qmake action

Relied on some broken magic.

Change-Id: I1641f4b135e825ef60d57e99741def018ab9b55a
Task-number: QTCREATORBUG-13700
Reviewed-by: Robert Loehning <robert.loehning@theqtcompany.com>
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
Daniel Teske
2015-02-23 12:45:53 +01:00
parent e93484d480
commit 357d01817b
2 changed files with 16 additions and 11 deletions

View File

@@ -196,8 +196,8 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
connect(m_buildSubProjectAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(buildSubDirContextMenu())); connect(m_buildSubProjectAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(buildSubDirContextMenu()));
m_runQMakeAction = new QAction(tr("Run qmake"), this); m_runQMakeAction = new QAction(tr("Run qmake"), this);
command = Core::ActionManager::registerAction(m_runQMakeAction, Constants::RUNQMAKE, projectContext); const Core::Context globalcontext(Core::Constants::C_GLOBAL);
command->setAttribute(Core::Command::CA_Hide); command = Core::ActionManager::registerAction(m_runQMakeAction, Constants::RUNQMAKE, globalcontext);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
connect(m_runQMakeAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(runQMake())); connect(m_runQMakeAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(runQMake()));
@@ -231,8 +231,11 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
connect(BuildManager::instance(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)), connect(BuildManager::instance(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)),
this, SLOT(buildStateChanged(ProjectExplorer::Project*))); this, SLOT(buildStateChanged(ProjectExplorer::Project*)));
connect(SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
this, SLOT(startupProjectChanged())); this, &QmakeProjectManagerPlugin::projectChanged);
connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
this, &QmakeProjectManagerPlugin::projectChanged);
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged, connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
this, &QmakeProjectManagerPlugin::updateContextActions); this, &QmakeProjectManagerPlugin::updateContextActions);
@@ -272,13 +275,16 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
void QmakeProjectManagerPlugin::extensionsInitialized() void QmakeProjectManagerPlugin::extensionsInitialized()
{ } { }
void QmakeProjectManagerPlugin::startupProjectChanged() void QmakeProjectManagerPlugin::projectChanged()
{ {
if (m_previousStartupProject) if (m_previousStartupProject)
disconnect(m_previousStartupProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), disconnect(m_previousStartupProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(activeTargetChanged())); this, SLOT(activeTargetChanged()));
m_previousStartupProject = qobject_cast<QmakeProject *>(SessionManager::startupProject()); if (ProjectTree::currentProject())
m_previousStartupProject = qobject_cast<QmakeProject *>(ProjectTree::currentProject());
else
m_previousStartupProject = qobject_cast<QmakeProject *>(SessionManager::startupProject());
if (m_previousStartupProject) if (m_previousStartupProject)
connect(m_previousStartupProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), connect(m_previousStartupProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
@@ -305,11 +311,10 @@ void QmakeProjectManagerPlugin::activeTargetChanged()
void QmakeProjectManagerPlugin::updateRunQMakeAction() void QmakeProjectManagerPlugin::updateRunQMakeAction()
{ {
bool enable = true; bool enable = true;
if (BuildManager::isBuilding(ProjectTree::currentProject())) if (BuildManager::isBuilding(m_previousStartupProject))
enable = false; enable = false;
QmakeProject *pro = qobject_cast<QmakeProject *>(ProjectTree::currentProject()); QmakeProject *pro = qobject_cast<QmakeProject *>(m_previousStartupProject);
if (!pro) m_runQMakeAction->setVisible(pro);
pro = qobject_cast<QmakeProject *>(SessionManager::startupProject());
if (!pro if (!pro
|| !pro->activeTarget() || !pro->activeTarget()
|| !pro->activeTarget()->activeBuildConfiguration()) || !pro->activeTarget()->activeBuildConfiguration())

View File

@@ -65,7 +65,7 @@ public:
void extensionsInitialized(); void extensionsInitialized();
private slots: private slots:
void startupProjectChanged(); void projectChanged();
void activeTargetChanged(); void activeTargetChanged();
void updateRunQMakeAction(); void updateRunQMakeAction();
void updateContextActions(ProjectExplorer::Node *node, ProjectExplorer::Project *project); void updateContextActions(ProjectExplorer::Node *node, ProjectExplorer::Project *project);