forked from qt-creator/qt-creator
Merge branch 'debugintegration'
Conflicts: src/plugins/qmlprojectmanager/qmlproject.cpp src/plugins/qmlprojectmanager/qmlproject.h
This commit is contained in:
@@ -24,5 +24,6 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license>
|
||||
<dependency name="CppTools" version="1.3.80"/>
|
||||
<dependency name="CppEditor" version="1.3.80"/>
|
||||
<dependency name="Help" version="1.3.80"/>
|
||||
<dependency name="Debugger" version="1.3.80"/>
|
||||
</dependencyList>
|
||||
</plugin>
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
#include <QtGui/qtextedit.h>
|
||||
|
||||
using namespace Qml;
|
||||
|
||||
InspectorOutputPane::InspectorOutputPane(QObject *parent)
|
||||
: Core::IOutputPane(parent),
|
||||
m_textEdit(new QTextEdit)
|
||||
|
||||
@@ -33,12 +33,11 @@
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTextEdit;
|
||||
|
||||
class RunControl;
|
||||
|
||||
namespace Qml {
|
||||
|
||||
class InspectorOutputPane : public Core::IOutputPane
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -76,7 +75,7 @@ private:
|
||||
QTextEdit *m_textEdit;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,8 +26,11 @@
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
#include "qmlinspectorconstants.h"
|
||||
#include "qmlinspector.h"
|
||||
#include "qmlinspectormode.h"
|
||||
#include "debugger/debuggermainwindow.h"
|
||||
|
||||
#include <debugger/debuggeruiswitcher.h>
|
||||
|
||||
#include "components/objectpropertiesview.h"
|
||||
#include "components/objecttree.h"
|
||||
@@ -52,7 +55,6 @@
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
||||
#include <texteditor/itexteditor.h>
|
||||
|
||||
@@ -66,6 +68,8 @@
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QtPlugin>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <QtGui/qtoolbutton.h>
|
||||
@@ -80,9 +84,9 @@
|
||||
|
||||
#include <QtNetwork/QHostAddress>
|
||||
|
||||
using namespace Qml;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace Qml {
|
||||
|
||||
class EngineSpinBox : public QSpinBox
|
||||
{
|
||||
@@ -107,6 +111,8 @@ private:
|
||||
QList<EngineInfo> m_engines;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
EngineSpinBox::EngineSpinBox(QWidget *parent)
|
||||
: QSpinBox(parent)
|
||||
{
|
||||
@@ -152,8 +158,8 @@ int EngineSpinBox::valueFromText(const QString &text) const
|
||||
}
|
||||
|
||||
|
||||
QmlInspectorMode::QmlInspectorMode(QObject *parent)
|
||||
: Core::BaseMode(parent),
|
||||
QmlInspector::QmlInspector(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_conn(0),
|
||||
m_client(0),
|
||||
m_engineQuery(0),
|
||||
@@ -161,17 +167,13 @@ QmlInspectorMode::QmlInspectorMode(QObject *parent)
|
||||
{
|
||||
m_watchTableModel = new WatchTableModel(0, this);
|
||||
|
||||
setWidget(createModeWindow());
|
||||
|
||||
setDisplayName(tr("QML Inspect"));
|
||||
setIcon(QIcon(":/qmlinspector/images/logo.png"));
|
||||
setId(QLatin1String("QML_INSPECT_MODE"));
|
||||
initWidgets();
|
||||
}
|
||||
|
||||
void QmlInspectorMode::connectToViewer()
|
||||
bool QmlInspector::connectToViewer()
|
||||
{
|
||||
if (m_conn && m_conn->state() != QAbstractSocket::UnconnectedState)
|
||||
return;
|
||||
return false;
|
||||
|
||||
delete m_client; m_client = 0;
|
||||
|
||||
@@ -183,17 +185,17 @@ void QmlInspectorMode::connectToViewer()
|
||||
ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject();
|
||||
if (!project) {
|
||||
emit statusMessage(tr("No active project, debugging canceled."));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
QmlProjectManager::QmlProjectRunConfiguration* config =
|
||||
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration*>(project->activeTarget()->activeRunConfiguration());
|
||||
if (!config) {
|
||||
emit statusMessage(tr("Cannot find project run configuration, debugging canceled."));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
QHostAddress host = QHostAddress::LocalHost;
|
||||
QString host = config->debugServerAddress();
|
||||
quint16 port = quint16(config->debugServerPort());
|
||||
|
||||
m_conn = new QmlDebugConnection(this);
|
||||
@@ -202,16 +204,21 @@ void QmlInspectorMode::connectToViewer()
|
||||
connect(m_conn, SIGNAL(error(QAbstractSocket::SocketError)),
|
||||
SLOT(connectionError()));
|
||||
|
||||
emit statusMessage(tr("[Inspector] set to connect to debug server %1:%2").arg(host.toString()).arg(port));
|
||||
emit statusMessage(tr("[Inspector] set to connect to debug server %1:%2").arg(host).arg(port));
|
||||
m_conn->connectToHost(host, port);
|
||||
// blocks until connected; if no connection is available, will fail immediately
|
||||
if (m_conn->waitForConnected())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QmlInspectorMode::disconnectFromViewer()
|
||||
void QmlInspector::disconnectFromViewer()
|
||||
{
|
||||
m_conn->disconnectFromHost();
|
||||
}
|
||||
|
||||
void QmlInspectorMode::connectionStateChanged()
|
||||
void QmlInspector::connectionStateChanged()
|
||||
{
|
||||
switch (m_conn->state()) {
|
||||
case QAbstractSocket::UnconnectedState:
|
||||
@@ -260,35 +267,27 @@ void QmlInspectorMode::connectionStateChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void QmlInspectorMode::connectionError()
|
||||
void QmlInspector::connectionError()
|
||||
{
|
||||
emit statusMessage(tr("[Inspector] error: (%1) %2", "%1=error code, %2=error message")
|
||||
.arg(m_conn->error()).arg(m_conn->errorString()));
|
||||
}
|
||||
|
||||
QToolButton *QmlInspectorMode::createToolButton(QAction *action)
|
||||
void QmlInspector::initWidgets()
|
||||
{
|
||||
QToolButton *button = new QToolButton;
|
||||
button->setDefaultAction(action);
|
||||
return button;
|
||||
}
|
||||
m_objectTreeWidget = new ObjectTree;
|
||||
m_propertiesWidget = new ObjectPropertiesView;
|
||||
m_watchTableView = new WatchTableView(m_watchTableModel);
|
||||
m_frameRateWidget = new CanvasFrameRate;
|
||||
m_expressionWidget = new ExpressionQueryWidget(ExpressionQueryWidget::ShellMode);
|
||||
|
||||
QWidget *QmlInspectorMode::createMainView()
|
||||
{
|
||||
initWidgets();
|
||||
m_engineSpinBox = new EngineSpinBox;
|
||||
m_engineSpinBox->setEnabled(false);
|
||||
connect(m_engineSpinBox, SIGNAL(valueChanged(int)),
|
||||
SLOT(queryEngineContext(int)));
|
||||
|
||||
Utils::FancyMainWindow *mainWindow = new Utils::FancyMainWindow;
|
||||
mainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
|
||||
mainWindow->setDocumentMode(true);
|
||||
|
||||
QBoxLayout *editorHolderLayout = new QVBoxLayout;
|
||||
editorHolderLayout->setMargin(0);
|
||||
editorHolderLayout->setSpacing(0);
|
||||
|
||||
QWidget *editorAndFindWidget = new QWidget;
|
||||
editorAndFindWidget->setLayout(editorHolderLayout);
|
||||
editorHolderLayout->addWidget(new Core::EditorManagerPlaceHolder(this));
|
||||
editorHolderLayout->addWidget(new Core::FindToolBarPlaceHolder(editorAndFindWidget));
|
||||
// FancyMainWindow uses widgets' window titles for tab labels
|
||||
m_frameRateWidget->setWindowTitle(tr("Frame rate"));
|
||||
|
||||
Utils::StyledBar *treeOptionBar = new Utils::StyledBar;
|
||||
QHBoxLayout *treeOptionBarLayout = new QHBoxLayout(treeOptionBar);
|
||||
@@ -298,121 +297,13 @@ QWidget *QmlInspectorMode::createMainView()
|
||||
treeOptionBarLayout->addWidget(m_engineSpinBox);
|
||||
|
||||
QWidget *treeWindow = new QWidget;
|
||||
treeWindow->setWindowTitle(tr("Object Tree"));
|
||||
QVBoxLayout *treeWindowLayout = new QVBoxLayout(treeWindow);
|
||||
treeWindowLayout->setMargin(0);
|
||||
treeWindowLayout->setSpacing(0);
|
||||
treeWindowLayout->addWidget(treeOptionBar);
|
||||
treeWindowLayout->addWidget(m_objectTreeWidget);
|
||||
|
||||
Core::MiniSplitter *documentAndTree = new Core::MiniSplitter;
|
||||
documentAndTree->addWidget(editorAndFindWidget);
|
||||
documentAndTree->addWidget(new Core::RightPanePlaceHolder(this));
|
||||
documentAndTree->addWidget(treeWindow);
|
||||
documentAndTree->setStretchFactor(0, 2);
|
||||
documentAndTree->setStretchFactor(1, 0);
|
||||
documentAndTree->setStretchFactor(2, 0);
|
||||
|
||||
Utils::StyledBar *configBar = new Utils::StyledBar;
|
||||
configBar->setProperty("topBorder", true);
|
||||
|
||||
QHBoxLayout *configBarLayout = new QHBoxLayout(configBar);
|
||||
configBarLayout->setMargin(0);
|
||||
configBarLayout->setSpacing(5);
|
||||
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
Core::ActionManager *am = core->actionManager();
|
||||
configBarLayout->addWidget(createToolButton(am->command(ProjectExplorer::Constants::DEBUG)->action()));
|
||||
configBarLayout->addWidget(createToolButton(am->command(ProjectExplorer::Constants::STOP)->action()));
|
||||
|
||||
configBarLayout->addStretch();
|
||||
|
||||
QWidget *widgetAboveTabs = new QWidget;
|
||||
QVBoxLayout *widgetAboveTabsLayout = new QVBoxLayout(widgetAboveTabs);
|
||||
widgetAboveTabsLayout->setMargin(0);
|
||||
widgetAboveTabsLayout->setSpacing(0);
|
||||
widgetAboveTabsLayout->addWidget(documentAndTree);
|
||||
widgetAboveTabsLayout->addWidget(configBar);
|
||||
|
||||
Core::MiniSplitter *mainSplitter = new Core::MiniSplitter(Qt::Vertical);
|
||||
mainSplitter->addWidget(widgetAboveTabs);
|
||||
mainSplitter->addWidget(createBottomWindow());
|
||||
mainSplitter->setStretchFactor(0, 3);
|
||||
mainSplitter->setStretchFactor(1, 1);
|
||||
|
||||
QWidget *centralWidget = new QWidget;
|
||||
QVBoxLayout *centralLayout = new QVBoxLayout(centralWidget);
|
||||
centralLayout->setMargin(0);
|
||||
centralLayout->setSpacing(0);
|
||||
centralLayout->addWidget(mainSplitter);
|
||||
|
||||
mainWindow->setCentralWidget(centralWidget);
|
||||
|
||||
return mainWindow;
|
||||
}
|
||||
|
||||
QWidget *QmlInspectorMode::createBottomWindow()
|
||||
{
|
||||
Utils::FancyMainWindow *win = new Utils::FancyMainWindow;
|
||||
win->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
|
||||
win->setDocumentMode(true);
|
||||
win->setTrackingEnabled(true);
|
||||
|
||||
Core::MiniSplitter *leftSplitter = new Core::MiniSplitter(Qt::Vertical);
|
||||
leftSplitter->addWidget(m_propertiesWidget);
|
||||
leftSplitter->addWidget(m_expressionWidget);
|
||||
leftSplitter->setStretchFactor(0, 2);
|
||||
leftSplitter->setStretchFactor(1, 1);
|
||||
|
||||
Core::MiniSplitter *propSplitter = new Core::MiniSplitter(Qt::Horizontal);
|
||||
propSplitter->addWidget(leftSplitter);
|
||||
propSplitter->addWidget(m_watchTableView);
|
||||
propSplitter->setStretchFactor(0, 2);
|
||||
propSplitter->setStretchFactor(1, 1);
|
||||
propSplitter->setWindowTitle(tr("Properties and Watchers"));
|
||||
|
||||
QDockWidget *propertiesDock = win->addDockForWidget(propSplitter);
|
||||
win->addDockWidget(Qt::TopDockWidgetArea, propertiesDock);
|
||||
|
||||
QDockWidget *frameRateDock = win->addDockForWidget(m_frameRateWidget);
|
||||
win->addDockWidget(Qt::TopDockWidgetArea, frameRateDock);
|
||||
|
||||
// stack the dock widgets as tabs
|
||||
win->tabifyDockWidget(frameRateDock, propertiesDock);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
QWidget *QmlInspectorMode::createModeWindow()
|
||||
{
|
||||
// right-side window with editor, output etc.
|
||||
Core::MiniSplitter *mainWindowSplitter = new Core::MiniSplitter;
|
||||
mainWindowSplitter->addWidget(createMainView());
|
||||
mainWindowSplitter->addWidget(new Core::OutputPanePlaceHolder(this, mainWindowSplitter));
|
||||
mainWindowSplitter->setStretchFactor(0, 10);
|
||||
mainWindowSplitter->setStretchFactor(1, 0);
|
||||
mainWindowSplitter->setOrientation(Qt::Vertical);
|
||||
|
||||
// navigation + right-side window
|
||||
Core::MiniSplitter *splitter = new Core::MiniSplitter;
|
||||
splitter->addWidget(new Core::NavigationWidgetPlaceHolder(this));
|
||||
splitter->addWidget(mainWindowSplitter);
|
||||
splitter->setStretchFactor(0, 0);
|
||||
splitter->setStretchFactor(1, 1);
|
||||
return splitter;
|
||||
}
|
||||
|
||||
void QmlInspectorMode::initWidgets()
|
||||
{
|
||||
m_objectTreeWidget = new ObjectTree;
|
||||
m_propertiesWidget = new ObjectPropertiesView;
|
||||
m_watchTableView = new WatchTableView(m_watchTableModel);
|
||||
m_frameRateWidget = new CanvasFrameRate;
|
||||
m_expressionWidget = new ExpressionQueryWidget(ExpressionQueryWidget::ShellMode);
|
||||
|
||||
// FancyMainWindow uses widgets' window titles for tab labels
|
||||
m_objectTreeWidget->setWindowTitle(tr("Object Tree"));
|
||||
m_frameRateWidget->setWindowTitle(tr("Frame rate"));
|
||||
|
||||
m_watchTableView->setModel(m_watchTableModel);
|
||||
WatchTableHeaderView *header = new WatchTableHeaderView(m_watchTableModel);
|
||||
m_watchTableView->setHorizontalHeader(header);
|
||||
@@ -441,13 +332,59 @@ void QmlInspectorMode::initWidgets()
|
||||
connect(m_objectTreeWidget, SIGNAL(currentObjectChanged(QmlDebugObjectReference)),
|
||||
m_expressionWidget, SLOT(setCurrentObject(QmlDebugObjectReference)));
|
||||
|
||||
m_engineSpinBox = new EngineSpinBox;
|
||||
m_engineSpinBox->setEnabled(false);
|
||||
connect(m_engineSpinBox, SIGNAL(valueChanged(int)),
|
||||
SLOT(queryEngineContext(int)));
|
||||
|
||||
Core::MiniSplitter *leftSplitter = new Core::MiniSplitter(Qt::Vertical);
|
||||
leftSplitter->addWidget(m_propertiesWidget);
|
||||
leftSplitter->addWidget(m_expressionWidget);
|
||||
leftSplitter->setStretchFactor(0, 2);
|
||||
leftSplitter->setStretchFactor(1, 1);
|
||||
|
||||
Core::MiniSplitter *propSplitter = new Core::MiniSplitter(Qt::Horizontal);
|
||||
propSplitter->addWidget(leftSplitter);
|
||||
propSplitter->addWidget(m_watchTableView);
|
||||
propSplitter->setStretchFactor(0, 2);
|
||||
propSplitter->setStretchFactor(1, 1);
|
||||
propSplitter->setWindowTitle(tr("Properties and Watchers"));
|
||||
|
||||
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);
|
||||
m_dockWidgets << m_objectTreeDock << m_frameRateDock << m_propertyWatcherDock;
|
||||
}
|
||||
|
||||
void QmlInspectorMode::reloadEngines()
|
||||
void QmlInspector::setSimpleDockWidgetArrangement()
|
||||
{
|
||||
Debugger::DebuggerMainWindow *mainWindow = Debugger::DebuggerUISwitcher::instance()->mainWindow();
|
||||
|
||||
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);
|
||||
mainWindow->setTrackingEnabled(true);
|
||||
}
|
||||
|
||||
void QmlInspector::reloadEngines()
|
||||
{
|
||||
if (m_engineQuery) {
|
||||
emit statusMessage("[Inspector] Waiting for response to previous engine query");
|
||||
@@ -464,7 +401,7 @@ void QmlInspectorMode::reloadEngines()
|
||||
this, SLOT(enginesChanged()));
|
||||
}
|
||||
|
||||
void QmlInspectorMode::enginesChanged()
|
||||
void QmlInspector::enginesChanged()
|
||||
{
|
||||
m_engineSpinBox->clearEngines();
|
||||
|
||||
@@ -485,7 +422,7 @@ void QmlInspectorMode::enginesChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void QmlInspectorMode::queryEngineContext(int id)
|
||||
void QmlInspector::queryEngineContext(int id)
|
||||
{
|
||||
if (id < 0)
|
||||
return;
|
||||
@@ -503,7 +440,7 @@ void QmlInspectorMode::queryEngineContext(int id)
|
||||
this, SLOT(contextChanged()));
|
||||
}
|
||||
|
||||
void QmlInspectorMode::contextChanged()
|
||||
void QmlInspector::contextChanged()
|
||||
{
|
||||
//dump(m_contextQuery->rootContext(), 0);
|
||||
|
||||
@@ -513,7 +450,7 @@ void QmlInspectorMode::contextChanged()
|
||||
delete m_contextQuery; m_contextQuery = 0;
|
||||
}
|
||||
|
||||
void QmlInspectorMode::treeObjectActivated(const QmlDebugObjectReference &obj)
|
||||
void QmlInspector::treeObjectActivated(const QmlDebugObjectReference &obj)
|
||||
{
|
||||
QmlDebugFileReference source = obj.source();
|
||||
QString fileName = source.url().toLocalFile();
|
||||
@@ -531,7 +468,4 @@ void QmlInspectorMode::treeObjectActivated(const QmlDebugObjectReference &obj)
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qmlinspectormode.moc"
|
||||
|
||||
#include "qmlinspector.moc"
|
||||
@@ -26,28 +26,92 @@
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
#ifndef QMLINSPECTOR_H
|
||||
#define QMLINSPECTOR_H
|
||||
#ifndef QMLINSPECTORMODE_H
|
||||
#define QMLINSPECTORMODE_H
|
||||
|
||||
#include <QString>
|
||||
#include "qmlinspector_global.h"
|
||||
#include <coreplugin/basemode.h>
|
||||
|
||||
namespace QmlInspector {
|
||||
namespace Constants {
|
||||
const char * const RUN = "QmlInspector.Run";
|
||||
const char * const STOP = "QmlInspector.Stop";
|
||||
#include <QtGui/QAction>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
const char * const C_INSPECTOR = "QmlInspector";
|
||||
};
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class StartParameters
|
||||
{
|
||||
public:
|
||||
StartParameters() : port(0) {}
|
||||
~StartParameters() {}
|
||||
class QDockWidget;
|
||||
class QToolButton;
|
||||
class QLineEdit;
|
||||
class QSpinBox;
|
||||
class QLabel;
|
||||
|
||||
class QmlEngineDebug;
|
||||
class QmlDebugConnection;
|
||||
class QmlDebugEnginesQuery;
|
||||
class QmlDebugRootContextQuery;
|
||||
class QmlDebugObjectReference;
|
||||
class ObjectTree;
|
||||
class WatchTableModel;
|
||||
class WatchTableView;
|
||||
class ObjectPropertiesView;
|
||||
class CanvasFrameRate;
|
||||
class ExpressionQueryWidget;
|
||||
|
||||
|
||||
namespace Qml {
|
||||
class EngineSpinBox;
|
||||
|
||||
class QMLINSPECTOR_EXPORT QmlInspector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlInspector(QObject *parent = 0);
|
||||
|
||||
bool connectToViewer(); // using host, port from widgets
|
||||
|
||||
signals:
|
||||
void statusMessage(const QString &text);
|
||||
|
||||
public slots:
|
||||
void disconnectFromViewer();
|
||||
void setSimpleDockWidgetArrangement();
|
||||
|
||||
private slots:
|
||||
void connectionStateChanged();
|
||||
void connectionError();
|
||||
void reloadEngines();
|
||||
void enginesChanged();
|
||||
void queryEngineContext(int);
|
||||
void contextChanged();
|
||||
void treeObjectActivated(const QmlDebugObjectReference &obj);
|
||||
|
||||
private:
|
||||
|
||||
void initWidgets();
|
||||
|
||||
QmlDebugConnection *m_conn;
|
||||
QmlEngineDebug *m_client;
|
||||
|
||||
QmlDebugEnginesQuery *m_engineQuery;
|
||||
QmlDebugRootContextQuery *m_contextQuery;
|
||||
|
||||
ObjectTree *m_objectTreeWidget;
|
||||
ObjectPropertiesView *m_propertiesWidget;
|
||||
WatchTableModel *m_watchTableModel;
|
||||
WatchTableView *m_watchTableView;
|
||||
CanvasFrameRate *m_frameRateWidget;
|
||||
ExpressionQueryWidget *m_expressionWidget;
|
||||
|
||||
EngineSpinBox *m_engineSpinBox;
|
||||
|
||||
QDockWidget *m_objectTreeDock;
|
||||
QDockWidget *m_frameRateDock;
|
||||
QDockWidget *m_propertyWatcherDock;
|
||||
QList<QDockWidget*> m_dockWidgets;
|
||||
|
||||
QString address;
|
||||
quint16 port;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,13 +6,16 @@ DEPENDPATH += .
|
||||
|
||||
include(components/qmldebugger.pri)
|
||||
|
||||
DEFINES += QMLINSPECTOR_LIBRARY
|
||||
|
||||
HEADERS += qmlinspectorplugin.h \
|
||||
qmlinspectorconstants.h \
|
||||
qmlinspector.h \
|
||||
qmlinspectormode.h \
|
||||
inspectoroutputpane.h
|
||||
inspectoroutputpane.h \
|
||||
qmlinspector_global.h
|
||||
|
||||
SOURCES += qmlinspectorplugin.cpp \
|
||||
qmlinspectormode.cpp \
|
||||
qmlinspector.cpp \
|
||||
inspectoroutputpane.cpp
|
||||
|
||||
OTHER_FILES += QmlInspector.pluginspec
|
||||
@@ -23,4 +26,4 @@ include(../../plugins/projectexplorer/projectexplorer.pri)
|
||||
include(../../plugins/qmlprojectmanager/qmlprojectmanager.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../plugins/texteditor/texteditor.pri)
|
||||
|
||||
include(../../plugins/debugger/debugger.pri)
|
||||
|
||||
40
src/plugins/qmlinspector/qmlinspector_global.h
Normal file
40
src/plugins/qmlinspector/qmlinspector_global.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
**************************************************************************/
|
||||
#ifndef QMLINSPECTOR_GLOBAL_H
|
||||
#define QMLINSPECTOR_GLOBAL_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if defined(QMLINSPECTOR_LIBRARY)
|
||||
# define QMLINSPECTOR_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define QMLINSPECTOR_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // QMLINSPECTOR_GLOBAL_H
|
||||
54
src/plugins/qmlinspector/qmlinspectorconstants.h
Normal file
54
src/plugins/qmlinspector/qmlinspectorconstants.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
**************************************************************************/
|
||||
#ifndef QMLINSPECTORCONSTANTS_H
|
||||
#define QMLINSPECTORCONSTANTS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace Qml {
|
||||
namespace Constants {
|
||||
const char * const RUN = "QmlInspector.Run";
|
||||
const char * const STOP = "QmlInspector.Stop";
|
||||
|
||||
const char * const C_INSPECTOR = "QmlInspector";
|
||||
const char * const LANG_QML = "QML";
|
||||
};
|
||||
|
||||
class StartParameters
|
||||
{
|
||||
public:
|
||||
StartParameters() : port(0) {}
|
||||
~StartParameters() {}
|
||||
|
||||
QString address;
|
||||
quint16 port;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,106 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
**************************************************************************/
|
||||
#ifndef QMLINSPECTORMODE_H
|
||||
#define QMLINSPECTORMODE_H
|
||||
|
||||
#include <coreplugin/basemode.h>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QToolButton;
|
||||
class QLineEdit;
|
||||
class QSpinBox;
|
||||
class QLabel;
|
||||
|
||||
class QmlEngineDebug;
|
||||
class QmlDebugConnection;
|
||||
class QmlDebugEnginesQuery;
|
||||
class QmlDebugRootContextQuery;
|
||||
class QmlDebugObjectReference;
|
||||
class ObjectTree;
|
||||
class WatchTableModel;
|
||||
class WatchTableView;
|
||||
class ObjectPropertiesView;
|
||||
class CanvasFrameRate;
|
||||
class ExpressionQueryWidget;
|
||||
class EngineSpinBox;
|
||||
|
||||
|
||||
class QmlInspectorMode : public Core::BaseMode
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlInspectorMode(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void statusMessage(const QString &text);
|
||||
|
||||
public slots:
|
||||
void connectToViewer(); // using host, port from widgets
|
||||
void disconnectFromViewer();
|
||||
|
||||
private slots:
|
||||
void connectionStateChanged();
|
||||
void connectionError();
|
||||
void reloadEngines();
|
||||
void enginesChanged();
|
||||
void queryEngineContext(int);
|
||||
void contextChanged();
|
||||
void treeObjectActivated(const QmlDebugObjectReference &obj);
|
||||
|
||||
private:
|
||||
QWidget *createModeWindow();
|
||||
QWidget *createMainView();
|
||||
void initWidgets();
|
||||
QWidget *createBottomWindow();
|
||||
QToolButton *createToolButton(QAction *action);
|
||||
|
||||
QmlDebugConnection *m_conn;
|
||||
QmlEngineDebug *m_client;
|
||||
|
||||
QmlDebugEnginesQuery *m_engineQuery;
|
||||
QmlDebugRootContextQuery *m_contextQuery;
|
||||
|
||||
ObjectTree *m_objectTreeWidget;
|
||||
ObjectPropertiesView *m_propertiesWidget;
|
||||
WatchTableModel *m_watchTableModel;
|
||||
WatchTableView *m_watchTableView;
|
||||
CanvasFrameRate *m_frameRateWidget;
|
||||
ExpressionQueryWidget *m_expressionWidget;
|
||||
|
||||
EngineSpinBox *m_engineSpinBox;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
@@ -26,16 +26,25 @@
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
#include "qmlinspectorconstants.h"
|
||||
#include "qmlinspector.h"
|
||||
#include "qmlinspectormode.h"
|
||||
#include "inspectoroutputpane.h"
|
||||
#include "qmlinspectorplugin.h"
|
||||
|
||||
#include <debugger/debuggeruiswitcher.h>
|
||||
#include <debugger/debuggerconstants.h>
|
||||
|
||||
#include <qmlprojectmanager/qmlproject.h>
|
||||
#include <qmljseditor/qmljseditorconstants.h>
|
||||
|
||||
#include <private/qmldebug_p.h>
|
||||
#include <private/qmldebugclient_p.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
@@ -44,19 +53,34 @@
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QtPlugin>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QToolButton>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qml;
|
||||
|
||||
static QToolButton *createToolButton(QAction *action)
|
||||
{
|
||||
QToolButton *button = new QToolButton;
|
||||
button->setDefaultAction(action);
|
||||
return button;
|
||||
}
|
||||
|
||||
QmlInspectorPlugin::QmlInspectorPlugin()
|
||||
: m_inspectMode(0)
|
||||
: m_inspector(0), m_connectionTimer(new QTimer(this)),
|
||||
m_connectionAttempts(0)
|
||||
{
|
||||
m_connectionTimer->setInterval(75);
|
||||
}
|
||||
|
||||
QmlInspectorPlugin::~QmlInspectorPlugin()
|
||||
@@ -65,13 +89,13 @@ QmlInspectorPlugin::~QmlInspectorPlugin()
|
||||
|
||||
void QmlInspectorPlugin::shutdown()
|
||||
{
|
||||
removeObject(m_inspectMode);
|
||||
delete m_inspectMode;
|
||||
m_inspectMode = 0;
|
||||
|
||||
removeObject(m_outputPane);
|
||||
delete m_outputPane;
|
||||
m_outputPane = 0;
|
||||
|
||||
removeObject(m_inspector);
|
||||
delete m_inspector;
|
||||
m_inspector = 0;
|
||||
}
|
||||
|
||||
bool QmlInspectorPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
@@ -79,42 +103,100 @@ bool QmlInspectorPlugin::initialize(const QStringList &arguments, QString *error
|
||||
Q_UNUSED(arguments);
|
||||
Q_UNUSED(errorString);
|
||||
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
Core::UniqueIDManager *uidm = core->uniqueIDManager();
|
||||
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
||||
SLOT(prepareDebugger(Core::IMode*)));
|
||||
|
||||
QList<int> context;
|
||||
context.append(uidm->uniqueIdentifier(QmlInspector::Constants::C_INSPECTOR));
|
||||
context.append(uidm->uniqueIdentifier(Core::Constants::C_EDITORMANAGER));
|
||||
context.append(uidm->uniqueIdentifier(Core::Constants::C_NAVIGATION_PANE));
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
|
||||
uiSwitcher->addLanguage(Qml::Constants::LANG_QML);
|
||||
|
||||
m_inspectMode = new QmlInspectorMode(this);
|
||||
m_inspectMode->setContext(context);
|
||||
addObject(m_inspectMode);
|
||||
m_inspector = new QmlInspector;
|
||||
addObject(m_inspector);
|
||||
|
||||
connect(m_connectionTimer, SIGNAL(timeout()), SLOT(pollInspector()));
|
||||
|
||||
m_outputPane = new InspectorOutputPane;
|
||||
addObject(m_outputPane);
|
||||
|
||||
connect(m_inspectMode, SIGNAL(statusMessage(QString)),
|
||||
connect(m_inspector, SIGNAL(statusMessage(QString)),
|
||||
m_outputPane, SLOT(addInspectorStatus(QString)));
|
||||
|
||||
connect(core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
|
||||
SLOT(currentModeChanged(Core::IMode*)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QmlInspectorPlugin::extensionsInitialized()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
|
||||
//connect(uiSwitcher, SIGNAL(languageChanged(QString)), SLOT(activateDebugger(QString)));
|
||||
connect(uiSwitcher, SIGNAL(dockArranged(QString)), SLOT(setDockWidgetArrangement(QString)));
|
||||
|
||||
ProjectExplorer::ProjectExplorerPlugin *pex = ProjectExplorer::ProjectExplorerPlugin::instance();
|
||||
if (pex) {
|
||||
connect(pex, SIGNAL(aboutToExecuteProject(ProjectExplorer::Project*)),
|
||||
SLOT(activateDebuggerForProject(ProjectExplorer::Project*)));
|
||||
}
|
||||
|
||||
QWidget *configBar = new QWidget;
|
||||
configBar->setProperty("topBorder", true);
|
||||
|
||||
QHBoxLayout *configBarLayout = new QHBoxLayout(configBar);
|
||||
configBarLayout->setMargin(0);
|
||||
configBarLayout->setSpacing(5);
|
||||
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
Core::ActionManager *am = core->actionManager();
|
||||
configBarLayout->addWidget(createToolButton(am->command(ProjectExplorer::Constants::DEBUG)->action()));
|
||||
configBarLayout->addWidget(createToolButton(am->command(ProjectExplorer::Constants::STOP)->action()));
|
||||
|
||||
configBarLayout->addStretch();
|
||||
|
||||
uiSwitcher->setToolbar(Qml::Constants::LANG_QML, configBar);
|
||||
}
|
||||
|
||||
void QmlInspectorPlugin::currentModeChanged(Core::IMode *mode)
|
||||
void QmlInspectorPlugin::activateDebugger(const QString &langName)
|
||||
{
|
||||
if (mode == m_inspectMode)
|
||||
m_inspectMode->connectToViewer();
|
||||
if (langName == Qml::Constants::LANG_QML) {
|
||||
m_inspector->connectToViewer();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlInspectorPlugin::activateDebuggerForProject(ProjectExplorer::Project *project)
|
||||
{
|
||||
QmlProjectManager::QmlProject *qmlproj = qobject_cast<QmlProjectManager::QmlProject*>(project);
|
||||
if (qmlproj)
|
||||
m_connectionTimer->start();
|
||||
|
||||
}
|
||||
void QmlInspectorPlugin::pollInspector()
|
||||
{
|
||||
++m_connectionAttempts;
|
||||
if (m_inspector->connectToViewer() || m_connectionAttempts == MaxConnectionAttempts) {
|
||||
m_connectionTimer->stop();
|
||||
m_connectionAttempts = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QmlInspectorPlugin::prepareDebugger(Core::IMode *mode)
|
||||
{
|
||||
if (mode->id() != Debugger::Constants::MODE_DEBUG)
|
||||
return;
|
||||
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
|
||||
if (editorManager->currentEditor() &&
|
||||
editorManager->currentEditor()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
|
||||
uiSwitcher->setActiveLanguage(Qml::Constants::LANG_QML);
|
||||
}
|
||||
}
|
||||
|
||||
void QmlInspectorPlugin::setDockWidgetArrangement(const QString &activeLanguage)
|
||||
{
|
||||
if (activeLanguage == Qml::Constants::LANG_QML || activeLanguage.isEmpty())
|
||||
m_inspector->setSimpleDockWidgetArrangement();
|
||||
}
|
||||
|
||||
|
||||
Q_EXPORT_PLUGIN(QmlInspectorPlugin)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
@@ -33,19 +33,24 @@
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
class QStringList;
|
||||
|
||||
class QmlInspectorMode;
|
||||
class InspectorOutputPane;
|
||||
namespace ProjectExplorer {
|
||||
class Project;
|
||||
}
|
||||
|
||||
namespace Core
|
||||
{
|
||||
namespace Core {
|
||||
class IMode;
|
||||
}
|
||||
|
||||
namespace Qml {
|
||||
class QmlInspector;
|
||||
class InspectorOutputPane;
|
||||
|
||||
const int MaxConnectionAttempts = 20;
|
||||
|
||||
class QmlInspectorPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -58,14 +63,23 @@ public:
|
||||
virtual void extensionsInitialized();
|
||||
virtual void shutdown();
|
||||
|
||||
public slots:
|
||||
void activateDebugger(const QString &langName);
|
||||
void activateDebuggerForProject(ProjectExplorer::Project *project);
|
||||
void setDockWidgetArrangement(const QString &activeLanguage);
|
||||
|
||||
private slots:
|
||||
void currentModeChanged(Core::IMode *mode);
|
||||
void pollInspector();
|
||||
void prepareDebugger(Core::IMode *mode);
|
||||
|
||||
private:
|
||||
QmlInspectorMode *m_inspectMode;
|
||||
QmlInspector *m_inspector;
|
||||
InspectorOutputPane *m_outputPane;
|
||||
QTimer *m_connectionTimer;
|
||||
int m_connectionAttempts;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user