Newer
Older
/**************************************************************************
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
** GNU Lesser General Public License Usage
** 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.
** If you are unsure which license is appropriate for your use, please
**************************************************************************/
#include "qt4projectmanager.h"
#include "wizards/consoleappwizard.h"
#include "wizards/guiappwizard.h"
#include "wizards/librarywizard.h"
#include "wizards/emptyprojectwizard.h"
#include "customwidgetwizard/customwidgetwizard.h"
#include "profileeditorfactory.h"
#include "qt4projectmanagerconstants.h"
#include "qt4project.h"
#include "qt4runconfiguration.h"
#include "profilereader.h"
#include "qtversionmanager.h"
#include "qtoptionspage.h"
#include "externaleditors.h"
#include "gettingstartedwelcomepage.h"
#include "gettingstartedwelcomepagewidget.h"

hjk
committed
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectnodes.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <texteditor/texteditoractionhandler.h>
#ifdef WITH_TESTS
using namespace Qt4ProjectManager::Internal;
using namespace Qt4ProjectManager;
using ProjectExplorer::Project;
Qt4ProjectManagerPlugin::~Qt4ProjectManagerPlugin()
{
//removeObject(m_embeddedPropertiesPage);
//delete m_embeddedPropertiesPage;
removeObject(m_proFileEditorFactory);
delete m_proFileEditorFactory;
removeObject(m_qt4ProjectManager);
delete m_qt4ProjectManager;
removeObject(m_welcomePage);
delete m_welcomePage;

hjk
committed
bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage)

hjk
committed
Core::ICore *core = Core::ICore::instance();
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":qt4projectmanager/Qt4ProjectManager.mimetypes.xml"), errorMessage))
m_projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
Core::ActionManager *am = core->actionManager();
QtVersionManager *mgr = new QtVersionManager();
addAutoReleasedObject(mgr);
addAutoReleasedObject(new QtOptionsPage());
m_welcomePage = new GettingStartedWelcomePage;
addObject(m_welcomePage);
GettingStartedWelcomePageWidget *gswp =
static_cast<GettingStartedWelcomePageWidget*>(m_welcomePage->page());
connect(mgr, SIGNAL(updateExamples(QString,QString,QString)),
gswp, SLOT(updateExamples(QString,QString,QString)));

hjk
committed
m_qt4ProjectManager = new Qt4Manager(this);
addObject(m_qt4ProjectManager);
TextEditor::TextEditorActionHandler *editorHandler

hjk
committed
= new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR);
m_proFileEditorFactory = new ProFileEditorFactory(m_qt4ProjectManager, editorHandler);
addObject(m_proFileEditorFactory);
addAutoReleasedObject(new EmptyProjectWizard);

hjk
committed
GuiAppWizard *guiWizard = new GuiAppWizard;

hjk
committed
ConsoleAppWizard *consoleWizard = new ConsoleAppWizard;

hjk
committed
LibraryWizard *libWizard = new LibraryWizard;
addAutoReleasedObject(new CustomWidgetWizard);
addAutoReleasedObject(new QMakeStepFactory);
addAutoReleasedObject(new MakeStepFactory);
#ifdef Q_OS_MAC
addAutoReleasedObject(new MacDesignerExternalEditor);
#else
addAutoReleasedObject(new DesignerExternalEditor);
#endif
addAutoReleasedObject(new LinguistExternalEditor);
#ifdef QTCREATOR_WITH_S60
addAutoReleasedObject(new S60Manager);
#endif
#ifdef QTCREATOR_WITH_MAEMO
addAutoReleasedObject(MaemoManager::instance());
#endif
// TODO reenable
//m_embeddedPropertiesPage = new EmbeddedPropertiesPage;
//addObject(m_embeddedPropertiesPage);
//menus
am->actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT);
//register actions
m_projectContext = core->uniqueIDManager()->
uniqueIdentifier(Qt4ProjectManager::Constants::PROJECT_KIND);
QList<int> context = QList<int>() << m_projectContext;
QIcon qmakeIcon(QLatin1String(":/qt4projectmanager/images/run_qmake.png"));
qmakeIcon.addFile(QLatin1String(":/qt4projectmanager/images/run_qmake_small.png"));
m_runQMakeAction = new QAction(qmakeIcon, tr("Run qmake"), this);
command = am->registerAction(m_runQMakeAction, Constants::RUNQMAKE, context);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_PROJECT);
connect(m_runQMakeAction, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(runQMake()));
m_runQMakeActionContextMenu = new QAction(qmakeIcon, tr("Run qmake"), this);
command = am->registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, context);
command->setAttribute(Core::Command::CA_Hide);
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
connect(m_runQMakeActionContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(runQMakeContextMenu()));
connect(m_projectExplorer,
SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)),
this, SLOT(updateContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)));
connect(m_projectExplorer->buildManager(), SIGNAL(buildStateChanged(ProjectExplorer::Project *)),
this, SLOT(buildStateChanged(ProjectExplorer::Project *)));
connect(m_projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project *)),
this, SLOT(currentProjectChanged()));
return true;
}
void Qt4ProjectManagerPlugin::extensionsInitialized()
{
m_qt4ProjectManager->init();
}
void Qt4ProjectManagerPlugin::updateContextMenu(Project *project,
ProjectExplorer::Node *node)
{
m_qt4ProjectManager->setContextProject(project);
m_qt4ProjectManager->setContextNode(node);
m_runQMakeActionContextMenu->setEnabled(false);
if (qobject_cast<Qt4Project *>(project)) {
if (!m_projectExplorer->buildManager()->isBuilding(project))
m_runQMakeActionContextMenu->setEnabled(true);
} else {
m_runQMakeActionContextMenu->setVisible(false);
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
}
}
void Qt4ProjectManagerPlugin::currentProjectChanged()
{
m_runQMakeAction->setEnabled(!m_projectExplorer->buildManager()->isBuilding(m_projectExplorer->currentProject()));
}
void Qt4ProjectManagerPlugin::buildStateChanged(ProjectExplorer::Project *pro)
{
ProjectExplorer::Project *currentProject = m_projectExplorer->currentProject();
if (pro == currentProject)
m_runQMakeAction->setEnabled(!m_projectExplorer->buildManager()->isBuilding(currentProject));
if (pro == m_qt4ProjectManager->contextProject())
m_runQMakeActionContextMenu->setEnabled(!m_projectExplorer->buildManager()->isBuilding(pro));
}
#ifdef WITH_TESTS
void Qt4ProjectManagerPlugin::testBasicProjectLoading()
{
QString testDirectory = ExtensionSystem::PluginManager::instance()->testDataDirectory() + "/qt4projectmanager/";
QString test1 = testDirectory + "test1/test1.pro";
m_projectExplorer->openProject(test1);
QVERIFY(!m_projectExplorer->session()->projects().isEmpty());
Qt4Project *qt4project = qobject_cast<Qt4Project *>(m_projectExplorer->session()->projects().first());
QVERIFY(qt4project);
QVERIFY(qt4project->rootProjectNode()->projectType() == ApplicationTemplate);
QVERIFY(m_projectExplorer->currentProject() != 0);
}
void Qt4ProjectManagerPlugin::testNotYetImplemented()
{
QCOMPARE(1+1, 2);
}
#endif
Q_EXPORT_PLUGIN(Qt4ProjectManagerPlugin)