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-03-18 16:39:02 +01:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
#include "qmlinspectorconstants.h"
|
2009-12-11 14:56:04 +10:00
|
|
|
#include "qmlinspector.h"
|
2010-02-17 12:33:31 +01:00
|
|
|
#include "inspectoroutputwidget.h"
|
2010-03-17 11:37:08 +01:00
|
|
|
#include "inspectorcontext.h"
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2009-12-11 14:56:04 +10:00
|
|
|
#include "components/objecttree.h"
|
|
|
|
|
#include "components/watchtable.h"
|
|
|
|
|
#include "components/canvasframerate.h"
|
|
|
|
|
#include "components/expressionquerywidget.h"
|
2010-03-18 16:39:02 +01:00
|
|
|
#include "components/objectpropertiesview.h"
|
|
|
|
|
|
|
|
|
|
#include <debugger/debuggermainwindow.h>
|
|
|
|
|
#include <debugger/debuggeruiswitcher.h>
|
2009-12-11 14:56:04 +10:00
|
|
|
|
|
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
#include <utils/fancymainwindow.h>
|
|
|
|
|
|
2010-03-17 11:37:08 +01:00
|
|
|
#include <coreplugin/icontext.h>
|
2009-12-11 14:56:04 +10:00
|
|
|
#include <coreplugin/basemode.h>
|
|
|
|
|
#include <coreplugin/findplaceholder.h>
|
|
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
#include <coreplugin/outputpane.h>
|
|
|
|
|
#include <coreplugin/rightpane.h>
|
|
|
|
|
#include <coreplugin/navigationwidget.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/uniqueidmanager.h>
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
|
|
|
|
|
#include <texteditor/itexteditor.h>
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/runconfiguration.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
#include <qmlprojectmanager/qmlprojectrunconfiguration.h>
|
2010-01-13 11:45:51 +10:00
|
|
|
|
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>
|
|
|
|
|
|
2009-12-11 14:56:04 +10:00
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/qtoolbutton.h>
|
|
|
|
|
#include <QtGui/qtoolbar.h>
|
|
|
|
|
#include <QtGui/qboxlayout.h>
|
|
|
|
|
#include <QtGui/qlabel.h>
|
|
|
|
|
#include <QtGui/qdockwidget.h>
|
|
|
|
|
#include <QtGui/qaction.h>
|
|
|
|
|
#include <QtGui/qlineedit.h>
|
|
|
|
|
#include <QtGui/qlabel.h>
|
|
|
|
|
#include <QtGui/qspinbox.h>
|
|
|
|
|
|
2009-12-18 15:32:36 +10:00
|
|
|
#include <QtNetwork/QHostAddress>
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
using namespace Qml;
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
namespace Qml {
|
2009-12-11 14:56:04 +10:00
|
|
|
|
|
|
|
|
class EngineSpinBox : public QSpinBox
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
struct EngineInfo
|
|
|
|
|
{
|
|
|
|
|
QString name;
|
|
|
|
|
int id;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
EngineSpinBox(QWidget *parent = 0);
|
|
|
|
|
|
|
|
|
|
void addEngine(int engine, const QString &name);
|
|
|
|
|
void clearEngines();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual QString textFromValue(int value) const;
|
|
|
|
|
virtual int valueFromText(const QString &text) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QList<EngineInfo> m_engines;
|
|
|
|
|
};
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-11 14:56:04 +10:00
|
|
|
EngineSpinBox::EngineSpinBox(QWidget *parent)
|
|
|
|
|
: QSpinBox(parent)
|
|
|
|
|
{
|
|
|
|
|
setEnabled(false);
|
|
|
|
|
setReadOnly(true);
|
|
|
|
|
setRange(0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EngineSpinBox::addEngine(int engine, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
EngineInfo info;
|
|
|
|
|
info.id = engine;
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
info.name = tr("Engine %1", "engine number").arg(engine);
|
|
|
|
|
else
|
|
|
|
|
info.name = name;
|
|
|
|
|
m_engines << info;
|
|
|
|
|
|
|
|
|
|
setRange(0, m_engines.count()-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EngineSpinBox::clearEngines()
|
|
|
|
|
{
|
|
|
|
|
m_engines.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString EngineSpinBox::textFromValue(int value) const
|
|
|
|
|
{
|
|
|
|
|
for (int i=0; i<m_engines.count(); ++i) {
|
|
|
|
|
if (m_engines[i].id == value)
|
|
|
|
|
return m_engines[i].name;
|
|
|
|
|
}
|
|
|
|
|
return QLatin1String("<None>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int EngineSpinBox::valueFromText(const QString &text) const
|
|
|
|
|
{
|
|
|
|
|
for (int i=0; i<m_engines.count(); ++i) {
|
|
|
|
|
if (m_engines[i].name == text)
|
|
|
|
|
return m_engines[i].id;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
QmlInspector::QmlInspector(QObject *parent)
|
|
|
|
|
: QObject(parent),
|
2009-12-11 14:56:04 +10:00
|
|
|
m_conn(0),
|
|
|
|
|
m_client(0),
|
|
|
|
|
m_engineQuery(0),
|
2010-02-17 12:33:31 +01:00
|
|
|
m_contextQuery(0),
|
|
|
|
|
m_objectTreeDock(0),
|
|
|
|
|
m_frameRateDock(0),
|
|
|
|
|
m_propertyWatcherDock(0),
|
|
|
|
|
m_inspectorOutputDock(0)
|
2010-01-29 22:49:55 +01:00
|
|
|
{
|
2009-12-11 14:56:04 +10:00
|
|
|
m_watchTableModel = new WatchTableModel(0, this);
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
initWidgets();
|
2009-12-11 14:56:04 +10:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
bool QmlInspector::connectToViewer()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
if (m_conn && m_conn->state() != QAbstractSocket::UnconnectedState)
|
2010-02-09 20:44:40 +01:00
|
|
|
return false;
|
2009-12-11 14:56:04 +10:00
|
|
|
|
|
|
|
|
delete m_client; m_client = 0;
|
|
|
|
|
|
|
|
|
|
if (m_conn) {
|
|
|
|
|
m_conn->disconnectFromHost();
|
|
|
|
|
delete m_conn;
|
2010-03-10 18:28:51 +01:00
|
|
|
m_conn = 0;
|
2009-12-11 14:56:04 +10:00
|
|
|
}
|
|
|
|
|
|
2009-12-18 15:32:36 +10:00
|
|
|
ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject();
|
|
|
|
|
if (!project) {
|
|
|
|
|
emit statusMessage(tr("No active project, debugging canceled."));
|
2010-02-09 20:44:40 +01:00
|
|
|
return false;
|
2009-12-18 15:32:36 +10:00
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
QmlProjectManager::QmlProjectRunConfiguration* config =
|
|
|
|
|
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration*>(project->activeTarget()->activeRunConfiguration());
|
2009-12-18 15:32:36 +10:00
|
|
|
if (!config) {
|
|
|
|
|
emit statusMessage(tr("Cannot find project run configuration, debugging canceled."));
|
2010-02-09 20:44:40 +01:00
|
|
|
return false;
|
2009-12-18 15:32:36 +10:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
QString host = config->debugServerAddress();
|
2010-01-13 11:45:51 +10:00
|
|
|
quint16 port = quint16(config->debugServerPort());
|
2009-12-18 15:32:36 +10:00
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
m_conn = new QDeclarativeDebugConnection(this);
|
2009-12-11 14:56:04 +10:00
|
|
|
connect(m_conn, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
|
|
|
|
|
SLOT(connectionStateChanged()));
|
|
|
|
|
connect(m_conn, SIGNAL(error(QAbstractSocket::SocketError)),
|
|
|
|
|
SLOT(connectionError()));
|
2009-12-18 15:32:36 +10:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
emit statusMessage(tr("[Inspector] set to connect to debug server %1:%2").arg(host).arg(port));
|
2009-12-18 15:32:36 +10:00
|
|
|
m_conn->connectToHost(host, port);
|
2010-02-09 20:44:40 +01:00
|
|
|
// blocks until connected; if no connection is available, will fail immediately
|
|
|
|
|
if (m_conn->waitForConnected())
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
2009-12-11 14:56:04 +10:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
void QmlInspector::disconnectFromViewer()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
m_conn->disconnectFromHost();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
void QmlInspector::connectionStateChanged()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
switch (m_conn->state()) {
|
|
|
|
|
case QAbstractSocket::UnconnectedState:
|
|
|
|
|
{
|
|
|
|
|
emit statusMessage(tr("[Inspector] disconnected.\n\n"));
|
|
|
|
|
|
|
|
|
|
delete m_engineQuery;
|
|
|
|
|
m_engineQuery = 0;
|
|
|
|
|
delete m_contextQuery;
|
|
|
|
|
m_contextQuery = 0;
|
2010-03-18 12:20:07 +01:00
|
|
|
|
|
|
|
|
resetViews();
|
|
|
|
|
|
2009-12-11 14:56:04 +10:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QAbstractSocket::HostLookupState:
|
|
|
|
|
emit statusMessage(tr("[Inspector] resolving host..."));
|
|
|
|
|
break;
|
|
|
|
|
case QAbstractSocket::ConnectingState:
|
|
|
|
|
emit statusMessage(tr("[Inspector] connecting to debug server..."));
|
|
|
|
|
break;
|
|
|
|
|
case QAbstractSocket::ConnectedState:
|
|
|
|
|
{
|
|
|
|
|
emit statusMessage(tr("[Inspector] connected.\n"));
|
|
|
|
|
|
|
|
|
|
if (!m_client) {
|
2010-02-26 14:42:11 +01:00
|
|
|
m_client = new QDeclarativeEngineDebug(m_conn, this);
|
2009-12-11 14:56:04 +10:00
|
|
|
m_objectTreeWidget->setEngineDebug(m_client);
|
|
|
|
|
m_propertiesWidget->setEngineDebug(m_client);
|
|
|
|
|
m_watchTableModel->setEngineDebug(m_client);
|
|
|
|
|
m_expressionWidget->setEngineDebug(m_client);
|
|
|
|
|
}
|
2010-01-29 22:49:55 +01:00
|
|
|
|
2010-03-18 12:20:07 +01:00
|
|
|
resetViews();
|
2009-12-11 14:56:04 +10:00
|
|
|
m_frameRateWidget->reset(m_conn);
|
|
|
|
|
|
|
|
|
|
reloadEngines();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QAbstractSocket::ClosingState:
|
|
|
|
|
emit statusMessage(tr("[Inspector] closing..."));
|
|
|
|
|
break;
|
2010-01-12 13:56:52 +10:00
|
|
|
case QAbstractSocket::BoundState:
|
|
|
|
|
case QAbstractSocket::ListeningState:
|
|
|
|
|
break;
|
2009-12-11 14:56:04 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-18 12:20:07 +01:00
|
|
|
void QmlInspector::resetViews()
|
|
|
|
|
{
|
|
|
|
|
m_objectTreeWidget->clear();
|
|
|
|
|
m_propertiesWidget->clear();
|
|
|
|
|
m_expressionWidget->clear();
|
|
|
|
|
m_watchTableModel->removeAllWatches();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-17 11:37:08 +01:00
|
|
|
Core::IContext *QmlInspector::context() const
|
|
|
|
|
{
|
|
|
|
|
return m_context;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
void QmlInspector::connectionError()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
emit statusMessage(tr("[Inspector] error: (%1) %2", "%1=error code, %2=error message")
|
|
|
|
|
.arg(m_conn->error()).arg(m_conn->errorString()));
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
void QmlInspector::initWidgets()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
2010-02-09 20:44:40 +01:00
|
|
|
m_objectTreeWidget = new ObjectTree;
|
|
|
|
|
m_propertiesWidget = new ObjectPropertiesView;
|
|
|
|
|
m_watchTableView = new WatchTableView(m_watchTableModel);
|
|
|
|
|
m_frameRateWidget = new CanvasFrameRate;
|
2010-03-17 11:37:08 +01:00
|
|
|
m_expressionWidget = new ExpressionQueryWidget(ExpressionQueryWidget::SeparateEntryMode);
|
|
|
|
|
m_context = new Internal::InspectorContext(m_expressionWidget);
|
|
|
|
|
m_expressionWidget->createCommands(m_context);
|
|
|
|
|
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
m_engineSpinBox = new EngineSpinBox;
|
|
|
|
|
m_engineSpinBox->setEnabled(false);
|
|
|
|
|
connect(m_engineSpinBox, SIGNAL(valueChanged(int)),
|
|
|
|
|
SLOT(queryEngineContext(int)));
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
// FancyMainWindow uses widgets' window titles for tab labels
|
|
|
|
|
m_frameRateWidget->setWindowTitle(tr("Frame rate"));
|
2009-12-11 14:56:04 +10:00
|
|
|
|
|
|
|
|
Utils::StyledBar *treeOptionBar = new Utils::StyledBar;
|
|
|
|
|
QHBoxLayout *treeOptionBarLayout = new QHBoxLayout(treeOptionBar);
|
|
|
|
|
treeOptionBarLayout->setContentsMargins(5, 0, 5, 0);
|
|
|
|
|
treeOptionBarLayout->setSpacing(5);
|
|
|
|
|
treeOptionBarLayout->addWidget(new QLabel(tr("QML engine:")));
|
|
|
|
|
treeOptionBarLayout->addWidget(m_engineSpinBox);
|
|
|
|
|
|
|
|
|
|
QWidget *treeWindow = new QWidget;
|
2010-02-09 20:44:40 +01:00
|
|
|
treeWindow->setWindowTitle(tr("Object Tree"));
|
2009-12-11 14:56:04 +10:00
|
|
|
QVBoxLayout *treeWindowLayout = new QVBoxLayout(treeWindow);
|
|
|
|
|
treeWindowLayout->setMargin(0);
|
|
|
|
|
treeWindowLayout->setSpacing(0);
|
|
|
|
|
treeWindowLayout->addWidget(treeOptionBar);
|
2010-01-29 22:49:55 +01:00
|
|
|
treeWindowLayout->addWidget(m_objectTreeWidget);
|
2009-12-11 14:56:04 +10:00
|
|
|
|
|
|
|
|
m_watchTableView->setModel(m_watchTableModel);
|
|
|
|
|
WatchTableHeaderView *header = new WatchTableHeaderView(m_watchTableModel);
|
|
|
|
|
m_watchTableView->setHorizontalHeader(header);
|
|
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
connect(m_objectTreeWidget, SIGNAL(activated(QDeclarativeDebugObjectReference)),
|
|
|
|
|
this, SLOT(treeObjectActivated(QDeclarativeDebugObjectReference)));
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
connect(m_objectTreeWidget, SIGNAL(currentObjectChanged(QDeclarativeDebugObjectReference)),
|
|
|
|
|
m_propertiesWidget, SLOT(reload(QDeclarativeDebugObjectReference)));
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
connect(m_objectTreeWidget, SIGNAL(expressionWatchRequested(QDeclarativeDebugObjectReference,QString)),
|
|
|
|
|
m_watchTableModel, SLOT(expressionWatchRequested(QDeclarativeDebugObjectReference,QString)));
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
connect(m_propertiesWidget, SIGNAL(activated(QDeclarativeDebugObjectReference,QDeclarativeDebugPropertyReference)),
|
|
|
|
|
m_watchTableModel, SLOT(togglePropertyWatch(QDeclarativeDebugObjectReference,QDeclarativeDebugPropertyReference)));
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
connect(m_watchTableModel, SIGNAL(watchCreated(QDeclarativeDebugWatch*)),
|
|
|
|
|
m_propertiesWidget, SLOT(watchCreated(QDeclarativeDebugWatch*)));
|
2009-12-11 14:56:04 +10:00
|
|
|
|
|
|
|
|
connect(m_watchTableModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
|
|
|
|
|
m_watchTableView, SLOT(scrollToBottom()));
|
|
|
|
|
|
|
|
|
|
connect(m_watchTableView, SIGNAL(objectActivated(int)),
|
2010-01-29 22:49:55 +01:00
|
|
|
m_objectTreeWidget, SLOT(setCurrentObject(int)));
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
connect(m_objectTreeWidget, SIGNAL(currentObjectChanged(QDeclarativeDebugObjectReference)),
|
|
|
|
|
m_expressionWidget, SLOT(setCurrentObject(QDeclarativeDebugObjectReference)));
|
2009-12-11 14:56:04 +10:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
|
|
|
|
|
Core::MiniSplitter *leftSplitter = new Core::MiniSplitter(Qt::Vertical);
|
|
|
|
|
leftSplitter->addWidget(m_propertiesWidget);
|
2010-03-17 11:37:08 +01:00
|
|
|
leftSplitter->addWidget(m_watchTableView);
|
2010-02-09 20:44:40 +01:00
|
|
|
leftSplitter->setStretchFactor(0, 2);
|
|
|
|
|
leftSplitter->setStretchFactor(1, 1);
|
|
|
|
|
|
|
|
|
|
Core::MiniSplitter *propSplitter = new Core::MiniSplitter(Qt::Horizontal);
|
|
|
|
|
propSplitter->addWidget(leftSplitter);
|
2010-03-17 11:37:08 +01:00
|
|
|
propSplitter->addWidget(m_expressionWidget);
|
2010-02-09 20:44:40 +01:00
|
|
|
propSplitter->setStretchFactor(0, 2);
|
|
|
|
|
propSplitter->setStretchFactor(1, 1);
|
|
|
|
|
propSplitter->setWindowTitle(tr("Properties and Watchers"));
|
|
|
|
|
|
2010-02-17 12:33:31 +01:00
|
|
|
|
|
|
|
|
InspectorOutputWidget *inspectorOutput = new InspectorOutputWidget();
|
|
|
|
|
connect(this, SIGNAL(statusMessage(QString)),
|
|
|
|
|
inspectorOutput, SLOT(addInspectorStatus(QString)));
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
m_objectTreeDock = Debugger::DebuggerUISwitcher::instance()->createDockWidget(Qml::Constants::LANG_QML,
|
|
|
|
|
treeWindow, Qt::BottomDockWidgetArea);
|
|
|
|
|
m_frameRateDock = Debugger::DebuggerUISwitcher::instance()->createDockWidget(Qml::Constants::LANG_QML,
|
|
|
|
|
m_frameRateWidget, Qt::BottomDockWidgetArea);
|
|
|
|
|
m_propertyWatcherDock = Debugger::DebuggerUISwitcher::instance()->createDockWidget(Qml::Constants::LANG_QML,
|
|
|
|
|
propSplitter, Qt::BottomDockWidgetArea);
|
2010-02-17 12:33:31 +01:00
|
|
|
m_inspectorOutputDock = Debugger::DebuggerUISwitcher::instance()->createDockWidget(Qml::Constants::LANG_QML,
|
|
|
|
|
inspectorOutput, Qt::BottomDockWidgetArea);
|
|
|
|
|
m_dockWidgets << m_objectTreeDock << m_frameRateDock << m_propertyWatcherDock << m_inspectorOutputDock;
|
2009-12-11 14:56:04 +10:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
void QmlInspector::setSimpleDockWidgetArrangement()
|
|
|
|
|
{
|
2010-03-18 10:59:06 +01:00
|
|
|
Utils::FancyMainWindow *mainWindow = Debugger::DebuggerUISwitcher::instance()->mainWindow();
|
2010-02-09 20:44:40 +01:00
|
|
|
|
|
|
|
|
mainWindow->setTrackingEnabled(false);
|
|
|
|
|
QList<QDockWidget *> dockWidgets = mainWindow->dockWidgets();
|
|
|
|
|
foreach (QDockWidget *dockWidget, dockWidgets) {
|
|
|
|
|
if (m_dockWidgets.contains(dockWidget)) {
|
|
|
|
|
dockWidget->setFloating(false);
|
|
|
|
|
mainWindow->removeDockWidget(dockWidget);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (QDockWidget *dockWidget, dockWidgets) {
|
|
|
|
|
if (m_dockWidgets.contains(dockWidget)) {
|
|
|
|
|
if (dockWidget == m_objectTreeDock)
|
|
|
|
|
mainWindow->addDockWidget(Qt::RightDockWidgetArea, dockWidget);
|
|
|
|
|
else
|
|
|
|
|
mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
|
|
|
|
|
dockWidget->show();
|
|
|
|
|
// dockwidget is not actually visible during init because debugger is
|
|
|
|
|
// not visible, either. we can use isVisibleTo(), though.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mainWindow->tabifyDockWidget(m_frameRateDock, m_propertyWatcherDock);
|
2010-03-18 14:47:52 +01:00
|
|
|
mainWindow->tabifyDockWidget(m_propertyWatcherDock, m_inspectorOutputDock);
|
|
|
|
|
|
|
|
|
|
m_inspectorOutputDock->setVisible(false);
|
2010-02-17 12:33:31 +01:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
mainWindow->setTrackingEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlInspector::reloadEngines()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
if (m_engineQuery) {
|
|
|
|
|
emit statusMessage("[Inspector] Waiting for response to previous engine query");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_engineSpinBox->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
m_engineQuery = m_client->queryAvailableEngines(this);
|
|
|
|
|
if (!m_engineQuery->isWaiting())
|
|
|
|
|
enginesChanged();
|
|
|
|
|
else
|
2010-02-26 14:42:11 +01:00
|
|
|
QObject::connect(m_engineQuery, SIGNAL(stateChanged(QDeclarativeDebugQuery::State)),
|
2010-01-29 22:49:55 +01:00
|
|
|
this, SLOT(enginesChanged()));
|
2009-12-11 14:56:04 +10:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
void QmlInspector::enginesChanged()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
m_engineSpinBox->clearEngines();
|
|
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
QList<QDeclarativeDebugEngineReference> engines = m_engineQuery->engines();
|
2009-12-11 14:56:04 +10:00
|
|
|
delete m_engineQuery; m_engineQuery = 0;
|
|
|
|
|
|
|
|
|
|
if (engines.isEmpty())
|
|
|
|
|
qWarning("qmldebugger: no engines found!");
|
|
|
|
|
|
|
|
|
|
m_engineSpinBox->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<engines.count(); ++i)
|
|
|
|
|
m_engineSpinBox->addEngine(engines.at(i).debugId(), engines.at(i).name());
|
|
|
|
|
|
|
|
|
|
if (engines.count() > 0) {
|
|
|
|
|
m_engineSpinBox->setValue(engines.at(0).debugId());
|
|
|
|
|
queryEngineContext(engines.at(0).debugId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
void QmlInspector::queryEngineContext(int id)
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
if (id < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (m_contextQuery) {
|
|
|
|
|
delete m_contextQuery;
|
|
|
|
|
m_contextQuery = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
m_contextQuery = m_client->queryRootContexts(QDeclarativeDebugEngineReference(id), this);
|
2009-12-11 14:56:04 +10:00
|
|
|
if (!m_contextQuery->isWaiting())
|
|
|
|
|
contextChanged();
|
|
|
|
|
else
|
2010-02-26 14:42:11 +01:00
|
|
|
QObject::connect(m_contextQuery, SIGNAL(stateChanged(QDeclarativeDebugQuery::State)),
|
2009-12-11 14:56:04 +10:00
|
|
|
this, SLOT(contextChanged()));
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
void QmlInspector::contextChanged()
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
|
|
|
|
//dump(m_contextQuery->rootContext(), 0);
|
|
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
foreach (const QDeclarativeDebugObjectReference &object, m_contextQuery->rootContext().objects())
|
2009-12-11 14:56:04 +10:00
|
|
|
m_objectTreeWidget->reload(object.debugId());
|
|
|
|
|
|
|
|
|
|
delete m_contextQuery; m_contextQuery = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-26 14:42:11 +01:00
|
|
|
void QmlInspector::treeObjectActivated(const QDeclarativeDebugObjectReference &obj)
|
2009-12-11 14:56:04 +10:00
|
|
|
{
|
2010-02-26 14:42:11 +01:00
|
|
|
QDeclarativeDebugFileReference source = obj.source();
|
2009-12-11 14:56:04 +10:00
|
|
|
QString fileName = source.url().toLocalFile();
|
|
|
|
|
|
|
|
|
|
if (source.lineNumber() < 0 || !QFile::exists(fileName))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
|
|
|
|
TextEditor::ITextEditor *editor = qobject_cast<TextEditor::ITextEditor*>(editorManager->openEditor(fileName));
|
|
|
|
|
if (editor) {
|
|
|
|
|
editorManager->ensureEditorManagerVisible();
|
|
|
|
|
editorManager->addCurrentPositionToNavigationHistory();
|
|
|
|
|
editor->gotoLine(source.lineNumber());
|
|
|
|
|
editor->widget()->setFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
#include "qmlinspector.moc"
|