Commit 3e919302 authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

Qml JS Debugger: Change context path from Creator's crumble path

parent 5f7969d0
......@@ -111,6 +111,7 @@ void SubcomponentEditorTool::animate()
m_animTimer->stop();
m_mask->setOpacity(0);
popContext();
emit contextPathChanged(m_path);
}
}
......@@ -235,6 +236,7 @@ void SubcomponentEditorTool::aboutToPopContext()
{
if (m_currentContext.size() > 2) {
popContext();
emit contextPathChanged(m_path);
} else {
m_animIncrement = -0.05f;
m_animTimer->start();
......@@ -302,6 +304,8 @@ QGraphicsObject *SubcomponentEditorTool::setContext(int contextIndex)
while (m_currentContext.size() - 1 > contextIndex) {
popContext();
}
emit contextPathChanged(m_path);
return m_currentContext.top();
}
......
......@@ -45,7 +45,7 @@ public:
void setCurrentItem(QGraphicsItem *contextObject);
void pushContext(QGraphicsObject *contextItem);
QGraphicsObject *popContext();
QGraphicsObject *currentRootItem() const;
QGraphicsObject *setContext(int contextIndex);
int contextIndex() const;
......@@ -66,6 +66,7 @@ private slots:
void refresh();
private:
QGraphicsObject *popContext();
void aboutToPopContext();
private:
......
......@@ -90,6 +90,8 @@ Q_SIGNALS:
// 1 < x < 16 = slowdown by some factor
void animationSpeedChangeRequested(qreal speedFactor);
void contextPathIndexChanged(int contextPathIndex);
protected:
virtual void messageReceived(const QByteArray &);
......
......@@ -107,6 +107,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_changeToMarqueeSelectTool())
Q_PRIVATE_SLOT(d_func(), void _q_changeToZoomTool())
Q_PRIVATE_SLOT(d_func(), void _q_changeToColorPickerTool())
Q_PRIVATE_SLOT(d_func(), void _q_changeContextPathIndex(int index))
inline QDeclarativeDesignViewPrivate *d_func() { return data.data(); }
QScopedPointer<QDeclarativeDesignViewPrivate> data;
......
......@@ -79,6 +79,10 @@ void QDeclarativeDesignDebugServer::messageReceived(const QByteArray &message)
m_stringIdForObjectId.insert(itemDebugId, itemIdString);
}
} else if (type == "SET_CONTEXT_PATH_IDX") {
int contextPathIndex;
ds >> contextPathIndex;
emit contextPathIndexChanged(contextPathIndex);
}
}
......
......@@ -94,7 +94,7 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
connect(qmlDesignDebugServer(),
SIGNAL(objectCreationRequested(QString,QObject*,QStringList,QString)),
SLOT(_q_createQmlObject(QString,QObject*,QStringList,QString)));
connect(qmlDesignDebugServer(), SIGNAL(contextPathIndexChanged(int)), SLOT(_q_changeContextPathIndex(int)));
connect(this, SIGNAL(statusChanged(QDeclarativeView::Status)), SLOT(_q_onStatusChanged(QDeclarativeView::Status)));
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), SIGNAL(selectedColorChanged(QColor)));
......@@ -513,6 +513,11 @@ void QDeclarativeDesignViewPrivate::_q_changeToColorPickerTool()
qmlDesignDebugServer()->setCurrentTool(Constants::ColorPickerMode);
}
void QDeclarativeDesignViewPrivate::_q_changeContextPathIndex(int index)
{
subcomponentEditorTool->setContext(index);
}
void QDeclarativeDesignView::changeAnimationSpeed(qreal slowdownFactor)
{
data->slowdownFactor = slowdownFactor;
......
......@@ -122,6 +122,7 @@ public:
void _q_changeToMarqueeSelectTool();
void _q_changeToZoomTool();
void _q_changeToColorPickerTool();
void _q_changeContextPathIndex(int index);
static QDeclarativeDesignViewPrivate *get(QDeclarativeDesignView *v) { return v->d_func(); }
};
......
......@@ -462,12 +462,18 @@ void ClientProxy::createQmlObject(const QString &qmlText, int parentDebugId,
m_designClient->createQmlObject(qmlText, parentDebugId, imports, filename);
}
void QmlJSInspector::Internal::ClientProxy::destroyQmlObject(int debugId)
void ClientProxy::destroyQmlObject(int debugId)
{
if (isDesignClientConnected())
m_designClient->destroyQmlObject(debugId);
}
void ClientProxy::setContextPathIndex(int contextIndex)
{
if (isDesignClientConnected())
m_designClient->setContextPathIndex(contextIndex);
}
bool ClientProxy::isDesignClientConnected() const
{
......
......@@ -108,6 +108,7 @@ public slots:
void createQmlObject(const QString &qmlText, int parentDebugId,
const QStringList &imports, const QString &filename = QString());
void destroyQmlObject(int debugId);
void setContextPathIndex(int contextIndex);
private slots:
void contextChanged();
......
......@@ -31,5 +31,10 @@ void ContextCrumblePath::updateContextPath(const QStringList &path)
}
}
bool ContextCrumblePath::isEmpty() const
{
return m_isEmpty;
}
} // namespace Internal
} // namespace QmlJSInspector
......@@ -13,6 +13,7 @@ class ContextCrumblePath : public Utils::CrumblePath
public:
ContextCrumblePath(QWidget *parent = 0);
virtual ~ContextCrumblePath();
bool isEmpty() const;
public slots:
void updateContextPath(const QStringList &path);
......
......@@ -167,6 +167,18 @@ void QmlJSDesignDebugClient::setObjectIdList(const QList<QDeclarativeDebugObject
sendMessage(message);
}
void QmlJSDesignDebugClient::setContextPathIndex(int contextPathIndex)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_CONTEXT_PATH_IDX")
<< contextPathIndex;
sendMessage(message);
}
void QmlJSDesignDebugClient::reloadViewer()
{
......
......@@ -75,6 +75,8 @@ public:
// ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's
void setObjectIdList(const QList<QDeclarativeDebugObjectReference> &objectRoots);
void setContextPathIndex(int contextPathIndex);
signals:
void currentObjectsChanged(const QList<int> &debugIds);
void selectedColorChanged(const QColor &color);
......
......@@ -635,6 +635,7 @@ void Inspector::createDockWidgets()
{
m_crumblePath = new ContextCrumblePath;
m_crumblePath->setWindowTitle("Context Path");
connect(m_crumblePath, SIGNAL(elementClicked(int)), SLOT(crumblePathElementClicked(int)));
Debugger::DebuggerUISwitcher *uiSwitcher = Debugger::DebuggerUISwitcher::instance();
m_crumblePathDock = uiSwitcher->createDockWidget(QmlJSInspector::Constants::LANG_QML,
m_crumblePath, Qt::BottomDockWidgetArea);
......@@ -643,6 +644,13 @@ void Inspector::createDockWidgets()
connect(m_clientProxy, SIGNAL(contextPathUpdated(QStringList)), m_crumblePath, SLOT(updateContextPath(QStringList)));
}
void Inspector::crumblePathElementClicked(int pathIndex)
{
if (m_clientProxy->isConnected() && !m_crumblePath->isEmpty()) {
m_clientProxy->setContextPathIndex(pathIndex);
}
}
bool Inspector::showExperimentalWarning()
{
return m_showExperimentalWarning;
......
......@@ -133,7 +133,7 @@ private slots:
void createPreviewForEditor(Core::IEditor *newEditor);
void disableLivePreview();
void crumblePathElementClicked(int);
private:
Debugger::DebuggerRunControl *createDebuggerRunControl(ProjectExplorer::RunConfiguration *runConfig,
const QString &executableFile = QString(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment