2009-12-11 14:56:04 +10:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-12-11 14:56:04 +10:00
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
2010-06-25 17:37:59 +02:00
|
|
|
|
2010-06-28 17:46:42 +02:00
|
|
|
#include "qmljsinspectorconstants.h"
|
|
|
|
|
#include "qmljsinspectorplugin.h"
|
2010-06-29 12:46:55 +02:00
|
|
|
#include "qmljsinspector.h"
|
2010-06-29 12:41:26 +02:00
|
|
|
#include "qmljsclientproxy.h"
|
2010-07-08 11:34:51 +02:00
|
|
|
#include "qmlinspectortoolbar.h"
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
#include <debugger/debuggeruiswitcher.h>
|
|
|
|
|
#include <debugger/debuggerconstants.h>
|
|
|
|
|
|
|
|
|
|
#include <qmlprojectmanager/qmlproject.h>
|
|
|
|
|
#include <qmljseditor/qmljseditorconstants.h>
|
|
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-06-29 12:31:07 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2009-12-11 14:56:04 +10:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
|
2010-06-29 12:31:07 +02:00
|
|
|
#include <coreplugin/modemanager.h>
|
|
|
|
|
#include <coreplugin/imode.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/icontext.h>
|
2009-12-11 14:56:04 +10:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2010-02-09 20:44:40 +01:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2009-12-11 14:56:04 +10:00
|
|
|
|
|
|
|
|
#include <QtCore/QStringList>
|
|
|
|
|
#include <QtCore/QtPlugin>
|
2010-02-09 20:44:40 +01:00
|
|
|
#include <QtCore/QTimer>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QHBoxLayout>
|
|
|
|
|
#include <QtGui/QToolButton>
|
|
|
|
|
|
2009-12-11 14:56:04 +10:00
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
|
2010-06-28 17:46:42 +02:00
|
|
|
using namespace QmlJSInspector::Internal;
|
|
|
|
|
using namespace QmlJSInspector::Constants;
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-06-28 17:15:45 +02:00
|
|
|
namespace {
|
2010-06-29 12:31:07 +02:00
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
InspectorPlugin *g_instance = 0; // the global QML/JS inspector instance
|
2010-06-29 12:31:07 +02:00
|
|
|
|
2010-06-28 17:15:45 +02:00
|
|
|
QToolButton *createToolButton(QAction *action)
|
2010-02-09 20:44:40 +01:00
|
|
|
{
|
|
|
|
|
QToolButton *button = new QToolButton;
|
|
|
|
|
button->setDefaultAction(action);
|
|
|
|
|
return button;
|
|
|
|
|
}
|
2010-06-29 12:31:07 +02:00
|
|
|
|
2010-06-28 17:15:45 +02:00
|
|
|
} // end of anonymous namespace
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
InspectorPlugin::InspectorPlugin()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
2010-06-29 12:31:07 +02:00
|
|
|
Q_ASSERT(! g_instance);
|
|
|
|
|
g_instance = this;
|
2010-06-29 12:41:26 +02:00
|
|
|
|
2010-06-29 12:46:55 +02:00
|
|
|
_clientProxy = new ClientProxy(this);
|
|
|
|
|
_inspector = new Inspector(this);
|
2010-07-08 11:34:51 +02:00
|
|
|
m_toolbar = new QmlInspectorToolbar(this);
|
2009-12-11 14:56:04 +10:00
|
|
|
}
|
|
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
InspectorPlugin::~InspectorPlugin()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-29 15:52:40 +02:00
|
|
|
QmlJS::ModelManagerInterface *InspectorPlugin::modelManager() const
|
|
|
|
|
{
|
|
|
|
|
return ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-29 12:46:55 +02:00
|
|
|
ClientProxy *InspectorPlugin::clientProxy() const
|
|
|
|
|
{
|
|
|
|
|
return _clientProxy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InspectorPlugin *InspectorPlugin::instance()
|
|
|
|
|
{
|
|
|
|
|
return g_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Inspector *InspectorPlugin::inspector() const
|
|
|
|
|
{
|
|
|
|
|
return _inspector;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-14 15:38:16 +02:00
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag InspectorPlugin::aboutToShutdown()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
2010-07-14 15:38:16 +02:00
|
|
|
return SynchronousShutdown;
|
2009-12-11 14:56:04 +10:00
|
|
|
}
|
|
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
bool InspectorPlugin::initialize(const QStringList &arguments, QString *errorString)
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(arguments);
|
|
|
|
|
Q_UNUSED(errorString);
|
2010-06-28 17:15:45 +02:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
|
|
|
|
SLOT(prepareDebugger(Core::IMode*)));
|
|
|
|
|
|
|
|
|
|
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-06-29 12:31:07 +02:00
|
|
|
uiSwitcher->addLanguage(LANG_QML, Core::Context(C_INSPECTOR));
|
2010-06-29 12:46:55 +02:00
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
|
# warning set up the QML/JS Inspector UI
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-06-29 12:31:07 +02:00
|
|
|
#if 0
|
2010-06-29 12:46:55 +02:00
|
|
|
_inspector->createDockWidgets();
|
2010-06-28 17:15:45 +02:00
|
|
|
#endif
|
2009-12-11 14:56:04 +10:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
void InspectorPlugin::extensionsInitialized()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
2010-02-09 20:44:40 +01:00
|
|
|
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
|
2010-04-13 15:15:02 +02:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
connect(uiSwitcher, SIGNAL(dockArranged(QString)), SLOT(setDockWidgetArrangement(QString)));
|
|
|
|
|
|
2010-06-29 12:31:07 +02:00
|
|
|
if (ProjectExplorer::ProjectExplorerPlugin *pex = ProjectExplorer::ProjectExplorerPlugin::instance()) {
|
2010-03-17 08:56:42 +01:00
|
|
|
connect(pex, SIGNAL(aboutToExecuteProject(ProjectExplorer::Project*, QString)),
|
|
|
|
|
SLOT(activateDebuggerForProject(ProjectExplorer::Project*, QString)));
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
2010-07-08 11:34:51 +02:00
|
|
|
m_toolbar->createActions(Core::Context(C_INSPECTOR));
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
connect(_clientProxy, SIGNAL(connected(QDeclarativeEngineDebug*)), m_toolbar, SLOT(enable()));
|
|
|
|
|
connect(_clientProxy, SIGNAL(disconnected()), m_toolbar, SLOT(disable()));
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2010-07-12 12:02:35 +02:00
|
|
|
connect(m_toolbar, SIGNAL(designModeSelected(bool)), _clientProxy, SLOT(setDesignModeBehavior(bool)));
|
2010-07-08 12:30:08 +02:00
|
|
|
connect(m_toolbar, SIGNAL(reloadSelected()), _clientProxy, SLOT(reloadQmlViewer()));
|
2010-07-08 11:34:51 +02:00
|
|
|
connect(m_toolbar, SIGNAL(animationSpeedChanged(qreal)), _clientProxy, SLOT(setAnimationSpeed(qreal)));
|
|
|
|
|
connect(m_toolbar, SIGNAL(colorPickerSelected()), _clientProxy, SLOT(changeToColorPickerTool()));
|
|
|
|
|
connect(m_toolbar, SIGNAL(zoomToolSelected()), _clientProxy, SLOT(changeToZoomTool()));
|
|
|
|
|
connect(m_toolbar, SIGNAL(selectToolSelected()), _clientProxy, SLOT(changeToSelectTool()));
|
|
|
|
|
connect(m_toolbar, SIGNAL(marqueeSelectToolSelected()), _clientProxy, SLOT(changeToSelectMarqueeTool()));
|
2010-07-26 11:59:59 +02:00
|
|
|
connect(m_toolbar, SIGNAL(applyChangesFromQmlFileTriggered(bool)), _inspector, SLOT(setApplyChangesToQmlObserver(bool)));
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
connect(_clientProxy, SIGNAL(colorPickerActivated()), m_toolbar, SLOT(activateColorPicker()));
|
|
|
|
|
connect(_clientProxy, SIGNAL(selectToolActivated()), m_toolbar, SLOT(activateSelectTool()));
|
|
|
|
|
connect(_clientProxy, SIGNAL(selectMarqueeToolActivated()), m_toolbar, SLOT(activateMarqueeSelectTool()));
|
|
|
|
|
connect(_clientProxy, SIGNAL(zoomToolActivated()), m_toolbar, SLOT(activateZoomTool()));
|
2010-07-12 12:02:35 +02:00
|
|
|
connect(_clientProxy, SIGNAL(designModeBehaviorChanged(bool)), m_toolbar, SLOT(setDesignModeBehavior(bool)));
|
2010-07-26 12:47:55 +02:00
|
|
|
connect(_clientProxy, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setSelectedColor(QColor)));
|
2010-06-29 16:15:49 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
connect(_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(changeAnimationSpeed(qreal)));
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
|
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
void InspectorPlugin::activateDebuggerForProject(ProjectExplorer::Project *project, const QString &runMode)
|
2010-02-09 20:44:40 +01:00
|
|
|
{
|
2010-06-28 17:15:45 +02:00
|
|
|
Q_UNUSED(project);
|
|
|
|
|
Q_UNUSED(runMode);
|
|
|
|
|
|
2010-06-29 12:31:07 +02:00
|
|
|
if (runMode == QLatin1String(ProjectExplorer::Constants::DEBUGMODE)) {
|
2010-06-29 12:46:55 +02:00
|
|
|
#ifdef __GNUC__
|
|
|
|
|
# warning start a QML/JS debugging session using the information stored in the current project
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-04-13 15:15:02 +02:00
|
|
|
// FIXME we probably want to activate the debugger for other projects than QmlProjects,
|
|
|
|
|
// if they contain Qml files. Some kind of options should exist for this behavior.
|
2010-06-29 14:24:12 +02:00
|
|
|
if (QmlProjectManager::QmlProject *qmlproj = qobject_cast<QmlProjectManager::QmlProject*>(project)) {
|
|
|
|
|
if (_inspector->setDebugConfigurationDataFromProject(qmlproj))
|
|
|
|
|
_inspector->startQmlProjectDebugger();
|
|
|
|
|
}
|
2010-06-29 12:31:07 +02:00
|
|
|
}
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
void InspectorPlugin::prepareDebugger(Core::IMode *mode)
|
2010-02-09 20:44:40 +01:00
|
|
|
{
|
2010-06-29 12:31:07 +02:00
|
|
|
if (mode->id() != QLatin1String(Debugger::Constants::MODE_DEBUG))
|
2010-02-09 20:44:40 +01:00
|
|
|
return;
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-04-13 15:15:02 +02:00
|
|
|
ProjectExplorer::ProjectExplorerPlugin *pex = ProjectExplorer::ProjectExplorerPlugin::instance();
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-06-29 12:31:07 +02:00
|
|
|
if (pex->startupProject() && pex->startupProject()->id() == QLatin1String("QmlProjectManager.QmlProject")) {
|
2010-02-09 20:44:40 +01:00
|
|
|
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
|
2010-06-29 12:31:07 +02:00
|
|
|
uiSwitcher->setActiveLanguage(LANG_QML);
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
void InspectorPlugin::setDockWidgetArrangement(const QString &activeLanguage)
|
2010-02-09 20:44:40 +01:00
|
|
|
{
|
2010-06-28 17:15:45 +02:00
|
|
|
Q_UNUSED(activeLanguage);
|
|
|
|
|
|
|
|
|
|
#if 0
|
2010-02-09 20:44:40 +01:00
|
|
|
if (activeLanguage == Qml::Constants::LANG_QML || activeLanguage.isEmpty())
|
|
|
|
|
m_inspector->setSimpleDockWidgetArrangement();
|
2010-06-28 17:15:45 +02:00
|
|
|
#endif
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
Q_EXPORT_PLUGIN(InspectorPlugin)
|