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"
|
2010-03-17 17:45:33 +01:00
|
|
|
#include "qmakestep.h"
|
|
|
|
|
#include "makestep.h"
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakebuildconfiguration.h"
|
2013-10-29 18:14:50 +01:00
|
|
|
#include "desktopqmakerunconfiguration.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "wizards/guiappwizard.h"
|
|
|
|
|
#include "wizards/librarywizard.h"
|
2009-12-16 14:19:34 +01:00
|
|
|
#include "wizards/testwizard.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/session.h>
|
|
|
|
|
#include <projectexplorer/projectmanager.h>
|
|
|
|
|
#include <projectexplorer/projecttree.h>
|
|
|
|
|
#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
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
2009-12-09 13:54:46 +01:00
|
|
|
|
2015-05-18 17:08:56 +02:00
|
|
|
using namespace Core;
|
2013-10-16 11:02:37 +02:00
|
|
|
using namespace QmakeProjectManager::Internal;
|
|
|
|
|
using namespace QmakeProjectManager;
|
2013-09-05 11:46:07 +02:00
|
|
|
using namespace ProjectExplorer;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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)
|
2015-05-18 17:08:56 +02:00
|
|
|
const Context projectContext(QmakeProjectManager::Constants::PROJECT_ID);
|
|
|
|
|
Context projecTreeContext(ProjectExplorer::Constants::C_PROJECT_TREE);
|
2010-01-29 21:33:57 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
//create and register objects
|
2014-08-22 17:40:24 +02:00
|
|
|
m_qmakeProjectManager = new QmakeManager;
|
2015-06-16 15:24:42 +02:00
|
|
|
addAutoReleasedObject(m_qmakeProjectManager);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-03-03 18:16:34 +01:00
|
|
|
ProjectManager::registerProjectType<QmakeProject>(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
|
|
|
|
|
|
2013-08-21 12:48:46 +02:00
|
|
|
ProjectExplorer::KitManager::registerKitInformation(new QmakeKitInformation);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2016-05-11 09:27:18 +02:00
|
|
|
IWizardFactory::registerFactoryCreator([] {
|
|
|
|
|
return QList<IWizardFactory *> {
|
|
|
|
|
new SubdirsProjectWizard,
|
|
|
|
|
new GuiAppWizard,
|
|
|
|
|
new LibraryWizard,
|
|
|
|
|
new TestWizard,
|
|
|
|
|
new CustomWidgetWizard,
|
|
|
|
|
new SimpleProjectWizard
|
|
|
|
|
};
|
2015-05-22 17:16:36 +02:00
|
|
|
});
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-30 14:00:49 +02:00
|
|
|
addAutoReleasedObject(new CustomWizardMetaFactory<CustomQmakeProjectWizard>
|
2015-05-18 17:08:56 +02:00
|
|
|
(QLatin1String("qmakeproject"), IWizardFactory::ProjectWizard));
|
2010-03-12 11:20:32 +01:00
|
|
|
|
2009-04-20 16:25:48 +02:00
|
|
|
addAutoReleasedObject(new QMakeStepFactory);
|
|
|
|
|
addAutoReleasedObject(new MakeStepFactory);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
addAutoReleasedObject(new QmakeBuildConfigurationFactory);
|
2013-10-29 18:14:50 +01:00
|
|
|
addAutoReleasedObject(new DesktopQmakeRunConfigurationFactory);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-09-28 15:43:13 +02:00
|
|
|
addAutoReleasedObject(ExternalQtEditor::createDesignerEditor());
|
|
|
|
|
addAutoReleasedObject(ExternalQtEditor::createLinguistEditor());
|
2009-05-19 14:54:52 +02:00
|
|
|
|
2014-09-30 13:08:05 +02:00
|
|
|
addAutoReleasedObject(new ProFileEditorFactory);
|
2014-06-26 00:27:27 +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
|
|
|
|
2012-04-26 19:28:59 +02:00
|
|
|
m_buildSubProjectContextMenu = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""),
|
|
|
|
|
Utils::ParameterAction::AlwaysEnabled/*handled manually*/,
|
|
|
|
|
this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(m_buildSubProjectContextMenu, Constants::BUILDSUBDIRCONTEXTMENU, projectContext);
|
|
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2012-04-26 19:28:59 +02:00
|
|
|
command->setDescription(m_buildSubProjectContextMenu->text());
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_buildSubProjectContextMenu, &QAction::triggered, m_qmakeProjectManager, &QmakeManager::buildSubDirContextMenu);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-04-26 19:28:59 +02:00
|
|
|
m_runQMakeActionContextMenu = new QAction(tr("Run qmake"), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, projectContext);
|
|
|
|
|
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);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_runQMakeActionContextMenu, &QAction::triggered,
|
|
|
|
|
m_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,
|
|
|
|
|
&m_subProjectRebuildSeparator);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
2010-01-13 18:00:02 +01:00
|
|
|
|
2012-04-26 19:28:59 +02:00
|
|
|
m_rebuildSubProjectContextMenu = new QAction(tr("Rebuild"), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(
|
2012-05-24 13:49:06 +02:00
|
|
|
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);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_rebuildSubProjectContextMenu, &QAction::triggered,
|
|
|
|
|
m_qmakeProjectManager, &QmakeManager::rebuildSubDirContextMenu);
|
2010-04-30 11:50:04 +02:00
|
|
|
|
2012-04-26 19:28:59 +02:00
|
|
|
m_cleanSubProjectContextMenu = new QAction(tr("Clean"), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(
|
2012-05-24 13:49:06 +02:00
|
|
|
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);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_cleanSubProjectContextMenu, &QAction::triggered,
|
|
|
|
|
m_qmakeProjectManager, &QmakeManager::cleanSubDirContextMenu);
|
2010-04-30 11:50:04 +02:00
|
|
|
|
2012-05-14 22:46:23 +03:00
|
|
|
m_buildFileContextMenu = new QAction(tr("Build"), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(m_buildFileContextMenu, Constants::BUILDFILECONTEXTMENU, projectContext);
|
|
|
|
|
command->setAttribute(Command::CA_Hide);
|
2012-05-14 22:46:23 +03:00
|
|
|
mfile->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_buildFileContextMenu, &QAction::triggered,
|
|
|
|
|
m_qmakeProjectManager, &QmakeManager::buildFileContextMenu);
|
2012-05-14 22:46:23 +03:00
|
|
|
|
2012-04-12 15:56:02 +04:00
|
|
|
m_buildSubProjectAction = new Utils::ParameterAction(tr("Build Subproject"), tr("Build Subproject \"%1\""),
|
2012-05-11 07:29:45 +03:00
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(m_buildSubProjectAction, Constants::BUILDSUBDIR, projectContext);
|
|
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2012-04-12 15:56:02 +04:00
|
|
|
command->setDescription(m_buildSubProjectAction->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_buildSubProjectAction, &QAction::triggered,
|
|
|
|
|
m_qmakeProjectManager, &QmakeManager::buildSubDirContextMenu);
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2012-04-26 19:28:59 +02:00
|
|
|
m_runQMakeAction = new QAction(tr("Run qmake"), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
const Context globalcontext(Core::Constants::C_GLOBAL);
|
|
|
|
|
command = ActionManager::registerAction(m_runQMakeAction, Constants::RUNQMAKE, globalcontext);
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_runQMakeAction, &QAction::triggered, m_qmakeProjectManager, &QmakeManager::runQMake);
|
2012-04-26 19:28:59 +02:00
|
|
|
|
2012-04-12 15:56:02 +04:00
|
|
|
m_rebuildSubProjectAction = new Utils::ParameterAction(tr("Rebuild Subproject"), tr("Rebuild Subproject \"%1\""),
|
2012-05-11 07:29:45 +03:00
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(m_rebuildSubProjectAction, Constants::REBUILDSUBDIR, projectContext);
|
|
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2012-04-12 15:56:02 +04:00
|
|
|
command->setDescription(m_rebuildSubProjectAction->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_REBUILD);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_rebuildSubProjectAction, &QAction::triggered,
|
|
|
|
|
m_qmakeProjectManager, &QmakeManager::rebuildSubDirContextMenu);
|
2012-04-12 15:56:02 +04:00
|
|
|
|
|
|
|
|
m_cleanSubProjectAction = new Utils::ParameterAction(tr("Clean Subproject"), tr("Clean Subproject \"%1\""),
|
2012-05-11 07:29:45 +03:00
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(m_cleanSubProjectAction, Constants::CLEANSUBDIR, projectContext);
|
|
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2012-04-12 15:56:02 +04:00
|
|
|
command->setDescription(m_cleanSubProjectAction->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_CLEAN);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_cleanSubProjectAction, &QAction::triggered,
|
|
|
|
|
m_qmakeProjectManager, &QmakeManager::cleanSubDirContextMenu);
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2012-05-04 16:25:41 +03:00
|
|
|
m_buildFileAction = new Utils::ParameterAction(tr("Build File"), tr("Build File \"%1\""),
|
2012-05-11 13:31:06 +03:00
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2017-01-30 15:19:57 +01:00
|
|
|
command = ActionManager::registerAction(m_buildFileAction, Constants::BUILDFILE, projectContext);
|
2015-05-18 17:08:56 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2012-05-04 16:25:41 +03:00
|
|
|
command->setDescription(m_buildFileAction->text());
|
|
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+B")));
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_buildFileAction, &QAction::triggered, m_qmakeProjectManager, &QmakeManager::buildFile);
|
2012-05-04 16:25:41 +03:00
|
|
|
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(BuildManager::instance(), &BuildManager::buildStateChanged,
|
|
|
|
|
this, &QmakeProjectManagerPlugin::buildStateChanged);
|
2015-02-23 12:45:53 +01:00
|
|
|
connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
|
|
|
|
|
this, &QmakeProjectManagerPlugin::projectChanged);
|
|
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
|
|
|
|
|
this, &QmakeProjectManagerPlugin::projectChanged);
|
|
|
|
|
|
2014-11-19 17:58:33 +01:00
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
|
|
|
|
|
this, &QmakeProjectManagerPlugin::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
|
|
|
|
2011-04-13 13:54:15 +02:00
|
|
|
m_addLibraryAction = new QAction(tr("Add Library..."), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(m_addLibraryAction,
|
2010-08-16 18:23:30 +02:00
|
|
|
Constants::ADDLIBRARY, proFileEditorContext);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_addLibraryAction, &QAction::triggered, m_qmakeProjectManager, &QmakeManager::addLibrary);
|
2011-04-13 13:54:15 +02:00
|
|
|
contextMenu->addAction(command);
|
|
|
|
|
|
|
|
|
|
m_addLibraryActionContextMenu = new QAction(tr("Add Library..."), this);
|
2015-05-18 17:08:56 +02:00
|
|
|
command = ActionManager::registerAction(m_addLibraryActionContextMenu,
|
2011-04-13 13:54:15 +02:00
|
|
|
Constants::ADDLIBRARY, projecTreeContext);
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_addLibraryActionContextMenu, &QAction::triggered,
|
|
|
|
|
m_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,
|
|
|
|
|
this, &QmakeProjectManagerPlugin::updateBuildFileAction);
|
2013-04-30 15:12:48 +02:00
|
|
|
|
2017-05-25 15:11:20 +03:00
|
|
|
updateActions();
|
2016-03-10 12:21:41 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::extensionsInitialized()
|
2013-07-11 16:24:51 +02:00
|
|
|
{ }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-23 12:45:53 +01:00
|
|
|
void QmakeProjectManagerPlugin::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,
|
|
|
|
|
this, &QmakeProjectManagerPlugin::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,
|
2017-07-13 10:51:15 +02:00
|
|
|
this, &QmakeProjectManagerPlugin::activeTargetChanged);
|
|
|
|
|
connect(m_previousStartupProject, &Project::parsingFinished,
|
2017-05-25 15:11:20 +03:00
|
|
|
this, &QmakeProjectManagerPlugin::updateActions);
|
|
|
|
|
}
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
|
activeTargetChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::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,
|
|
|
|
|
this, &QmakeProjectManagerPlugin::updateRunQMakeAction);
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
|
m_previousTarget = m_previousStartupProject ? m_previousStartupProject->activeTarget() : 0;
|
|
|
|
|
|
|
|
|
|
if (m_previousTarget)
|
2016-03-10 12:21:30 +01:00
|
|
|
connect(m_previousTarget, &Target::activeBuildConfigurationChanged,
|
|
|
|
|
this, &QmakeProjectManagerPlugin::updateRunQMakeAction);
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
|
updateRunQMakeAction();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-25 15:11:20 +03:00
|
|
|
void QmakeProjectManagerPlugin::updateActions()
|
|
|
|
|
{
|
|
|
|
|
updateRunQMakeAction();
|
|
|
|
|
updateContextActions();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::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
|
|
|
}
|
|
|
|
|
|
2017-02-24 10:02:39 +01:00
|
|
|
void QmakeProjectManagerPlugin::updateContextActions()
|
2011-04-13 13:54:15 +02:00
|
|
|
{
|
2017-05-31 15:48:45 +02:00
|
|
|
const Node *node = ProjectTree::findCurrentNode();
|
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;
|
|
|
|
|
const QmakeProFileNode *proFileNode = dynamic_cast<const QmakeProFileNode *>(containerNode ? containerNode->rootProjectNode() : node);
|
2017-03-27 17:51:19 +02:00
|
|
|
|
|
|
|
|
m_addLibraryActionContextMenu->setEnabled(proFileNode);
|
2017-02-28 14:13:41 +01:00
|
|
|
QmakeProject *qmakeProject = qobject_cast<QmakeProject *>(QmakeManager::contextProject());
|
|
|
|
|
QmakeProFileNode *subProjectNode = nullptr;
|
|
|
|
|
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-05-31 15:48:45 +02:00
|
|
|
const FileNode *fileNode = node ? node->asFileNode() : nullptr;
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2017-02-24 17:10:28 +01:00
|
|
|
bool buildFilePossible = subProjectNode && fileNode && (fileNode->fileType() == FileType::Source);
|
2017-05-25 15:11:20 +03:00
|
|
|
bool subProjectActionsVisible = false;
|
|
|
|
|
if (qmakeProject && subProjectNode) {
|
|
|
|
|
if (QmakeProFileNode *rootNode = qmakeProject->rootProjectNode())
|
|
|
|
|
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());
|
2015-10-29 17:53:47 +01:00
|
|
|
m_buildFileAction->setParameter(buildFilePossible ? fileNode->filePath().fileName() : 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);
|
2017-03-14 23:04:23 +02:00
|
|
|
m_buildFileAction->setVisible(buildFilePossible);
|
2012-05-11 07:29:45 +03:00
|
|
|
|
|
|
|
|
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());
|
2012-05-11 13:31:06 +03:00
|
|
|
m_buildFileAction->setEnabled(buildFilePossible && !isBuilding);
|
2012-05-14 22:46:23 +03:00
|
|
|
m_buildFileContextMenu->setEnabled(buildFilePossible && !isBuilding);
|
2011-04-13 13:54:15 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::buildStateChanged(ProjectExplorer::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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::updateBuildFileAction()
|
2013-04-30 15:12:48 +02:00
|
|
|
{
|
|
|
|
|
bool visible = false;
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
|
2015-05-18 17:08:56 +02:00
|
|
|
if (IDocument *currentDocument= EditorManager::currentDocument()) {
|
2015-02-02 00:37:38 +02:00
|
|
|
Utils::FileName file = currentDocument->filePath();
|
2013-09-05 11:46:07 +02:00
|
|
|
Node *node = SessionManager::nodeForFile(file);
|
|
|
|
|
Project *project = SessionManager::projectForFile(file);
|
2015-02-02 00:37:38 +02:00
|
|
|
m_buildFileAction->setParameter(file.fileName());
|
2013-10-29 14:22:31 +01:00
|
|
|
visible = qobject_cast<QmakeProject *>(project)
|
2013-05-28 18:21:10 +02:00
|
|
|
&& node
|
2016-11-09 13:39:59 +01:00
|
|
|
&& dynamic_cast<QmakePriFileNode *>(node->parentProjectNode());
|
2013-04-30 15:12:48 +02:00
|
|
|
|
2013-09-05 14:36:20 +02:00
|
|
|
enabled = !BuildManager::isBuilding(project);
|
2012-05-11 07:29:45 +03:00
|
|
|
}
|
2013-04-30 15:12:48 +02:00
|
|
|
m_buildFileAction->setVisible(visible);
|
|
|
|
|
m_buildFileAction->setEnabled(enabled);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|