Commit 5e9d19cd authored by Lasse Holmstedt's avatar Lasse Holmstedt

QML Observer: Enter context when context menu item is selected

Right-clicking on an item in qml observer presents a context menu as
before, but instead of just selecting the item, the user enters its
context if it's possible.
parent 657bb225
......@@ -29,6 +29,7 @@
#include "abstractformeditortool.h"
#include "qdeclarativedesignview.h"
#include "qdeclarativedesignview_p.h"
#include <QDeclarativeEngine>
......@@ -69,6 +70,11 @@ QList<QGraphicsItem*> AbstractFormEditorTool::items() const
return view()->selectedItems();
}
void AbstractFormEditorTool::enterContext(QGraphicsItem *itemToEnter)
{
view()->data->enterContext(itemToEnter);
}
bool AbstractFormEditorTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
{
QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList);
......
......@@ -76,6 +76,8 @@ public:
void updateSelectedItems();
QList<QGraphicsItem*> items() const;
void enterContext(QGraphicsItem *itemToEnter);
bool topItemIsMovable(const QList<QGraphicsItem*> &itemList);
bool topItemIsResizeHandle(const QList<QGraphicsItem*> &itemList);
bool topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList);
......
......@@ -209,11 +209,13 @@ void SelectionTool::contextMenuElementSelected()
if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
QPointF updatePt(0, 0);
QGraphicsItem *item = m_contextMenuItemList.at(itemListIndex);
m_singleSelectionManipulator.begin(updatePt);
m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection,
QList<QGraphicsItem*>() << m_contextMenuItemList.at(itemListIndex),
QList<QGraphicsItem*>() << item,
false);
m_singleSelectionManipulator.end(updatePt);
enterContext(item);
}
}
......
......@@ -115,6 +115,7 @@ private:
inline QDeclarativeDesignViewPrivate *d_func() { return data.data(); }
QScopedPointer<QDeclarativeDesignViewPrivate> data;
friend class QDeclarativeDesignViewPrivate;
friend class AbstractFormEditorTool;
};
......
......@@ -323,6 +323,7 @@ void QDeclarativeDesignView::mouseDoubleClickEvent(QMouseEvent *event)
}
}
void QDeclarativeDesignView::wheelEvent(QWheelEvent *event)
{
if (!data->designModeBehavior) {
......@@ -332,6 +333,16 @@ void QDeclarativeDesignView::wheelEvent(QWheelEvent *event)
data->currentTool->wheelEvent(event);
}
void QDeclarativeDesignViewPrivate::enterContext(QGraphicsItem *itemToEnter)
{
QGraphicsItem *itemUnderCurrentContext = itemToEnter;
if (itemUnderCurrentContext)
itemUnderCurrentContext = subcomponentEditorTool->firstChildOfContext(itemToEnter);
if (itemUnderCurrentContext)
subcomponentEditorTool->setCurrentItem(itemToEnter);
}
void QDeclarativeDesignView::setDesignModeBehavior(bool value)
{
emit designModeBehaviorChanged(value);
......
......@@ -114,6 +114,7 @@ public:
QGraphicsItem *currentRootItem() const;
void enterContext(QGraphicsItem *itemToEnter);
void _q_reloadView();
void _q_onStatusChanged(QDeclarativeView::Status status);
......
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