2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakeprojectmanagerplugin.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2014-08-20 14:43:06 +02:00
|
|
|
#include "profileeditor.h"
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakeprojectmanager.h"
|
|
|
|
|
#include "qmakenodes.h"
|
2019-03-04 17:29:57 +01:00
|
|
|
#include "qmakesettings.h"
|
2010-03-17 17:45:33 +01:00
|
|
|
#include "qmakestep.h"
|
2018-05-17 09:37:56 +02:00
|
|
|
#include "qmakemakestep.h"
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakebuildconfiguration.h"
|
2016-05-11 09:27:18 +02:00
|
|
|
#include "wizards/simpleprojectwizard.h"
|
2010-11-24 15:18:50 +01:00
|
|
|
#include "wizards/subdirsprojectwizard.h"
|
2009-06-29 14:47:04 +02:00
|
|
|
#include "customwidgetwizard/customwidgetwizard.h"
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakeprojectmanagerconstants.h"
|
|
|
|
|
#include "qmakeproject.h"
|
2009-05-19 14:54:52 +02:00
|
|
|
#include "externaleditors.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "qmakekitinformation.h"
|
2014-06-26 00:27:27 +02:00
|
|
|
#include "profilehighlighter.h"
|
2009-05-26 15:31:29 +02:00
|
|
|
|
2009-01-20 15:31:33 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2013-04-30 15:12:48 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2009-01-13 13:39:31 +01:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2013-04-30 15:12:48 +02:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/buildmanager.h>
|
|
|
|
|
#include <projectexplorer/projectmanager.h>
|
|
|
|
|
#include <projectexplorer/projecttree.h>
|
2019-03-13 12:22:44 +01:00
|
|
|
#include <projectexplorer/runcontrol.h>
|
2017-12-04 13:53:38 +01:00
|
|
|
#include <projectexplorer/session.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <texteditor/texteditoractionhandler.h>
|
2010-05-25 16:16:04 +02:00
|
|
|
#include <texteditor/texteditorconstants.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2012-04-12 15:56:02 +04:00
|
|
|
#include <utils/parameteraction.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#ifdef WITH_TESTS
|
2009-12-09 13:54:46 +01:00
|
|
|
# include <QTest>
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
2015-05-18 17:08:56 +02:00
|
|
|
using namespace Core;
|
2013-09-05 11:46:07 +02:00
|
|
|
using namespace ProjectExplorer;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
namespace QmakeProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class QmakeProjectManagerPluginPrivate : public QObject
|
|
|
|
|
{
|
|
|
|
|
public:
|
2018-07-12 23:59:51 +02:00
|
|
|
~QmakeProjectManagerPluginPrivate() override;
|
2018-02-09 16:17:00 +01:00
|
|
|
|
|
|
|
|
void projectChanged();
|
|
|
|
|
void activeTargetChanged();
|
|
|
|
|
void updateActions();
|
|
|
|
|
void updateRunQMakeAction();
|
|
|
|
|
void updateContextActions();
|
|
|
|
|
void buildStateChanged(Project *pro);
|
|
|
|
|
void updateBuildFileAction();
|
|
|
|
|
void disableBuildFileMenus();
|
2019-05-28 13:49:26 +02:00
|
|
|
void enableBuildFileMenus(const Utils::FilePath &file);
|
2018-02-09 16:17:00 +01:00
|
|
|
|
|
|
|
|
QmakeManager qmakeProjectManager;
|
|
|
|
|
Core::Context projectContext;
|
|
|
|
|
|
|
|
|
|
CustomWizardMetaFactory<CustomQmakeProjectWizard>
|
|
|
|
|
qmakeProjectWizard{"qmakeproject", IWizardFactory::ProjectWizard};
|
|
|
|
|
|
|
|
|
|
QMakeStepFactory qmakeStepFactory;
|
2018-05-14 16:39:19 +02:00
|
|
|
QmakeMakeStepFactory makeStepFactory;
|
2018-02-09 16:17:00 +01:00
|
|
|
|
|
|
|
|
QmakeBuildConfigurationFactory buildConfigFactory;
|
|
|
|
|
|
|
|
|
|
ProFileEditorFactory profileEditorFactory;
|
|
|
|
|
|
2019-03-04 17:29:57 +01:00
|
|
|
QmakeSettingsPage settingsPage;
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
ExternalQtEditor *m_designerEditor{ExternalQtEditor::createDesignerEditor()};
|
|
|
|
|
ExternalQtEditor *m_linguistEditor{ExternalQtEditor::createLinguistEditor()};
|
|
|
|
|
|
|
|
|
|
QmakeProject *m_previousStartupProject = nullptr;
|
|
|
|
|
ProjectExplorer::Target *m_previousTarget = nullptr;
|
|
|
|
|
|
|
|
|
|
QAction *m_runQMakeAction = nullptr;
|
|
|
|
|
QAction *m_runQMakeActionContextMenu = nullptr;
|
|
|
|
|
Utils::ParameterAction *m_buildSubProjectContextMenu = nullptr;
|
|
|
|
|
QAction *m_subProjectRebuildSeparator = nullptr;
|
|
|
|
|
QAction *m_rebuildSubProjectContextMenu = nullptr;
|
|
|
|
|
QAction *m_cleanSubProjectContextMenu = nullptr;
|
|
|
|
|
QAction *m_buildFileContextMenu = nullptr;
|
|
|
|
|
Utils::ParameterAction *m_buildSubProjectAction = nullptr;
|
|
|
|
|
Utils::ParameterAction *m_rebuildSubProjectAction = nullptr;
|
|
|
|
|
Utils::ParameterAction *m_cleanSubProjectAction = nullptr;
|
|
|
|
|
Utils::ParameterAction *m_buildFileAction = nullptr;
|
|
|
|
|
QAction *m_addLibraryAction = nullptr;
|
|
|
|
|
QAction *m_addLibraryActionContextMenu = nullptr;
|
2019-03-14 09:17:59 +01:00
|
|
|
|
|
|
|
|
QmakeKitAspect qmakeKitAspect;
|
2018-02-09 16:17:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QmakeProjectManagerPlugin::~QmakeProjectManagerPlugin()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(arguments)
|
2015-02-04 09:32:46 +01:00
|
|
|
Q_UNUSED(errorMessage)
|
2017-12-20 11:13:26 +01:00
|
|
|
const Context projectContext(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
|
2015-05-18 17:08:56 +02:00
|
|
|
Context projecTreeContext(ProjectExplorer::Constants::C_PROJECT_TREE);
|
2010-01-29 21:33:57 +01:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d = new QmakeProjectManagerPluginPrivate;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
//create and register objects
|
2017-03-03 18:16:34 +01:00
|
|
|
ProjectManager::registerProjectType<QmakeProject>(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
|
|
|
|
|
|
2016-05-11 09:27:18 +02:00
|
|
|
IWizardFactory::registerFactoryCreator([] {
|
|
|
|
|
return QList<IWizardFactory *> {
|
|
|
|
|
new SubdirsProjectWizard,
|
|
|
|
|
new CustomWidgetWizard,
|
|
|
|
|
new SimpleProjectWizard
|
|
|
|
|
};
|
2015-05-22 17:16:36 +02:00
|
|
|
});
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//menus
|
2015-05-18 17:08:56 +02:00
|
|
|
ActionContainer *mbuild =
|
|
|
|
|
ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT);
|
|
|
|
|
ActionContainer *mproject =
|
|
|
|
|
ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT);
|
|
|
|
|
ActionContainer *msubproject =
|
|
|
|
|
ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
|
|
|
|
|
ActionContainer *mfile =
|
|
|
|
|
ActionManager::actionContainer(ProjectExplorer::Constants::M_FILECONTEXT);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//register actions
|
2016-03-29 16:09:16 +02:00
|
|
|
Command *command = nullptr;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_buildSubProjectContextMenu = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""),
|
2012-04-26 19:28:59 +02:00
|
|
|
Utils::ParameterAction::AlwaysEnabled/*handled manually*/,
|
|
|
|
|
this);
|
2018-02-09 16:17:00 +01:00
|
|
|
command = ActionManager::registerAction(d->m_buildSubProjectContextMenu, Constants::BUILDSUBDIRCONTEXTMENU, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2018-02-09 16:17:00 +01:00
|
|
|
command->setDescription(d->m_buildSubProjectContextMenu->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_buildSubProjectContextMenu, &QAction::triggered,
|
|
|
|
|
&d->qmakeProjectManager, &QmakeManager::buildSubDirContextMenu);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_runQMakeActionContextMenu = new QAction(tr("Run qmake"), this);
|
|
|
|
|
command = ActionManager::registerAction(d->m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
2008-12-02 12:01:29 +01:00
|
|
|
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2010-01-13 18:00:02 +01:00
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_runQMakeActionContextMenu, &QAction::triggered,
|
|
|
|
|
&d->qmakeProjectManager, &QmakeManager::runQMakeContextMenu);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-06-05 14:22:20 +02:00
|
|
|
command = msubproject->addSeparator(projectContext, ProjectExplorer::Constants::G_PROJECT_BUILD,
|
2018-02-09 16:17:00 +01:00
|
|
|
&d->m_subProjectRebuildSeparator);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
2010-01-13 18:00:02 +01:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_rebuildSubProjectContextMenu = new QAction(tr("Rebuild"), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_rebuildSubProjectContextMenu, Constants::REBUILDSUBDIRCONTEXTMENU, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
2010-04-30 11:50:04 +02:00
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_rebuildSubProjectContextMenu, &QAction::triggered,
|
|
|
|
|
&d->qmakeProjectManager, &QmakeManager::rebuildSubDirContextMenu);
|
2010-04-30 11:50:04 +02:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_cleanSubProjectContextMenu = new QAction(tr("Clean"), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_cleanSubProjectContextMenu, Constants::CLEANSUBDIRCONTEXTMENU, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
2010-04-30 11:50:04 +02:00
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_cleanSubProjectContextMenu, &QAction::triggered,
|
|
|
|
|
&d->qmakeProjectManager, &QmakeManager::cleanSubDirContextMenu);
|
2010-04-30 11:50:04 +02:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_buildFileContextMenu = new QAction(tr("Build"), this);
|
|
|
|
|
command = ActionManager::registerAction(d->m_buildFileContextMenu, Constants::BUILDFILECONTEXTMENU, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
2012-05-14 22:46:23 +03:00
|
|
|
mfile->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_buildFileContextMenu, &QAction::triggered,
|
|
|
|
|
&d->qmakeProjectManager, &QmakeManager::buildFileContextMenu);
|
2012-05-14 22:46:23 +03:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_buildSubProjectAction = new Utils::ParameterAction(tr("Build Subproject"), tr("Build Subproject \"%1\""),
|
2012-05-11 07:29:45 +03:00
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2018-02-09 16:17:00 +01:00
|
|
|
command = ActionManager::registerAction(d->m_buildSubProjectAction, Constants::BUILDSUBDIR, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2018-02-09 16:17:00 +01:00
|
|
|
command->setDescription(d->m_buildSubProjectAction->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_buildSubProjectAction, &QAction::triggered,
|
|
|
|
|
&d->qmakeProjectManager, &QmakeManager::buildSubDirContextMenu);
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_runQMakeAction = new QAction(tr("Run qmake"), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
const Context globalcontext(Core::Constants::C_GLOBAL);
|
2018-02-09 16:17:00 +01:00
|
|
|
command = ActionManager::registerAction(d->m_runQMakeAction, Constants::RUNQMAKE, globalcontext);
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_runQMakeAction, &QAction::triggered, &d->qmakeProjectManager, &QmakeManager::runQMake);
|
2012-04-26 19:28:59 +02:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_rebuildSubProjectAction = new Utils::ParameterAction(tr("Rebuild Subproject"), tr("Rebuild Subproject \"%1\""),
|
2012-05-11 07:29:45 +03:00
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2018-02-09 16:17:00 +01:00
|
|
|
command = ActionManager::registerAction(d->m_rebuildSubProjectAction, Constants::REBUILDSUBDIR, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2018-02-09 16:17:00 +01:00
|
|
|
command->setDescription(d->m_rebuildSubProjectAction->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_REBUILD);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_rebuildSubProjectAction, &QAction::triggered,
|
|
|
|
|
&d->qmakeProjectManager, &QmakeManager::rebuildSubDirContextMenu);
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_cleanSubProjectAction = new Utils::ParameterAction(tr("Clean Subproject"), tr("Clean Subproject \"%1\""),
|
2012-05-11 07:29:45 +03:00
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2018-02-09 16:17:00 +01:00
|
|
|
command = ActionManager::registerAction(d->m_cleanSubProjectAction, Constants::CLEANSUBDIR, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2018-02-09 16:17:00 +01:00
|
|
|
command->setDescription(d->m_cleanSubProjectAction->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_CLEAN);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_cleanSubProjectAction, &QAction::triggered,
|
|
|
|
|
&d->qmakeProjectManager, &QmakeManager::cleanSubDirContextMenu);
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_buildFileAction = new Utils::ParameterAction(tr("Build File"), tr("Build File \"%1\""),
|
2012-05-11 13:31:06 +03:00
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2018-02-09 16:17:00 +01:00
|
|
|
command = ActionManager::registerAction(d->m_buildFileAction, Constants::BUILDFILE, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2018-02-09 16:17:00 +01:00
|
|
|
command->setDescription(d->m_buildFileAction->text());
|
2012-05-04 16:25:41 +03:00
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+B")));
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_buildFileAction, &QAction::triggered, &d->qmakeProjectManager, &QmakeManager::buildFile);
|
2012-05-04 16:25:41 +03:00
|
|
|
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(BuildManager::instance(), &BuildManager::buildStateChanged,
|
2018-02-09 16:17:00 +01:00
|
|
|
d, &QmakeProjectManagerPluginPrivate::buildStateChanged);
|
2015-02-23 12:45:53 +01:00
|
|
|
connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
|
2018-02-09 16:17:00 +01:00
|
|
|
d, &QmakeProjectManagerPluginPrivate::projectChanged);
|
2015-02-23 12:45:53 +01:00
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
|
2018-02-09 16:17:00 +01:00
|
|
|
d, &QmakeProjectManagerPluginPrivate::projectChanged);
|
2015-02-23 12:45:53 +01:00
|
|
|
|
2014-11-19 17:58:33 +01:00
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
|
2018-02-09 16:17:00 +01:00
|
|
|
d, &QmakeProjectManagerPluginPrivate::updateContextActions);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-05-18 17:08:56 +02:00
|
|
|
ActionContainer *contextMenu = ActionManager::createMenu(QmakeProjectManager::Constants::M_CONTEXT);
|
2010-05-25 16:16:04 +02:00
|
|
|
|
2015-05-18 17:08:56 +02:00
|
|
|
Context proFileEditorContext = Context(QmakeProjectManager::Constants::PROFILE_EDITOR_ID);
|
2010-08-16 18:23:30 +02:00
|
|
|
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR);
|
2011-04-13 13:54:15 +02:00
|
|
|
contextMenu->addAction(command);
|
2010-10-14 11:54:29 +02:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_addLibraryAction = new QAction(tr("Add Library..."), this);
|
|
|
|
|
command = ActionManager::registerAction(d->m_addLibraryAction,
|
2010-08-16 18:23:30 +02:00
|
|
|
Constants::ADDLIBRARY, proFileEditorContext);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_addLibraryAction, &QAction::triggered, &d->qmakeProjectManager, &QmakeManager::addLibrary);
|
2011-04-13 13:54:15 +02:00
|
|
|
contextMenu->addAction(command);
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->m_addLibraryActionContextMenu = new QAction(tr("Add Library..."), this);
|
|
|
|
|
command = ActionManager::registerAction(d->m_addLibraryActionContextMenu,
|
2011-04-13 13:54:15 +02:00
|
|
|
Constants::ADDLIBRARY, projecTreeContext);
|
2018-02-09 16:17:00 +01:00
|
|
|
connect(d->m_addLibraryActionContextMenu, &QAction::triggered,
|
|
|
|
|
&d->qmakeProjectManager, &QmakeManager::addLibraryContextMenu);
|
2011-04-13 13:54:15 +02:00
|
|
|
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_FILES);
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_FILES);
|
2010-08-16 18:23:30 +02:00
|
|
|
|
2012-06-05 14:22:20 +02:00
|
|
|
contextMenu->addSeparator(proFileEditorContext);
|
2010-10-14 11:54:29 +02:00
|
|
|
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION);
|
2011-04-13 13:54:15 +02:00
|
|
|
contextMenu->addAction(command);
|
2010-10-14 11:54:29 +02:00
|
|
|
|
2015-05-18 17:08:56 +02:00
|
|
|
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
|
2018-02-09 16:17:00 +01:00
|
|
|
d, &QmakeProjectManagerPluginPrivate::updateBuildFileAction);
|
2013-04-30 15:12:48 +02:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
d->updateActions();
|
2016-03-10 12:21:41 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
QmakeProjectManagerPluginPrivate::~QmakeProjectManagerPluginPrivate()
|
|
|
|
|
{
|
|
|
|
|
delete m_designerEditor;
|
|
|
|
|
delete m_linguistEditor;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
void QmakeProjectManagerPluginPrivate::projectChanged()
|
2011-10-28 10:15:04 +00:00
|
|
|
{
|
|
|
|
|
if (m_previousStartupProject)
|
2016-03-10 12:21:30 +01:00
|
|
|
disconnect(m_previousStartupProject, &Project::activeTargetChanged,
|
2018-02-09 16:17:00 +01:00
|
|
|
this, &QmakeProjectManagerPluginPrivate::activeTargetChanged);
|
2011-10-28 10:15:04 +00:00
|
|
|
|
2015-02-23 12:45:53 +01:00
|
|
|
if (ProjectTree::currentProject())
|
|
|
|
|
m_previousStartupProject = qobject_cast<QmakeProject *>(ProjectTree::currentProject());
|
|
|
|
|
else
|
|
|
|
|
m_previousStartupProject = qobject_cast<QmakeProject *>(SessionManager::startupProject());
|
2011-10-28 10:15:04 +00:00
|
|
|
|
2017-05-25 15:11:20 +03:00
|
|
|
if (m_previousStartupProject) {
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_previousStartupProject, &Project::activeTargetChanged,
|
2018-02-09 16:17:00 +01:00
|
|
|
this, &QmakeProjectManagerPluginPrivate::activeTargetChanged);
|
2017-07-13 10:51:15 +02:00
|
|
|
connect(m_previousStartupProject, &Project::parsingFinished,
|
2018-02-09 16:17:00 +01:00
|
|
|
this, &QmakeProjectManagerPluginPrivate::updateActions);
|
2017-05-25 15:11:20 +03:00
|
|
|
}
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
|
activeTargetChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
void QmakeProjectManagerPluginPrivate::activeTargetChanged()
|
2011-10-28 10:15:04 +00:00
|
|
|
{
|
|
|
|
|
if (m_previousTarget)
|
2016-03-10 12:21:30 +01:00
|
|
|
disconnect(m_previousTarget, &Target::activeBuildConfigurationChanged,
|
2018-02-09 16:17:00 +01:00
|
|
|
this, &QmakeProjectManagerPluginPrivate::updateRunQMakeAction);
|
2011-10-28 10:15:04 +00:00
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
m_previousTarget = m_previousStartupProject ? m_previousStartupProject->activeTarget() : nullptr;
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
|
if (m_previousTarget)
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_previousTarget, &Target::activeBuildConfigurationChanged,
|
2018-02-09 16:17:00 +01:00
|
|
|
this, &QmakeProjectManagerPluginPrivate::updateRunQMakeAction);
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
|
updateRunQMakeAction();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
void QmakeProjectManagerPluginPrivate::updateActions()
|
2017-05-25 15:11:20 +03:00
|
|
|
{
|
|
|
|
|
updateRunQMakeAction();
|
|
|
|
|
updateContextActions();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
void QmakeProjectManagerPluginPrivate::updateRunQMakeAction()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-10-28 10:15:04 +00:00
|
|
|
bool enable = true;
|
2015-02-23 12:45:53 +01:00
|
|
|
if (BuildManager::isBuilding(m_previousStartupProject))
|
2011-10-28 10:15:04 +00:00
|
|
|
enable = false;
|
2016-03-29 16:09:16 +02:00
|
|
|
auto pro = qobject_cast<QmakeProject *>(m_previousStartupProject);
|
2015-02-23 12:45:53 +01:00
|
|
|
m_runQMakeAction->setVisible(pro);
|
2011-10-28 10:15:04 +00:00
|
|
|
if (!pro
|
2017-05-25 15:11:20 +03:00
|
|
|
|| !pro->rootProjectNode()
|
2011-10-28 10:15:04 +00:00
|
|
|
|| !pro->activeTarget()
|
|
|
|
|
|| !pro->activeTarget()->activeBuildConfiguration())
|
|
|
|
|
enable = false;
|
|
|
|
|
|
|
|
|
|
m_runQMakeAction->setEnabled(enable);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
void QmakeProjectManagerPluginPrivate::updateContextActions()
|
2011-04-13 13:54:15 +02:00
|
|
|
{
|
2019-04-30 12:58:33 +02:00
|
|
|
const Node *node = ProjectTree::currentNode();
|
2017-02-24 10:02:39 +01:00
|
|
|
Project *project = ProjectTree::currentProject();
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2017-05-31 15:48:45 +02:00
|
|
|
const ContainerNode *containerNode = node ? node->asContainerNode() : nullptr;
|
2018-07-12 23:59:51 +02:00
|
|
|
const auto *proFileNode = dynamic_cast<const QmakeProFileNode *>(containerNode ? containerNode->rootProjectNode() : node);
|
2017-03-27 17:51:19 +02:00
|
|
|
|
|
|
|
|
m_addLibraryActionContextMenu->setEnabled(proFileNode);
|
2019-04-30 12:54:47 +02:00
|
|
|
auto *qmakeProject = qobject_cast<QmakeProject *>(project);
|
2017-02-28 14:13:41 +01:00
|
|
|
QmakeProFileNode *subProjectNode = nullptr;
|
2017-10-14 22:13:54 +02:00
|
|
|
disableBuildFileMenus();
|
2017-02-28 14:13:41 +01:00
|
|
|
if (node) {
|
2017-05-31 15:48:45 +02:00
|
|
|
auto subPriFileNode = dynamic_cast<const QmakePriFileNode *>(node);
|
2017-02-28 14:13:41 +01:00
|
|
|
if (!subPriFileNode)
|
|
|
|
|
subPriFileNode = dynamic_cast<QmakePriFileNode *>(node->parentProjectNode());
|
|
|
|
|
subProjectNode = subPriFileNode ? subPriFileNode->proFileNode() : nullptr;
|
2017-10-14 22:13:54 +02:00
|
|
|
|
|
|
|
|
if (const FileNode *fileNode = node->asFileNode())
|
|
|
|
|
enableBuildFileMenus(fileNode->filePath());
|
2017-02-28 14:13:41 +01:00
|
|
|
}
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2017-05-25 15:11:20 +03:00
|
|
|
bool subProjectActionsVisible = false;
|
|
|
|
|
if (qmakeProject && subProjectNode) {
|
2017-12-20 19:35:21 +01:00
|
|
|
if (ProjectNode *rootNode = qmakeProject->rootProjectNode())
|
2017-05-25 15:11:20 +03:00
|
|
|
subProjectActionsVisible = subProjectNode != rootNode;
|
|
|
|
|
}
|
2012-04-12 15:56:02 +04:00
|
|
|
|
|
|
|
|
QString subProjectName;
|
|
|
|
|
if (subProjectActionsVisible)
|
2017-03-01 14:21:02 +01:00
|
|
|
subProjectName = subProjectNode->displayName();
|
2012-04-12 15:56:02 +04:00
|
|
|
|
|
|
|
|
m_buildSubProjectAction->setParameter(subProjectName);
|
|
|
|
|
m_rebuildSubProjectAction->setParameter(subProjectName);
|
|
|
|
|
m_cleanSubProjectAction->setParameter(subProjectName);
|
2017-03-01 14:21:02 +01:00
|
|
|
m_buildSubProjectContextMenu->setParameter(proFileNode ? proFileNode->displayName() : QString());
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2016-03-29 16:09:16 +02:00
|
|
|
auto buildConfiguration = (qmakeProject && qmakeProject->activeTarget()) ?
|
|
|
|
|
static_cast<QmakeBuildConfiguration *>(qmakeProject->activeTarget()->activeBuildConfiguration()) : nullptr;
|
2013-10-29 17:37:39 +01:00
|
|
|
bool isProjectNode = qmakeProject && proFileNode && buildConfiguration;
|
2013-09-05 14:36:20 +02:00
|
|
|
bool isBuilding = BuildManager::isBuilding(project);
|
2012-05-13 21:54:37 +03:00
|
|
|
bool enabled = subProjectActionsVisible && !isBuilding;
|
2012-05-11 07:29:45 +03:00
|
|
|
|
2012-04-12 15:56:02 +04:00
|
|
|
m_buildSubProjectAction->setVisible(subProjectActionsVisible);
|
|
|
|
|
m_rebuildSubProjectAction->setVisible(subProjectActionsVisible);
|
|
|
|
|
m_cleanSubProjectAction->setVisible(subProjectActionsVisible);
|
2012-05-11 07:29:45 +03:00
|
|
|
m_buildSubProjectContextMenu->setVisible(subProjectActionsVisible && isProjectNode);
|
|
|
|
|
m_subProjectRebuildSeparator->setVisible(subProjectActionsVisible && isProjectNode);
|
|
|
|
|
m_rebuildSubProjectContextMenu->setVisible(subProjectActionsVisible && isProjectNode);
|
|
|
|
|
m_cleanSubProjectContextMenu->setVisible(subProjectActionsVisible && isProjectNode);
|
|
|
|
|
|
|
|
|
|
m_buildSubProjectAction->setEnabled(enabled);
|
|
|
|
|
m_rebuildSubProjectAction->setEnabled(enabled);
|
|
|
|
|
m_cleanSubProjectAction->setEnabled(enabled);
|
|
|
|
|
m_buildSubProjectContextMenu->setEnabled(enabled && isProjectNode);
|
|
|
|
|
m_rebuildSubProjectContextMenu->setEnabled(enabled && isProjectNode);
|
|
|
|
|
m_cleanSubProjectContextMenu->setEnabled(enabled && isProjectNode);
|
2012-05-13 21:54:37 +03:00
|
|
|
m_runQMakeActionContextMenu->setEnabled(isProjectNode && !isBuilding
|
|
|
|
|
&& buildConfiguration->qmakeStep());
|
2011-04-13 13:54:15 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
void QmakeProjectManagerPluginPrivate::buildStateChanged(Project *pro)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2017-02-24 10:02:39 +01:00
|
|
|
if (pro == ProjectTree::currentProject()) {
|
2011-10-28 10:15:04 +00:00
|
|
|
updateRunQMakeAction();
|
2017-02-24 10:02:39 +01:00
|
|
|
updateContextActions();
|
2013-04-30 15:12:48 +02:00
|
|
|
updateBuildFileAction();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
void QmakeProjectManagerPluginPrivate::updateBuildFileAction()
|
2017-10-14 22:13:54 +02:00
|
|
|
{
|
|
|
|
|
disableBuildFileMenus();
|
|
|
|
|
if (IDocument *currentDocument = EditorManager::currentDocument())
|
|
|
|
|
enableBuildFileMenus(currentDocument->filePath());
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 16:17:00 +01:00
|
|
|
void QmakeProjectManagerPluginPrivate::disableBuildFileMenus()
|
2017-10-14 22:13:54 +02:00
|
|
|
{
|
|
|
|
|
m_buildFileAction->setVisible(false);
|
|
|
|
|
m_buildFileAction->setEnabled(false);
|
|
|
|
|
m_buildFileAction->setParameter(QString());
|
|
|
|
|
m_buildFileContextMenu->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
void QmakeProjectManagerPluginPrivate::enableBuildFileMenus(const Utils::FilePath &file)
|
2013-04-30 15:12:48 +02:00
|
|
|
{
|
|
|
|
|
bool visible = false;
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
|
2017-12-04 13:53:38 +01:00
|
|
|
if (Node *node = ProjectTree::nodeForFile(file)) {
|
2017-10-14 22:13:54 +02:00
|
|
|
if (Project *project = SessionManager::projectForFile(file)) {
|
|
|
|
|
if (const FileNode *fileNode = node->asFileNode()) {
|
|
|
|
|
const FileType type = fileNode->fileType();
|
|
|
|
|
visible = qobject_cast<QmakeProject *>(project)
|
|
|
|
|
&& dynamic_cast<QmakePriFileNode *>(node->parentProjectNode())
|
|
|
|
|
&& (type == FileType::Source || type == FileType::Header);
|
|
|
|
|
|
|
|
|
|
enabled = !BuildManager::isBuilding(project);
|
|
|
|
|
m_buildFileAction->setParameter(file.fileName());
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-05-11 07:29:45 +03:00
|
|
|
}
|
2013-04-30 15:12:48 +02:00
|
|
|
m_buildFileAction->setVisible(visible);
|
|
|
|
|
m_buildFileAction->setEnabled(enabled);
|
2017-10-14 22:13:54 +02:00
|
|
|
m_buildFileContextMenu->setEnabled(visible && enabled);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2018-02-09 16:17:00 +01:00
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // QmakeProjectManager
|