2010-11-11 10:05:05 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
2010-12-17 17:14:20 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 17:14:20 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 17:14:20 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qmljstoolsplugin.h"
|
|
|
|
|
#include "qmljsmodelmanager.h"
|
2010-11-16 13:54:50 +01:00
|
|
|
#include "qmljsfunctionfilter.h"
|
|
|
|
|
#include "qmljslocatordata.h"
|
2011-02-03 15:48:14 +01:00
|
|
|
#include "qmljscodestylesettingspage.h"
|
|
|
|
|
#include "qmljstoolsconstants.h"
|
2011-05-25 08:50:01 +02:00
|
|
|
#include "qmljstoolssettings.h"
|
2010-11-11 10:05:05 +01:00
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2011-06-23 15:12:03 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
|
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
2010-11-11 10:05:05 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QtPlugin>
|
|
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QSettings>
|
2011-06-23 15:12:03 +02:00
|
|
|
#include <QtGui/QMenu>
|
2010-11-11 10:05:05 +01:00
|
|
|
|
|
|
|
|
using namespace QmlJSTools::Internal;
|
|
|
|
|
|
|
|
|
|
enum { debug = 0 };
|
|
|
|
|
|
|
|
|
|
QmlJSToolsPlugin *QmlJSToolsPlugin::m_instance = 0;
|
|
|
|
|
|
|
|
|
|
QmlJSToolsPlugin::QmlJSToolsPlugin()
|
|
|
|
|
: m_modelManager(0)
|
|
|
|
|
{
|
|
|
|
|
m_instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlJSToolsPlugin::~QmlJSToolsPlugin()
|
|
|
|
|
{
|
|
|
|
|
m_instance = 0;
|
|
|
|
|
m_modelManager = 0; // deleted automatically
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(arguments)
|
|
|
|
|
Q_UNUSED(error)
|
2011-06-23 15:12:03 +02:00
|
|
|
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::ActionManager *am = Core::ICore::actionManager();
|
2010-11-11 10:05:05 +01:00
|
|
|
|
2011-05-25 08:50:01 +02:00
|
|
|
m_settings = new QmlJSToolsSettings(this); // force registration of qmljstools settings
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
// Objects
|
|
|
|
|
m_modelManager = new ModelManager(this);
|
|
|
|
|
// Core::VCSManager *vcsManager = core->vcsManager();
|
|
|
|
|
// Core::FileManager *fileManager = core->fileManager();
|
|
|
|
|
// connect(vcsManager, SIGNAL(repositoryChanged(QString)),
|
|
|
|
|
// m_modelManager, SLOT(updateModifiedSourceFiles()));
|
|
|
|
|
// connect(fileManager, SIGNAL(filesChangedInternally(QStringList)),
|
|
|
|
|
// m_modelManager, SLOT(updateSourceFiles(QStringList)));
|
|
|
|
|
addAutoReleasedObject(m_modelManager);
|
|
|
|
|
|
2010-11-16 13:54:50 +01:00
|
|
|
LocatorData *locatorData = new LocatorData;
|
|
|
|
|
addAutoReleasedObject(locatorData);
|
|
|
|
|
addAutoReleasedObject(new FunctionFilter(locatorData));
|
2011-05-25 08:50:01 +02:00
|
|
|
addAutoReleasedObject(new QmlJSCodeStyleSettingsPage);
|
|
|
|
|
|
2011-06-23 15:12:03 +02:00
|
|
|
// Menus
|
|
|
|
|
Core::ActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS);
|
|
|
|
|
Core::ActionContainer *mqmljstools = am->createMenu(Constants::M_TOOLS_QMLJS);
|
|
|
|
|
QMenu *menu = mqmljstools->menu();
|
|
|
|
|
menu->setTitle(tr("&QML/JS"));
|
|
|
|
|
menu->setEnabled(true);
|
|
|
|
|
mtools->addMenu(mqmljstools);
|
|
|
|
|
|
|
|
|
|
// Update context in global context
|
|
|
|
|
m_resetCodeModelAction = new QAction(tr("Reset Code Model"), this);
|
|
|
|
|
Core::Context globalContext(Core::Constants::C_GLOBAL);
|
|
|
|
|
Core::Command *cmd = am->registerAction(m_resetCodeModelAction, Core::Id(Constants::RESET_CODEMODEL), globalContext);
|
|
|
|
|
connect(m_resetCodeModelAction, SIGNAL(triggered()), m_modelManager, SLOT(resetCodeModel()));
|
|
|
|
|
mqmljstools->addAction(cmd);
|
|
|
|
|
|
|
|
|
|
// watch task progress
|
2012-01-24 15:36:40 +01:00
|
|
|
connect(Core::ICore::progressManager(), SIGNAL(taskStarted(QString)),
|
2011-06-23 15:12:03 +02:00
|
|
|
this, SLOT(onTaskStarted(QString)));
|
2012-01-24 15:36:40 +01:00
|
|
|
connect(Core::ICore::progressManager(), SIGNAL(allTasksFinished(QString)),
|
2011-06-23 15:12:03 +02:00
|
|
|
this, SLOT(onAllTasksFinished(QString)));
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlJSToolsPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2010-12-03 10:13:15 +01:00
|
|
|
m_modelManager->delayedInitialization();
|
2010-11-11 10:05:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag QmlJSToolsPlugin::aboutToShutdown()
|
|
|
|
|
{
|
|
|
|
|
return SynchronousShutdown;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-23 15:12:03 +02:00
|
|
|
void QmlJSToolsPlugin::onTaskStarted(const QString &type)
|
|
|
|
|
{
|
|
|
|
|
if (type == QmlJSTools::Constants::TASK_INDEX) {
|
|
|
|
|
m_resetCodeModelAction->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlJSToolsPlugin::onAllTasksFinished(const QString &type)
|
|
|
|
|
{
|
|
|
|
|
if (type == QmlJSTools::Constants::TASK_INDEX) {
|
|
|
|
|
m_resetCodeModelAction->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
Q_EXPORT_PLUGIN(QmlJSToolsPlugin)
|