2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
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/consoleappwizard.h"
|
|
|
|
|
#include "wizards/guiappwizard.h"
|
|
|
|
|
#include "wizards/librarywizard.h"
|
2009-12-16 14:19:34 +01:00
|
|
|
#include "wizards/testwizard.h"
|
2010-11-24 15:18:50 +01:00
|
|
|
#include "wizards/subdirsprojectwizard.h"
|
2011-02-06 16:23:02 +01:00
|
|
|
#include "wizards/qtquickappwizard.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>
|
2009-01-14 15:08:46 +01:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2009-09-25 11:35:44 +02:00
|
|
|
#include <projectexplorer/session.h>
|
2014-11-19 17:58:33 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.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>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <texteditor/texteditoractionhandler.h>
|
2010-05-25 16:16:04 +02:00
|
|
|
#include <texteditor/texteditorconstants.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2015-02-04 09:32:46 +01:00
|
|
|
#include <utils/mimetypes/mimedatabase.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
|
|
|
|
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
|
|
|
QmakeProjectManagerPlugin::QmakeProjectManagerPlugin()
|
2011-10-28 10:15:04 +00:00
|
|
|
: m_previousStartupProject(0), m_previousTarget(0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
QmakeProjectManagerPlugin::~QmakeProjectManagerPlugin()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
//removeObject(m_embeddedPropertiesPage);
|
|
|
|
|
//delete m_embeddedPropertiesPage;
|
|
|
|
|
|
2013-10-29 17:37:39 +01:00
|
|
|
removeObject(m_qmakeProjectManager);
|
|
|
|
|
delete m_qmakeProjectManager;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-01-20 15:31:33 +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)
|
2013-10-16 11:02:37 +02:00
|
|
|
const Core::Context projectContext(QmakeProjectManager::Constants::PROJECT_ID);
|
2011-04-13 13:54:15 +02:00
|
|
|
Core::Context projecTreeContext(ProjectExplorer::Constants::C_PROJECT_TREE);
|
2010-01-29 21:33:57 +01:00
|
|
|
|
2015-02-04 09:32:46 +01:00
|
|
|
Utils::MimeDatabase::addMimeTypes(QLatin1String(":qmakeprojectmanager/QmakeProjectManager.mimetypes.xml"));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//create and register objects
|
2014-08-22 17:40:24 +02:00
|
|
|
m_qmakeProjectManager = new QmakeManager;
|
2013-10-29 17:37:39 +01:00
|
|
|
addObject(m_qmakeProjectManager);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-08-21 12:48:46 +02:00
|
|
|
ProjectExplorer::KitManager::registerKitInformation(new QmakeKitInformation);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2010-11-24 15:18:50 +01:00
|
|
|
addAutoReleasedObject(new SubdirsProjectWizard);
|
|
|
|
|
addAutoReleasedObject(new GuiAppWizard);
|
|
|
|
|
addAutoReleasedObject(new ConsoleAppWizard);
|
2013-10-24 08:21:12 +02:00
|
|
|
addAutoReleasedObject(new QtQuickAppWizard);
|
2010-11-24 15:18:50 +01:00
|
|
|
addAutoReleasedObject(new LibraryWizard);
|
2009-12-16 14:19:34 +01:00
|
|
|
addAutoReleasedObject(new TestWizard);
|
2009-06-29 14:47:04 +02:00
|
|
|
addAutoReleasedObject(new CustomWidgetWizard);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-30 14:00:49 +02:00
|
|
|
addAutoReleasedObject(new CustomWizardMetaFactory<CustomQmakeProjectWizard>
|
2014-05-02 17:38:42 +02:00
|
|
|
(QLatin1String("qmakeproject"), Core::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
|
|
|
|
2012-08-23 15:53:58 +02:00
|
|
|
if (Utils::HostOsInfo::isMacHost())
|
|
|
|
|
addAutoReleasedObject(new MacDesignerExternalEditor);
|
|
|
|
|
else
|
|
|
|
|
addAutoReleasedObject(new DesignerExternalEditor);
|
2009-05-19 14:54:52 +02:00
|
|
|
addAutoReleasedObject(new LinguistExternalEditor);
|
|
|
|
|
|
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
|
2009-01-14 12:39:59 +01:00
|
|
|
Core::ActionContainer *mbuild =
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT);
|
2009-01-14 12:39:59 +01:00
|
|
|
Core::ActionContainer *mproject =
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT);
|
2010-01-13 18:00:02 +01:00
|
|
|
Core::ActionContainer *msubproject =
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
|
2012-05-14 22:46:23 +03:00
|
|
|
Core::ActionContainer *mfile =
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_FILECONTEXT);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//register actions
|
2009-01-14 13:17:53 +01:00
|
|
|
Core::Command *command;
|
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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_buildSubProjectContextMenu, Constants::BUILDSUBDIRCONTEXTMENU, projectContext);
|
2011-02-23 15:52:04 +01:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
2012-04-26 19:28:59 +02:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
command->setDescription(m_buildSubProjectContextMenu->text());
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_buildSubProjectContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, projectContext);
|
2009-09-16 18:37:36 +02:00
|
|
|
command->setAttribute(Core::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);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_runQMakeActionContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(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);
|
2010-01-13 18:00:02 +01:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
|
2012-04-26 19:28:59 +02:00
|
|
|
m_rebuildSubProjectContextMenu = new QAction(tr("Rebuild"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(
|
|
|
|
|
m_rebuildSubProjectContextMenu, Constants::REBUILDSUBDIRCONTEXTMENU, projectContext);
|
2010-04-30 11:50:04 +02:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_rebuildSubProjectContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(rebuildSubDirContextMenu()));
|
2010-04-30 11:50:04 +02:00
|
|
|
|
2012-04-26 19:28:59 +02:00
|
|
|
m_cleanSubProjectContextMenu = new QAction(tr("Clean"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(
|
|
|
|
|
m_cleanSubProjectContextMenu, Constants::CLEANSUBDIRCONTEXTMENU, projectContext);
|
2010-04-30 11:50:04 +02:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_cleanSubProjectContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(cleanSubDirContextMenu()));
|
2010-04-30 11:50:04 +02:00
|
|
|
|
2012-05-14 22:46:23 +03:00
|
|
|
m_buildFileContextMenu = new QAction(tr("Build"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_buildFileContextMenu, Constants::BUILDFILECONTEXTMENU, projectContext);
|
2012-05-14 22:46:23 +03:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
mfile->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_buildFileContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_buildSubProjectAction, Constants::BUILDSUBDIR, projectContext);
|
2012-04-26 13:30:58 +04:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
2012-04-12 15:56:02 +04:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
command->setDescription(m_buildSubProjectAction->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_buildSubProjectAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_runQMakeAction, Constants::RUNQMAKE, projectContext);
|
2012-04-26 19:28:59 +02:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_runQMakeAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_rebuildSubProjectAction, Constants::REBUILDSUBDIR, projectContext);
|
2012-04-26 13:30:58 +04:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
2012-04-12 15:56:02 +04:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
command->setDescription(m_rebuildSubProjectAction->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_REBUILD);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_rebuildSubProjectAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_cleanSubProjectAction, Constants::CLEANSUBDIR, projectContext);
|
2012-04-26 13:30:58 +04:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
2012-04-12 15:56:02 +04:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
command->setDescription(m_cleanSubProjectAction->text());
|
2012-04-26 19:28:59 +02:00
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_CLEAN);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_cleanSubProjectAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(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);
|
2015-02-19 11:35:47 +01:00
|
|
|
command = Core::ActionManager::registerAction(m_buildFileAction, Constants::BUILDFILE);
|
2012-05-04 16:25:41 +03:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
command->setDescription(m_buildFileAction->text());
|
|
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+B")));
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2013-10-29 17:37:39 +01:00
|
|
|
connect(m_buildFileAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(buildFile()));
|
2012-05-04 16:25:41 +03:00
|
|
|
|
2013-09-05 14:36:20 +02:00
|
|
|
connect(BuildManager::instance(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)),
|
2012-03-05 22:30:59 +01:00
|
|
|
this, SLOT(buildStateChanged(ProjectExplorer::Project*)));
|
2013-09-05 11:46:07 +02:00
|
|
|
connect(SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
2011-10-28 10:15:04 +00:00
|
|
|
this, SLOT(startupProjectChanged()));
|
2014-11-19 17:58:33 +01:00
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
|
|
|
|
|
this, &QmakeProjectManagerPlugin::updateContextActions);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
Core::ActionContainer *contextMenu = Core::ActionManager::createMenu(QmakeProjectManager::Constants::M_CONTEXT);
|
2010-05-25 16:16:04 +02:00
|
|
|
|
2014-09-02 12:25:20 +02:00
|
|
|
Core::Context proFileEditorContext = Core::Context(QmakeProjectManager::Constants::PROFILE_EDITOR_ID);
|
2010-08-16 18:23:30 +02:00
|
|
|
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_addLibraryAction,
|
2010-08-16 18:23:30 +02:00
|
|
|
Constants::ADDLIBRARY, proFileEditorContext);
|
2011-04-13 13:54:15 +02:00
|
|
|
connect(m_addLibraryAction, SIGNAL(triggered()),
|
2013-10-29 17:37:39 +01:00
|
|
|
m_qmakeProjectManager, SLOT(addLibrary()));
|
2011-04-13 13:54:15 +02:00
|
|
|
contextMenu->addAction(command);
|
|
|
|
|
|
|
|
|
|
m_addLibraryActionContextMenu = new QAction(tr("Add Library..."), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_addLibraryActionContextMenu,
|
2011-04-13 13:54:15 +02:00
|
|
|
Constants::ADDLIBRARY, projecTreeContext);
|
|
|
|
|
connect(m_addLibraryActionContextMenu, SIGNAL(triggered()),
|
2013-10-29 17:37:39 +01:00
|
|
|
m_qmakeProjectManager, SLOT(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
|
|
|
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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
|
|
|
|
2013-04-30 15:12:48 +02:00
|
|
|
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
|
|
|
|
this, SLOT(updateBuildFileAction()));
|
|
|
|
|
|
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
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::startupProjectChanged()
|
2011-10-28 10:15:04 +00:00
|
|
|
{
|
|
|
|
|
if (m_previousStartupProject)
|
|
|
|
|
disconnect(m_previousStartupProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(activeTargetChanged()));
|
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
m_previousStartupProject = qobject_cast<QmakeProject *>(SessionManager::startupProject());
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
|
if (m_previousStartupProject)
|
|
|
|
|
connect(m_previousStartupProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(activeTargetChanged()));
|
|
|
|
|
|
|
|
|
|
activeTargetChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::activeTargetChanged()
|
2011-10-28 10:15:04 +00:00
|
|
|
{
|
|
|
|
|
if (m_previousTarget)
|
|
|
|
|
disconnect(m_previousTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(updateRunQMakeAction()));
|
|
|
|
|
|
|
|
|
|
m_previousTarget = m_previousStartupProject ? m_previousStartupProject->activeTarget() : 0;
|
|
|
|
|
|
|
|
|
|
if (m_previousTarget)
|
|
|
|
|
connect(m_previousTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(updateRunQMakeAction()));
|
|
|
|
|
|
|
|
|
|
updateRunQMakeAction();
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2014-11-19 17:58:33 +01:00
|
|
|
if (BuildManager::isBuilding(ProjectTree::currentProject()))
|
2011-10-28 10:15:04 +00:00
|
|
|
enable = false;
|
2014-11-19 17:58:33 +01:00
|
|
|
QmakeProject *pro = qobject_cast<QmakeProject *>(ProjectTree::currentProject());
|
2015-02-18 12:29:33 +01:00
|
|
|
if (!pro)
|
|
|
|
|
pro = qobject_cast<QmakeProject *>(SessionManager::startupProject());
|
2011-10-28 10:15:04 +00:00
|
|
|
if (!pro
|
|
|
|
|
|| !pro->activeTarget()
|
|
|
|
|
|| !pro->activeTarget()->activeBuildConfiguration())
|
|
|
|
|
enable = false;
|
|
|
|
|
|
|
|
|
|
m_runQMakeAction->setEnabled(enable);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::updateContextActions(ProjectExplorer::Node *node, ProjectExplorer::Project *project)
|
2011-04-13 13:54:15 +02:00
|
|
|
{
|
2015-01-09 15:50:06 +01:00
|
|
|
m_addLibraryActionContextMenu->setEnabled(dynamic_cast<QmakeProFileNode *>(node));
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2015-01-09 15:50:06 +01:00
|
|
|
QmakeProFileNode *proFileNode = dynamic_cast<QmakeProFileNode *>(node);
|
2013-10-29 17:37:39 +01:00
|
|
|
QmakeProject *qmakeProject = qobject_cast<QmakeProject *>(project);
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProFileNode *subProjectNode = 0;
|
2013-10-28 19:42:56 +02:00
|
|
|
if (node) {
|
2015-01-09 15:50:06 +01:00
|
|
|
if (QmakePriFileNode *subPriFileNode = dynamic_cast<QmakePriFileNode *>(node->projectNode()))
|
2013-10-28 19:42:56 +02:00
|
|
|
subProjectNode = subPriFileNode->proFileNode();
|
|
|
|
|
}
|
2015-02-18 13:10:40 +01:00
|
|
|
ProjectExplorer::FileNode *fileNode = node ? node->asFileNode() : 0;
|
2012-05-04 16:25:41 +03:00
|
|
|
bool buildFilePossible = subProjectNode && fileNode
|
2012-05-14 22:58:34 +03:00
|
|
|
&& (fileNode->fileType() == ProjectExplorer::SourceType);
|
2012-04-26 13:18:10 +04:00
|
|
|
|
2013-10-29 17:37:39 +01:00
|
|
|
m_qmakeProjectManager->setContextNode(subProjectNode);
|
|
|
|
|
m_qmakeProjectManager->setContextProject(qmakeProject);
|
|
|
|
|
m_qmakeProjectManager->setContextFile(buildFilePossible ? fileNode : 0);
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2013-10-29 17:37:39 +01:00
|
|
|
bool subProjectActionsVisible = qmakeProject && subProjectNode && (subProjectNode != qmakeProject->rootProjectNode());
|
2012-04-12 15:56:02 +04:00
|
|
|
|
|
|
|
|
QString subProjectName;
|
|
|
|
|
if (subProjectActionsVisible)
|
2012-04-26 13:18:10 +04:00
|
|
|
subProjectName = subProjectNode->displayName();
|
2012-04-12 15:56:02 +04:00
|
|
|
|
|
|
|
|
m_buildSubProjectAction->setParameter(subProjectName);
|
|
|
|
|
m_rebuildSubProjectAction->setParameter(subProjectName);
|
|
|
|
|
m_cleanSubProjectAction->setParameter(subProjectName);
|
2012-04-26 19:28:59 +02:00
|
|
|
m_buildSubProjectContextMenu->setParameter(subProjectName);
|
2015-02-02 00:37:38 +02:00
|
|
|
m_buildFileAction->setParameter(buildFilePossible ? fileNode->path().fileName() : QString());
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2013-10-29 17:37:39 +01:00
|
|
|
QmakeBuildConfiguration *buildConfiguration = (qmakeProject && qmakeProject->activeTarget()) ?
|
|
|
|
|
static_cast<QmakeBuildConfiguration *>(qmakeProject->activeTarget()->activeBuildConfiguration()) : 0;
|
|
|
|
|
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);
|
2012-05-13 21:54:37 +03:00
|
|
|
m_runQMakeActionContextMenu->setVisible(isProjectNode && buildConfiguration->qmakeStep());
|
2012-05-04 16:25:41 +03:00
|
|
|
m_buildFileAction->setVisible(buildFilePossible);
|
2012-05-14 22:46:23 +03:00
|
|
|
m_buildFileContextMenu->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
|
|
|
{
|
2014-11-19 17:58:33 +01:00
|
|
|
ProjectExplorer::Project *currentProject = ProjectTree::currentProject();
|
2012-05-11 07:29:45 +03:00
|
|
|
if (pro == currentProject) {
|
2011-10-28 10:15:04 +00:00
|
|
|
updateRunQMakeAction();
|
2014-11-19 17:58:33 +01:00
|
|
|
updateContextActions(ProjectTree::currentNode(), pro);
|
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;
|
|
|
|
|
|
2013-07-09 11:52:44 +02:00
|
|
|
if (Core::IDocument *currentDocument= Core::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
|
2015-01-09 15:50:06 +01:00
|
|
|
&& dynamic_cast<QmakePriFileNode *>(node->projectNode());
|
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
|
|
|
}
|