Commit 2b8e5b53 authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlObserver: Fix navigation on Mac OS X

The QmlObserver relies on installing an event handler on the graphicsview
viewport, to get e.g. Mouse events.

QmlObserver on Mac OS X switches the viewport later on to a QGLViewPort, when
QmlObserver has already been set up ... Make QmlObserver aware of this by
listening to the ChildRemoved event that will be signalled in this case.

Task-number: QTCREATORBUG-2892
Reviewed-by: Lasse Holmstedt
parent 3564feac
......@@ -79,8 +79,10 @@ QDeclarativeViewObserver::QDeclarativeViewObserver(QDeclarativeView *view, QObje
data->subcomponentEditorTool = new SubcomponentEditorTool(this);
data->currentTool = data->selectionTool;
data->view->setMouseTracking(true);
data->view->viewport()->installEventFilter(this);
// to capture ChildRemoved event when viewport changes
data->view->installEventFilter(this);
data->setViewport(data->view->viewport());
data->debugService = QDeclarativeObserverService::instance();
connect(data->debugService, SIGNAL(designModeBehaviorChanged(bool)), SLOT(setDesignModeBehavior(bool)));
......@@ -137,6 +139,22 @@ void QDeclarativeViewObserverPrivate::_q_reloadView()
emit q->reloadRequested();
}
void QDeclarativeViewObserverPrivate::setViewport(QWidget *widget)
{
if (viewport.data() == widget)
return;
if (viewport) {
viewport->removeEventFilter(q);
}
viewport = widget;
if (viewport) {
// make sure we get mouse move events
viewport->setMouseTracking(true);
viewport->installEventFilter(q);
}
}
void QDeclarativeViewObserverPrivate::clearEditorItems()
{
clearHighlight();
......@@ -145,6 +163,17 @@ void QDeclarativeViewObserverPrivate::clearEditorItems()
bool QDeclarativeViewObserver::eventFilter(QObject *obj, QEvent *event)
{
if (obj == data->view) {
// Event from view
if (event->type() == QEvent::ChildRemoved) {
// Might mean that viewport has changed
if (data->view->viewport() != data->viewport.data())
data->setViewport(data->view->viewport());
}
return QObject::eventFilter(obj, event);
}
//Event from viewport
switch (event->type()) {
case QEvent::Leave: {
if (leaveEvent(event))
......
......@@ -66,6 +66,7 @@ public:
QDeclarativeView *view;
QDeclarativeViewObserver *q;
QDeclarativeObserverService *debugService;
QWeakPointer<QWidget> viewport;
QPointF cursorPos;
QList<QWeakPointer<QGraphicsObject> > currentSelection;
......@@ -88,6 +89,8 @@ public:
QmlToolbar *toolbar;
void setViewport(QWidget *widget);
void clearEditorItems();
void createToolbar();
void changeToSelectTool();
......
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