From e753993b14bee1dc631336a4f46416620858479a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 9 Jun 2011 10:52:10 +0200 Subject: QmlInspector: Initial support for QSGView based applications Currently only displays a rectangle highlighting the item below the mouse, but it's a start. Change-Id: I9946a923add4c53780546ac4bf138fe731508da2 --- .../qdeclarativeinspectorplugin.cpp | 12 +- .../qmldbg_inspector/qdeclarativeinspectorplugin.h | 2 +- .../qmldbg_inspector/qmldbg_inspector.pro | 12 +- .../qmltooling/qmldbg_inspector/sgabstracttool.cpp | 54 ++++++ .../qmltooling/qmldbg_inspector/sgabstracttool.h | 83 ++++++++++ .../qmldbg_inspector/sgselectiontool.cpp | 112 +++++++++++++ .../qmltooling/qmldbg_inspector/sgselectiontool.h | 83 ++++++++++ .../qmldbg_inspector/sgviewinspector.cpp | 183 +++++++++++++++++++++ .../qmltooling/qmldbg_inspector/sgviewinspector.h | 92 +++++++++++ 9 files changed, 625 insertions(+), 8 deletions(-) create mode 100644 src/plugins/qmltooling/qmldbg_inspector/sgabstracttool.cpp create mode 100644 src/plugins/qmltooling/qmldbg_inspector/sgabstracttool.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.cpp create mode 100644 src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.cpp create mode 100644 src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.h (limited to 'src/plugins/qmltooling') diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp index a266eb90b5..36ee1e835e 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp @@ -42,9 +42,11 @@ #include "qdeclarativeinspectorplugin.h" #include "qdeclarativeviewinspector_p.h" +#include "sgviewinspector.h" #include #include +#include QT_BEGIN_NAMESPACE @@ -61,13 +63,16 @@ QDeclarativeInspectorPlugin::~QDeclarativeInspectorPlugin() void QDeclarativeInspectorPlugin::activate() { QDeclarativeInspectorService *service = QDeclarativeInspectorService::instance(); - QList views = service->views(); + QList views = service->views(); if (views.isEmpty()) return; // TODO: Support multiple views - QDeclarativeView *view = service->views().at(0); - m_inspector = new QDeclarativeViewInspector(view, view); + QObject *firstView = views.first(); + if (QDeclarativeView *declarativeView = qobject_cast(firstView)) + m_inspector = new QDeclarativeViewInspector(declarativeView, declarativeView); + else if (QSGView *sgView = qobject_cast(firstView)) + m_inspector = new SGViewInspector(sgView, sgView); } void QDeclarativeInspectorPlugin::deactivate() @@ -78,4 +83,3 @@ void QDeclarativeInspectorPlugin::deactivate() Q_EXPORT_PLUGIN2(declarativeinspector, QDeclarativeInspectorPlugin) QT_END_NAMESPACE - diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h index 3e28643eff..af9c594f92 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h @@ -63,7 +63,7 @@ public: void deactivate(); private: - QPointer m_inspector; + QPointer m_inspector; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro index 385326a806..c60be1fc97 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro +++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro @@ -1,7 +1,7 @@ load(qt_module) TARGET = qmldbg_inspector -QT += declarative-private +QT += declarative-private core-private gui-private opengl-private load(qt_plugin) @@ -23,7 +23,10 @@ SOURCES += \ editor/zoomtool.cpp \ editor/colorpickertool.cpp \ editor/qmltoolbar.cpp \ - editor/toolbarcolorbox.cpp + editor/toolbarcolorbox.cpp \ + sgabstracttool.cpp \ + sgviewinspector.cpp \ + sgselectiontool.cpp HEADERS += \ qdeclarativeinspectorplugin.h \ @@ -43,7 +46,10 @@ HEADERS += \ editor/zoomtool_p.h \ editor/colorpickertool_p.h \ editor/qmltoolbar_p.h \ - editor/toolbarcolorbox_p.h + editor/toolbarcolorbox_p.h \ + sgabstracttool.h \ + sgviewinspector.h \ + sgselectiontool.h RESOURCES += editor/editor.qrc diff --git a/src/plugins/qmltooling/qmldbg_inspector/sgabstracttool.cpp b/src/plugins/qmltooling/qmldbg_inspector/sgabstracttool.cpp new file mode 100644 index 0000000000..4557831752 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/sgabstracttool.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "sgabstracttool.h" + +#include "sgviewinspector.h" + +QT_BEGIN_NAMESPACE + +SGAbstractTool::SGAbstractTool(SGViewInspector *inspector) : + QObject(inspector), + m_inspector(inspector) +{ +} + +QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_inspector/sgabstracttool.h b/src/plugins/qmltooling/qmldbg_inspector/sgabstracttool.h new file mode 100644 index 0000000000..016f8f32fc --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/sgabstracttool.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SGABSTRACTTOOL_H +#define SGABSTRACTTOOL_H + +#include + +QT_BEGIN_NAMESPACE + +class QMouseEvent; +class QKeyEvent; +class QWheelEvent; + +class SGViewInspector; + +class SGAbstractTool : public QObject +{ + Q_OBJECT + +public: + explicit SGAbstractTool(SGViewInspector *inspector); + + SGViewInspector *inspector() const { return m_inspector; } + + virtual void leaveEvent(QEvent *event) = 0; + + virtual void mousePressEvent(QMouseEvent *event) = 0; + virtual void mouseMoveEvent(QMouseEvent *event) = 0; + virtual void mouseReleaseEvent(QMouseEvent *event) = 0; + virtual void mouseDoubleClickEvent(QMouseEvent *event) = 0; + + virtual void hoverMoveEvent(QMouseEvent *event) = 0; + virtual void wheelEvent(QWheelEvent *event) = 0; + + virtual void keyPressEvent(QKeyEvent *event) = 0; + virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0; + +private: + SGViewInspector *m_inspector; +}; + +QT_END_NAMESPACE + +#endif // SGABSTRACTTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.cpp b/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.cpp new file mode 100644 index 0000000000..ec0a6ced9e --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "sgselectiontool.h" + +#include "sgviewinspector.h" + +#include +#include +#include +#include +#include + +/* + * Returns the first visible item at the given position, or 0 when no such + * child exists. + */ +static QSGItem *itemAt(QSGItem *item, const QPointF &pos, QSGItem *overlay) +{ + if (item == overlay) + return 0; + + if (!item->isVisible() || item->opacity() == 0.0) + return 0; + + if (item->flags() & QSGItem::ItemClipsChildrenToShape) { + if (!QRectF(0, 0, item->width(), item->height()).contains(pos)) + return 0; + } + + QList children = QSGItemPrivate::get(item)->paintOrderChildItems(); + for (int i = children.count() - 1; i >= 0; --i) { + QSGItem *child = children.at(i); + if (QSGItem *betterCandidate = itemAt(child, item->mapToItem(child, pos), overlay)) + return betterCandidate; + } + + if (!(item->flags() & QSGItem::ItemHasContents)) + return 0; + + if (!QRectF(0, 0, item->width(), item->height()).contains(pos)) + return 0; + + return item; +} + + +SGSelectionTool::SGSelectionTool(SGViewInspector *inspector) : + SGAbstractTool(inspector), + m_hoverHighlight(new QSGRectangle(inspector->overlay())) +{ + m_hoverHighlight->border()->setColor(QColor(64, 128, 255)); + m_hoverHighlight->setColor(Qt::transparent); +} + +void SGSelectionTool::leaveEvent(QEvent *) +{ + m_hoverHighlight->setVisible(false); +} + +void SGSelectionTool::hoverMoveEvent(QMouseEvent *event) +{ + QSGItem *root = inspector()->view()->rootItem(); + QPointF mappedPos = root->mapFromScene(event->pos()); + QSGItem *item = itemAt(root, mappedPos, inspector()->overlay()); + if (!item || item == root) { + m_hoverHighlight->setVisible(false); + return; + } + + m_hoverHighlight->setSize(QSizeF(item->width() - 1, item->height() - 1)); + m_hoverHighlight->setPos(root->mapFromItem(item->parentItem(), item->pos())); + m_hoverHighlight->setVisible(true); +} diff --git a/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.h b/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.h new file mode 100644 index 0000000000..4a64d50177 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SGSELECTIONTOOL_H +#define SGSELECTIONTOOL_H + +#include "sgabstracttool.h" + +#include + +QT_BEGIN_NAMESPACE + +class QSGRectangle; + +class SGSelectionTool : public SGAbstractTool +{ + Q_OBJECT +public: + explicit SGSelectionTool(SGViewInspector *inspector); + + void leaveEvent(QEvent *); + + void mousePressEvent(QMouseEvent *) {} + void mouseMoveEvent(QMouseEvent *) {} + void mouseReleaseEvent(QMouseEvent *) {} + void mouseDoubleClickEvent(QMouseEvent *) {} + + void hoverMoveEvent(QMouseEvent *); + void wheelEvent(QWheelEvent *) {} + + void keyPressEvent(QKeyEvent *) {} + void keyReleaseEvent(QKeyEvent *) {} + +signals: + +public slots: + +private: + QList m_highlightItems; + QSGRectangle *m_hoverHighlight; +}; + +QT_END_NAMESPACE + +#endif // SGSELECTIONTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.cpp new file mode 100644 index 0000000000..6cd5582074 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "sgviewinspector.h" + +#include "qdeclarativeinspectorprotocol.h" + +#include "sgabstracttool.h" +#include "sgselectiontool.h" + +#include +#include + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +SGViewInspector::SGViewInspector(QSGView *view, QObject *parent) : + QObject(parent), + m_view(view), + m_overlay(new QSGItem), + m_currentTool(0), + m_selectionTool(new SGSelectionTool(this)), + m_designMode(true) +{ + // Try to make sure the overlay is always on top + m_overlay->setZ(FLT_MAX); + + // Make sure mouse hover events are received + m_view->setMouseTracking(true); + + if (QSGItem *root = view->rootItem()) + m_overlay->setParentItem(root); + + view->installEventFilter(this); + m_currentTool = m_selectionTool; +} + +bool SGViewInspector::eventFilter(QObject *obj, QEvent *event) +{ + if (obj != m_view || !m_designMode) + return QObject::eventFilter(obj, event); + + switch (event->type()) { + case QEvent::Leave: + if (leaveEvent(event)) + return true; + break; + case QEvent::MouseButtonPress: + if (mousePressEvent(static_cast(event))) + return true; + break; + case QEvent::MouseMove: + if (mouseMoveEvent(static_cast(event))) + return true; + break; + case QEvent::MouseButtonRelease: + if (mouseReleaseEvent(static_cast(event))) + return true; + break; + case QEvent::KeyPress: + if (keyPressEvent(static_cast(event))) + return true; + break; + case QEvent::KeyRelease: + if (keyReleaseEvent(static_cast(event))) + return true; + break; + case QEvent::MouseButtonDblClick: + if (mouseDoubleClickEvent(static_cast(event))) + return true; + break; + case QEvent::Wheel: + if (wheelEvent(static_cast(event))) + return true; + break; + default: + break; + } + + return QObject::eventFilter(obj, event); +} + +bool SGViewInspector::leaveEvent(QEvent *event) +{ + m_currentTool->leaveEvent(event); + return true; +} + +bool SGViewInspector::mousePressEvent(QMouseEvent *event) +{ + m_currentTool->mousePressEvent(event); + return true; +} + +bool SGViewInspector::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons()) { + m_currentTool->mouseMoveEvent(event); + } else { + m_currentTool->hoverMoveEvent(event); + } + return true; +} + +bool SGViewInspector::mouseReleaseEvent(QMouseEvent *event) +{ + m_currentTool->mouseReleaseEvent(event); + return true; +} + +bool SGViewInspector::keyPressEvent(QKeyEvent *event) +{ + m_currentTool->keyPressEvent(event); + return true; +} + +bool SGViewInspector::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) { + default: + break; + } + + m_currentTool->keyReleaseEvent(event); + return true; +} + +bool SGViewInspector::mouseDoubleClickEvent(QMouseEvent *event) +{ + m_currentTool->mouseDoubleClickEvent(event); + return true; +} + +bool SGViewInspector::wheelEvent(QWheelEvent *event) +{ + m_currentTool->wheelEvent(event); + return true; +} + +QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.h new file mode 100644 index 0000000000..226230700d --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSGVIEWINSPECTOR_H +#define QSGVIEWINSPECTOR_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QMouseEvent; +class QKeyEvent; +class QWheelEvent; + +class QSGView; +class QSGItem; + +class SGAbstractTool; +class SGSelectionTool; + +class SGViewInspector : public QObject +{ + Q_OBJECT +public: + explicit SGViewInspector(QSGView *view, QObject *parent = 0); + + QSGView *view() const { return m_view; } + QSGItem *overlay() const { return m_overlay; } + + bool eventFilter(QObject *obj, QEvent *event); + +private: + bool leaveEvent(QEvent *); + bool mousePressEvent(QMouseEvent *event); + bool mouseMoveEvent(QMouseEvent *event); + bool mouseReleaseEvent(QMouseEvent *event); + bool keyPressEvent(QKeyEvent *event); + bool keyReleaseEvent(QKeyEvent *keyEvent); + bool mouseDoubleClickEvent(QMouseEvent *event); + bool wheelEvent(QWheelEvent *event); + + QSGView *m_view; + QSGItem *m_overlay; + SGAbstractTool *m_currentTool; + + SGSelectionTool *m_selectionTool; + + bool m_designMode; +}; + +QT_END_NAMESPACE + +#endif // QSGVIEWINSPECTOR_H -- cgit v1.2.3