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>
|
2010-08-13 14:18:10 +02:00
|
|
|
#include <debugger/qml/qmladapter.h>
|
2010-09-08 16:44:42 +02:00
|
|
|
#include <debugger/qml/qmlengine.h>
|
2010-02-09 20:44:40 +01:00
|
|
|
|
|
|
|
|
#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 <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/icontext.h>
|
2009-12-11 14:56:04 +10:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
} // end of anonymous namespace
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
InspectorPlugin::InspectorPlugin()
|
2010-08-13 14:18:10 +02:00
|
|
|
: IPlugin()
|
|
|
|
|
, m_clientProxy(0)
|
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-08-13 14:18:10 +02:00
|
|
|
m_inspectorUi = new InspectorUi(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
|
|
|
InspectorPlugin *InspectorPlugin::instance()
|
|
|
|
|
{
|
|
|
|
|
return g_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
InspectorUi *InspectorPlugin::inspector() const
|
2010-06-29 12:46:55 +02:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
return m_inspectorUi;
|
2010-06-29 12:46:55 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-14 15:38:16 +02:00
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag InspectorPlugin::aboutToShutdown()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
m_inspectorUi->saveSettings();
|
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
|
|
|
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-08-24 17:17:54 +02:00
|
|
|
uiSwitcher->addLanguage(Debugger::QmlLanguage, tr("QML"), Core::Context(C_INSPECTOR));
|
2010-06-29 12:46:55 +02:00
|
|
|
|
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();
|
2010-04-13 15:15:02 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
connect(pluginManager, SIGNAL(objectAdded(QObject*)), SLOT(objectAdded(QObject*)));
|
|
|
|
|
connect(pluginManager, SIGNAL(aboutToRemoveObject(QObject*)), SLOT(aboutToRemoveObject(QObject*)));
|
|
|
|
|
|
|
|
|
|
m_inspectorUi->setupUi();
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
// The adapter object is only added to the pool with a succesful connection,
|
|
|
|
|
// so we can immediately init our stuff.
|
|
|
|
|
void InspectorPlugin::objectAdded(QObject *object)
|
2010-02-09 20:44:40 +01:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
Debugger::Internal::QmlAdapter *adapter = qobject_cast<Debugger::Internal::QmlAdapter *>(object);
|
|
|
|
|
if (adapter) {
|
|
|
|
|
m_clientProxy = new ClientProxy(adapter);
|
|
|
|
|
m_inspectorUi->connected(m_clientProxy);
|
2010-09-08 16:44:42 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Debugger::Internal::QmlEngine *engine = qobject_cast<Debugger::Internal::QmlEngine*>(object);
|
|
|
|
|
if (engine) {
|
|
|
|
|
m_inspectorUi->setDebuggerEngine(engine);
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorPlugin::aboutToRemoveObject(QObject *obj)
|
2010-02-09 20:44:40 +01:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
if (m_clientProxy && m_clientProxy->qmlAdapter() == obj) {
|
|
|
|
|
m_inspectorUi->disconnected();
|
|
|
|
|
delete m_clientProxy;
|
|
|
|
|
m_clientProxy = 0;
|
|
|
|
|
}
|
2010-09-08 16:44:42 +02:00
|
|
|
|
|
|
|
|
if (m_inspectorUi->debuggerEngine() == obj) {
|
|
|
|
|
m_inspectorUi->setDebuggerEngine(0);
|
|
|
|
|
}
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
|
|
|
|
|
2010-06-29 12:41:26 +02:00
|
|
|
Q_EXPORT_PLUGIN(InspectorPlugin)
|