Commit 8d504e1a authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

QML Observer: Highlight selected items in Qt Creator on click

parent 64f668fe
...@@ -282,18 +282,24 @@ void SubcomponentEditorTool::contextDestroyed(QObject *contextToDestroy) ...@@ -282,18 +282,24 @@ void SubcomponentEditorTool::contextDestroyed(QObject *contextToDestroy)
m_mask->setVisible(false); m_mask->setVisible(false);
} }
void SubcomponentEditorTool::setContext(int contextIndex) QGraphicsObject *SubcomponentEditorTool::setContext(int contextIndex)
{ {
Q_ASSERT(contextIndex >= 0); Q_ASSERT(contextIndex >= 0);
// sometimes we have to delete the context while user was still clicking around, // sometimes we have to delete the context while user was still clicking around,
// so just bail out. // so just bail out.
if (contextIndex >= m_currentContext.size() -1) if (contextIndex >= m_currentContext.size() -1)
return; return 0;
while (m_currentContext.size() - 1 > contextIndex) { while (m_currentContext.size() - 1 > contextIndex) {
popContext(); popContext();
} }
return m_currentContext.top();
}
int SubcomponentEditorTool::contextIndex() const
{
return m_currentContext.size() - 1;
} }
......
...@@ -46,9 +46,8 @@ public: ...@@ -46,9 +46,8 @@ public:
void pushContext(QGraphicsObject *contextItem); void pushContext(QGraphicsObject *contextItem);
QGraphicsObject *popContext(); QGraphicsObject *popContext();
QGraphicsObject *currentRootItem() const; QGraphicsObject *currentRootItem() const;
QGraphicsObject *setContext(int contextIndex);
public slots: int contextIndex() const;
void setContext(int contextIndex);
signals: signals:
void exitContextRequested(); void exitContextRequested();
......
...@@ -114,7 +114,11 @@ QDeclarativeDesignView::~QDeclarativeDesignView() ...@@ -114,7 +114,11 @@ QDeclarativeDesignView::~QDeclarativeDesignView()
void QDeclarativeDesignView::setInspectorContext(int contextIndex) void QDeclarativeDesignView::setInspectorContext(int contextIndex)
{ {
data->subcomponentEditorTool->setContext(contextIndex); if (data->subcomponentEditorTool->contextIndex() != contextIndex) {
QGraphicsObject *object = data->subcomponentEditorTool->setContext(contextIndex);
if (object)
qmlDesignDebugServer()->setCurrentObjects(QList<QObject*>() << object);
}
} }
void QDeclarativeDesignViewPrivate::_q_reloadView() void QDeclarativeDesignViewPrivate::_q_reloadView()
...@@ -184,7 +188,7 @@ void QDeclarativeDesignView::mouseReleaseEvent(QMouseEvent *event) ...@@ -184,7 +188,7 @@ void QDeclarativeDesignView::mouseReleaseEvent(QMouseEvent *event)
data->cursorPos = event->pos(); data->cursorPos = event->pos();
data->currentTool->mouseReleaseEvent(event); data->currentTool->mouseReleaseEvent(event);
//qmlDesignDebugServer()->setCurrentObjects(AbstractFormEditorTool::toObjectList(selectedItems())); qmlDesignDebugServer()->setCurrentObjects(AbstractFormEditorTool::toObjectList(selectedItems()));
} }
void QDeclarativeDesignView::keyPressEvent(QKeyEvent *event) void QDeclarativeDesignView::keyPressEvent(QKeyEvent *event)
...@@ -357,6 +361,7 @@ void QDeclarativeDesignViewPrivate::setSelectedItems(QList<QGraphicsItem *> item ...@@ -357,6 +361,7 @@ void QDeclarativeDesignViewPrivate::setSelectedItems(QList<QGraphicsItem *> item
} }
} }
currentTool->updateSelectedItems(); currentTool->updateSelectedItems();
qmlDesignDebugServer()->setCurrentObjects(AbstractFormEditorTool::toObjectList(items));
} }
QList<QGraphicsItem *> QDeclarativeDesignViewPrivate::selectedItems() QList<QGraphicsItem *> QDeclarativeDesignViewPrivate::selectedItems()
......
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