2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/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
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt 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
|
|
|
|
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"
|
2009-05-07 20:31:12 +02:00
|
|
|
#include "wizards/emptyprojectwizard.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"
|
2011-02-05 23:08:59 +01:00
|
|
|
#include "wizards/html5appwizard.h"
|
2009-06-29 14:47:04 +02:00
|
|
|
#include "customwidgetwizard/customwidgetwizard.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "profileeditorfactory.h"
|
2011-11-10 11:55:05 +01:00
|
|
|
#include "profilehoverhandler.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"
|
2011-04-15 16:19:23 +02:00
|
|
|
#include "profilecompletionassist.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "qmakekitinformation.h"
|
2013-08-14 13:52:13 +02:00
|
|
|
#include "profilehighlighterfactory.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>
|
2009-01-14 15:08:46 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/mimedatabase.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>
|
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>
|
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;
|
|
|
|
|
|
|
|
|
|
removeObject(m_proFileEditorFactory);
|
|
|
|
|
delete m_proFileEditorFactory;
|
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)
|
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
|
|
|
|
2013-10-29 16:19:24 +01:00
|
|
|
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":qmakeprojectmanager/QmakeProjectManager.mimetypes.xml"), errorMessage))
|
2008-12-02 12:01:29 +01:00
|
|
|
return false;
|
|
|
|
|
|
2014-05-02 17:02:28 +02:00
|
|
|
m_projectExplorer = ProjectExplorerPlugin::instance();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//create and register objects
|
2013-10-29 17:37:39 +01:00
|
|
|
m_qmakeProjectManager = new QmakeManager(this);
|
|
|
|
|
addObject(m_qmakeProjectManager);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-12-10 17:13:21 +01:00
|
|
|
m_proFileEditorFactory = new ProFileEditorFactory(m_qmakeProjectManager);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-08-21 12:48:46 +02:00
|
|
|
ProjectExplorer::KitManager::registerKitInformation(new QmakeKitInformation);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
addObject(m_proFileEditorFactory);
|
|
|
|
|
|
2009-05-07 20:31:12 +02:00
|
|
|
addAutoReleasedObject(new EmptyProjectWizard);
|
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);
|
2011-02-05 23:08:59 +01:00
|
|
|
addAutoReleasedObject(new Html5AppWizard);
|
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-02-13 16:17:23 +01:00
|
|
|
addAutoReleasedObject(new CustomWizardFactory<CustomQmakeProjectWizard>
|
|
|
|
|
(QLatin1String("qmakeproject"), Core::IWizard::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);
|
|
|
|
|
|
2011-04-15 16:19:23 +02:00
|
|
|
addAutoReleasedObject(new ProFileCompletionAssistProvider);
|
2011-11-10 11:55:05 +01:00
|
|
|
addAutoReleasedObject(new ProFileHoverHandler(this));
|
2013-08-14 13:52:13 +02:00
|
|
|
addAutoReleasedObject(new ProFileHighlighterFactory);
|
2010-11-08 14:01:50 +01: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
|
|
|
|
2013-04-30 15:12:48 +02:00
|
|
|
const Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
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);
|
2013-04-30 15:12:48 +02:00
|
|
|
command = Core::ActionManager::registerAction(m_buildFileAction, Constants::BUILDFILE, globalcontext);
|
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()));
|
2011-04-13 13:54:15 +02:00
|
|
|
connect(m_projectExplorer, SIGNAL(currentNodeChanged(ProjectExplorer::Node*,ProjectExplorer::Project*)),
|
2012-05-11 07:29:45 +03:00
|
|
|
this, SLOT(updateContextActions(ProjectExplorer::Node*,ProjectExplorer::Project*)));
|
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
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
Core::Context proFileEditorContext = Core::Context(QmakeProjectManager::Constants::C_PROFILEEDITOR);
|
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;
|
2013-09-05 14:36:20 +02:00
|
|
|
if (BuildManager::isBuilding(m_projectExplorer->currentProject()))
|
2011-10-28 10:15:04 +00:00
|
|
|
enable = false;
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject *pro = qobject_cast<QmakeProject *>(m_projectExplorer->currentProject());
|
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
|
|
|
{
|
2013-10-29 14:22:31 +01:00
|
|
|
m_addLibraryActionContextMenu->setEnabled(qobject_cast<QmakeProFileNode *>(node));
|
2012-04-12 15:56:02 +04:00
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProFileNode *proFileNode = qobject_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) {
|
2013-10-29 14:22:31 +01:00
|
|
|
if (QmakePriFileNode *subPriFileNode = qobject_cast<QmakePriFileNode *>(node->projectNode()))
|
2013-10-28 19:42:56 +02:00
|
|
|
subProjectNode = subPriFileNode->proFileNode();
|
|
|
|
|
}
|
2012-05-04 16:25:41 +03:00
|
|
|
ProjectExplorer::FileNode *fileNode = qobject_cast<ProjectExplorer::FileNode *>(node);
|
|
|
|
|
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);
|
2012-05-11 13:31:06 +03:00
|
|
|
m_buildFileAction->setParameter(buildFilePossible ? QFileInfo(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
|
|
|
{
|
|
|
|
|
ProjectExplorer::Project *currentProject = m_projectExplorer->currentProject();
|
2012-05-11 07:29:45 +03:00
|
|
|
if (pro == currentProject) {
|
2011-10-28 10:15:04 +00:00
|
|
|
updateRunQMakeAction();
|
2012-05-11 07:29:45 +03:00
|
|
|
updateContextActions(m_projectExplorer->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()) {
|
2013-09-05 11:46:07 +02:00
|
|
|
QString file = currentDocument->filePath();
|
|
|
|
|
Node *node = SessionManager::nodeForFile(file);
|
|
|
|
|
Project *project = SessionManager::projectForFile(file);
|
2013-05-28 18:13:46 +02:00
|
|
|
m_buildFileAction->setParameter(QFileInfo(file).fileName());
|
2013-10-29 14:22:31 +01:00
|
|
|
visible = qobject_cast<QmakeProject *>(project)
|
2013-05-28 18:21:10 +02:00
|
|
|
&& node
|
2013-10-29 14:22:31 +01:00
|
|
|
&& qobject_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
|
|
|
}
|
|
|
|
|
|
2013-10-29 16:05:14 +01:00
|
|
|
Q_EXPORT_PLUGIN(QmakeProjectManagerPlugin)
|