diff options
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_qtquick2')
9 files changed, 0 insertions, 1516 deletions
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp deleted file mode 100644 index 5af7a225fd..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "highlight.h" - -#include <QtCore/QTimer> -#include <QtGui/QPainter> -#include <QtGui/QStaticText> -#include <QtQuick/QQuickWindow> - -namespace QmlJSDebugger { -namespace QtQuick2 { - -Highlight::Highlight(QQuickItem *parent) : QQuickPaintedItem(parent) -{ - initRenderDetails(); -} - -Highlight::Highlight(QQuickItem *item, QQuickItem *parent) - : QQuickPaintedItem(parent) -{ - initRenderDetails(); - setItem(item); -} - -void Highlight::initRenderDetails() -{ - setRenderTarget(QQuickPaintedItem::FramebufferObject); - setPerformanceHint(QQuickPaintedItem::FastFBOResizing, true); -} - -void Highlight::setItem(QQuickItem *item) -{ - if (m_item) - m_item->disconnect(this); - - if (item) { - connect(item, SIGNAL(xChanged()), SLOT(adjust())); - connect(item, SIGNAL(yChanged()), SLOT(adjust())); - connect(item, SIGNAL(widthChanged()), SLOT(adjust())); - connect(item, SIGNAL(heightChanged()), SLOT(adjust())); - connect(item, SIGNAL(rotationChanged()), SLOT(adjust())); - connect(item, SIGNAL(transformOriginChanged(TransformOrigin)), - SLOT(adjust())); - } - QQuickWindow *view = item->window(); - QQuickItem * contentItem = view->contentItem(); - if (contentItem) { - connect(contentItem, SIGNAL(xChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(yChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(widthChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(heightChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(rotationChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(transformOriginChanged(TransformOrigin)), - SLOT(adjust())); - } - m_item = item; - setContentsSize(view->size()); - adjust(); -} - -void Highlight::adjust() -{ - if (!m_item) - return; - - bool success = false; - m_transform = m_item->itemTransform(0, &success); - if (!success) - m_transform = QTransform(); - - setSize(QSizeF(m_item->width(), m_item->height())); - qreal scaleFactor = 1; - QPointF originOffset = QPointF(0,0); - QQuickWindow *view = m_item->window(); - if (view->contentItem()) { - scaleFactor = view->contentItem()->scale(); - originOffset -= view->contentItem()->position(); - } - // The scale transform for the overlay needs to be cancelled - // as the Item's transform which will be applied to the painter - // takes care of it. - parentItem()->setScale(1/scaleFactor); - setPosition(originOffset); - update(); -} - - -void HoverHighlight::paint(QPainter *painter) -{ - if (!item()) - return; - - painter->save(); - painter->setTransform(transform()); - painter->setPen(QColor(108, 141, 221)); - painter->drawRect(QRect(0, 0, item()->width() - 1, item()->height() - 1)); - painter->restore(); -} - - -SelectionHighlight::SelectionHighlight(const QString &name, QQuickItem *item, QQuickItem *parent) - : Highlight(item, parent), - m_name(name), - m_nameDisplayActive(false) -{ -} - -void SelectionHighlight::paint(QPainter *painter) -{ - if (!item()) - return; - painter->save(); - painter->fillRect(QRectF(0,0,contentsSize().width(), contentsSize().height()), - QColor(0,0,0,127)); - painter->setTransform(transform()); - // Setting the composition mode such that the transparency will - // be erased as per the selected item. - painter->setCompositionMode(QPainter::CompositionMode_Clear); - painter->fillRect(0, 0, item()->width(), item()->height(), Qt::black); - painter->restore(); - - // Use the painter with the original transform and not with the - // item's transform for display of name. - if (!m_nameDisplayActive) - return; - - // Paint the text in gray background if display name is active.. - QRect textRect = painter->boundingRect(QRect(10, contentsSize().height() - 10 , - contentsSize().width() - 20, contentsSize().height()), - Qt::AlignCenter | Qt::ElideRight, m_name); - - qreal xPosition = m_displayPoint.x(); - if (xPosition + textRect.width() > contentsSize().width()) - xPosition = contentsSize().width() - textRect.width(); - if (xPosition < 0) { - xPosition = 0; - textRect.setWidth(contentsSize().width()); - } - qreal yPosition = m_displayPoint.y() - textRect.height() - 20; - if (yPosition < 50 ) - yPosition = 50; - - painter->fillRect(QRectF(xPosition - 5, yPosition - 5, - textRect.width() + 10, textRect.height() + 10), Qt::gray); - painter->drawRect(QRectF(xPosition - 5, yPosition - 5, - textRect.width() + 10, textRect.height() + 10)); - - painter->drawStaticText(xPosition, yPosition, QStaticText(m_name)); -} - -void SelectionHighlight::showName(const QPointF &displayPoint) -{ - m_displayPoint = displayPoint; - m_nameDisplayActive = true; - QTimer::singleShot(1500, this, SLOT(disableNameDisplay())); - update(); -} - -void SelectionHighlight::disableNameDisplay() -{ - m_nameDisplayActive = false; - update(); -} - -} // namespace QtQuick2 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h deleted file mode 100644 index 29d2f0d911..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef HIGHLIGHT_H -#define HIGHLIGHT_H - -#include <QtCore/QPointer> -#include <QtCore/QPointF> -#include <QtGui/QTransform> -#include <QtQuick/QQuickPaintedItem> - - -namespace QmlJSDebugger { -namespace QtQuick2 { - -class Highlight : public QQuickPaintedItem -{ - Q_OBJECT - -public: - Highlight(QQuickItem *parent); - Highlight(QQuickItem *item, QQuickItem *parent); - - void setItem(QQuickItem *item); - QQuickItem *item() {return m_item;} - -protected: - QTransform transform() {return m_transform;} - -private: - void initRenderDetails(); - -private slots: - void adjust(); - -private: - QPointer<QQuickItem> m_item; - QTransform m_transform; -}; - -/** - * A highlight suitable for indicating selection. - */ -class SelectionHighlight : public Highlight -{ - Q_OBJECT - -public: - SelectionHighlight(const QString &name, QQuickItem *item, QQuickItem *parent); - void paint(QPainter *painter); - void showName(const QPointF &displayPoint); - -private slots: - void disableNameDisplay(); - -private: - QPointF m_displayPoint; - QString m_name; - bool m_nameDisplayActive; -}; - -/** - * A highlight suitable for indicating hover. - */ -class HoverHighlight : public Highlight -{ -public: - HoverHighlight(QQuickItem *parent) - : Highlight(parent) - { - setZ(1); // hover highlight on top of selection highlight - } - - void paint(QPainter *painter); -}; - -} // namespace QtQuick2 -} // namespace QmlJSDebugger - -#endif // HIGHLIGHT_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/inspecttool.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/inspecttool.cpp deleted file mode 100644 index f86225fa0a..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick2/inspecttool.cpp +++ /dev/null @@ -1,422 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "inspecttool.h" - -#include "highlight.h" -#include "qquickviewinspector.h" - -#include <QtCore/QLineF> - -#include <QtGui/QMouseEvent> -#include <QtGui/QWheelEvent> -#include <QtGui/QTouchEvent> -#include <QtGui/QKeyEvent> -#include <QtGui/QGuiApplication> -#include <QtGui/QStyleHints> - -#include <QtQuick/QQuickView> -#include <QtQuick/QQuickItem> - -namespace QmlJSDebugger { -namespace QtQuick2 { - -InspectTool::InspectTool(QQuickViewInspector *inspector, QQuickView *view) : - AbstractTool(inspector), - m_originalSmooth(view->contentItem()->smooth()), - m_dragStarted(false), - m_pinchStarted(false), - m_didPressAndHold(false), - m_tapEvent(false), - m_contentItem(view->contentItem()), - m_originalPosition(view->contentItem()->position()), - m_smoothScaleFactor(Constants::ZoomSnapDelta), - m_minScale(0.125f), - m_maxScale(48.0f), - m_originalScale(view->contentItem()->scale()), - m_touchTimestamp(0), - m_hoverHighlight(new HoverHighlight(inspector->overlay())), - m_lastItem(0), - m_lastClickedItem(0) -{ - //Press and Hold Timer - m_pressAndHoldTimer.setSingleShot(true); - m_pressAndHoldTimer.setInterval(Constants::PressAndHoldTimeout); - connect(&m_pressAndHoldTimer, SIGNAL(timeout()), SLOT(zoomTo100())); - //Timer to display selected item's name - m_nameDisplayTimer.setSingleShot(true); - m_nameDisplayTimer.setInterval(QGuiApplication::styleHints()->mouseDoubleClickInterval()); - connect(&m_nameDisplayTimer, SIGNAL(timeout()), SLOT(showSelectedItemName())); - enable(true); -} - -InspectTool::~InspectTool() -{ - enable(false); -} - -void InspectTool::enable(bool enable) -{ - if (!enable) { - inspector()->setSelectedItems(QList<QQuickItem*>()); - // restoring the original states. - if (m_contentItem) { - m_contentItem->setScale(m_originalScale); - m_contentItem->setPosition(m_originalPosition); - m_contentItem->setSmooth(m_originalSmooth); - } - } else { - if (m_contentItem) { - m_originalSmooth = m_contentItem->smooth(); - m_originalScale = m_contentItem->scale(); - m_originalPosition = m_contentItem->position(); - m_contentItem->setSmooth(true); - } - } -} - -void InspectTool::leaveEvent(QEvent *) -{ - m_hoverHighlight->setVisible(false); -} - -void InspectTool::mousePressEvent(QMouseEvent *event) -{ - m_mousePosition = event->localPos(); - if (event->button() == Qt::LeftButton) { - m_pressAndHoldTimer.start(); - initializeDrag(event->localPos()); - } -} - -void InspectTool::mouseReleaseEvent(QMouseEvent *event) -{ - m_mousePosition = event->localPos(); - m_pressAndHoldTimer.stop(); - if (event->button() == Qt::LeftButton && !m_dragStarted) { - selectItem(); - m_hoverHighlight->setVisible(false); - } -} - -void InspectTool::mouseDoubleClickEvent(QMouseEvent *event) -{ - m_mousePosition = event->localPos(); - m_pressAndHoldTimer.stop(); - if (event->button() == Qt::LeftButton) { - selectNextItem(); - m_hoverHighlight->setVisible(false); - } -} - -void InspectTool::mouseMoveEvent(QMouseEvent *event) -{ - m_mousePosition = event->localPos(); - moveItem(event->buttons() & Qt::LeftButton); -} - -void InspectTool::hoverMoveEvent(QMouseEvent *event) -{ - m_mousePosition = event->localPos(); - m_pressAndHoldTimer.stop(); - QQuickItem *item = inspector()->topVisibleItemAt(event->pos()); - if (!item || item == m_lastClickedItem) { - m_hoverHighlight->setVisible(false); - } else { - m_hoverHighlight->setItem(item); - m_hoverHighlight->setVisible(true); - } -} - -#ifndef QT_NO_WHEELEVENT -void InspectTool::wheelEvent(QWheelEvent *event) -{ - if (event->orientation() != Qt::Vertical) - return; - - Qt::KeyboardModifier smoothZoomModifier = Qt::ControlModifier; - if (event->modifiers() & smoothZoomModifier) { - int numDegrees = event->delta() / 8; - qreal newScale = m_contentItem->scale() + m_smoothScaleFactor * (numDegrees / 15.0f); - scaleView(newScale / m_contentItem->scale(), m_mousePosition, m_mousePosition); - } else if (!event->modifiers()) { - if (event->delta() > 0) { - zoomIn(); - } else if (event->delta() < 0) { - zoomOut(); - } - } -} -#endif - -void InspectTool::keyReleaseEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Plus: - zoomIn(); - break; - case Qt::Key_Minus: - zoomOut(); - break; - case Qt::Key_1: - case Qt::Key_2: - case Qt::Key_3: - case Qt::Key_4: - case Qt::Key_5: - case Qt::Key_6: - case Qt::Key_7: - case Qt::Key_8: - case Qt::Key_9: { - qreal newScale = ((event->key() - Qt::Key_0) * 1.0f); - scaleView(newScale / m_contentItem->scale(), m_mousePosition, m_mousePosition); - break; - } - default: - break; - } -} - -void InspectTool::touchEvent(QTouchEvent *event) -{ - QList<QTouchEvent::TouchPoint> touchPoints = event->touchPoints(); - - switch (event->type()) { - case QEvent::TouchBegin: - if (touchPoints.count() == 1 && (event->touchPointStates() & Qt::TouchPointPressed)) { - if (!m_pressAndHoldTimer.isActive()) - m_pressAndHoldTimer.start(); - m_mousePosition = touchPoints.first().pos(); - initializeDrag(touchPoints.first().pos()); - m_tapEvent = true; - } else { - m_tapEvent = false; - } - break; - case QEvent::TouchUpdate: { - if (touchPoints.count() > 1) - m_tapEvent = false; - if ((touchPoints.count() == 1) - && (event->touchPointStates() & Qt::TouchPointMoved)) { - m_mousePosition = touchPoints.first().pos(); - moveItem(true); - } else if ((touchPoints.count() == 2) - && (!(event->touchPointStates() & Qt::TouchPointReleased))) { - // determine scale factor - const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first(); - const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last(); - - qreal touchScaleFactor = - QLineF(touchPoint0.pos(), touchPoint1.pos()).length() - / QLineF(touchPoint0.lastPos(), touchPoint1.lastPos()).length(); - - QPointF oldcenter = (touchPoint0.lastPos() + touchPoint1.lastPos()) / 2; - QPointF newcenter = (touchPoint0.pos() + touchPoint1.pos()) / 2; - - m_pinchStarted = true; - scaleView(touchScaleFactor, newcenter, oldcenter); - } - break; - } - case QEvent::TouchEnd: { - m_pressAndHoldTimer.stop(); - if (m_pinchStarted) { - m_pinchStarted = false; - } - if (touchPoints.count() == 1 && !m_dragStarted && - !m_didPressAndHold && m_tapEvent) { - m_tapEvent = false; - bool doubleTap = event->timestamp() - m_touchTimestamp - < static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval()); - if (doubleTap) { - m_nameDisplayTimer.stop(); - selectNextItem(); - } - else { - selectItem(); - } - m_touchTimestamp = event->timestamp(); - } - m_didPressAndHold = false; - break; - } - default: - break; - } -} - -void InspectTool::scaleView(const qreal &factor, const QPointF &newcenter, const QPointF &oldcenter) -{ - m_pressAndHoldTimer.stop(); - if (((m_contentItem->scale() * factor) > m_maxScale) - || ((m_contentItem->scale() * factor) < m_minScale)) { - return; - } - //New position = new center + scalefactor * (oldposition - oldcenter) - QPointF newPosition = newcenter + (factor * (m_contentItem->position() - oldcenter)); - m_contentItem->setScale(m_contentItem->scale() * factor); - m_contentItem->setPosition(newPosition); -} - -void InspectTool::zoomIn() -{ - qreal newScale = nextZoomScale(ZoomIn); - scaleView(newScale / m_contentItem->scale(), m_mousePosition, m_mousePosition); -} - -void InspectTool::zoomOut() -{ - qreal newScale = nextZoomScale(ZoomOut); - scaleView(newScale / m_contentItem->scale(), m_mousePosition, m_mousePosition); -} - -void InspectTool::zoomTo100() -{ - m_didPressAndHold = true; - - m_contentItem->setPosition(QPointF(0, 0)); - m_contentItem->setScale(1.0); -} - -qreal InspectTool::nextZoomScale(ZoomDirection direction) -{ - static QList<qreal> zoomScales = - QList<qreal>() - << 0.125f - << 1.0f / 6.0f - << 0.25f - << 1.0f / 3.0f - << 0.5f - << 2.0f / 3.0f - << 1.0f - << 2.0f - << 3.0f - << 4.0f - << 5.0f - << 6.0f - << 7.0f - << 8.0f - << 12.0f - << 16.0f - << 32.0f - << 48.0f; - - if (direction == ZoomIn) { - for (int i = 0; i < zoomScales.length(); ++i) { - if (zoomScales[i] > m_contentItem->scale()) - return zoomScales[i]; - } - return zoomScales.last(); - } else { - for (int i = zoomScales.length() - 1; i >= 0; --i) { - if (zoomScales[i] < m_contentItem->scale()) - return zoomScales[i]; - } - return zoomScales.first(); - } - - return 1.0f; -} - -void InspectTool::initializeDrag(const QPointF &pos) -{ - m_dragStartPosition = pos; - m_dragStarted = false; -} - -void InspectTool::dragItemToPosition() -{ - QPointF newPosition = m_contentItem->position() + m_mousePosition - m_dragStartPosition; - m_dragStartPosition = m_mousePosition; - m_contentItem->setPosition(newPosition); -} - -void InspectTool::moveItem(bool valid) -{ - if (m_pinchStarted) - return; - - if (!m_dragStarted - && valid - && ((m_dragStartPosition - m_mousePosition).manhattanLength() - > QGuiApplication::styleHints()->startDragDistance())) { - m_pressAndHoldTimer.stop(); - m_dragStarted = true; - } - if (m_dragStarted) - dragItemToPosition(); -} - -void InspectTool::selectNextItem() -{ - if (m_lastClickedItem != inspector()->topVisibleItemAt(m_mousePosition)) - return; - QList<QQuickItem*> items = inspector()->itemsAt(m_mousePosition); - for (int i = 0; i < items.count(); i++) { - if (m_lastItem == items[i]) { - if (i + 1 < items.count()) - m_lastItem = items[i+1]; - else - m_lastItem = items[0]; - inspector()->setSelectedItems(QList<QQuickItem*>() << m_lastItem); - showSelectedItemName(); - break; - } - } -} - -void InspectTool::selectItem() -{ - if (!inspector()->topVisibleItemAt(m_mousePosition)) - return; - if (m_lastClickedItem == inspector()->topVisibleItemAt(m_mousePosition)) { - m_nameDisplayTimer.start(); - return; - } - m_lastClickedItem = inspector()->topVisibleItemAt(m_mousePosition); - m_lastItem = m_lastClickedItem; - inspector()->setSelectedItems(QList<QQuickItem*>() << m_lastClickedItem); - showSelectedItemName(); -} - -QQuickViewInspector *InspectTool::inspector() const -{ - return static_cast<QQuickViewInspector*>(AbstractTool::inspector()); -} - -void InspectTool::showSelectedItemName() -{ - inspector()->showSelectedItemName(m_lastItem, m_mousePosition); -} - -} // namespace QtQuick2 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/inspecttool.h b/src/plugins/qmltooling/qmldbg_qtquick2/inspecttool.h deleted file mode 100644 index 0b1b49fd93..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick2/inspecttool.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INSPECTTOOL_H -#define INSPECTTOOL_H - -#include "abstracttool.h" - -#include <QtCore/QPointF> -#include <QtCore/QPointer> -#include <QtCore/QTimer> - -QT_FORWARD_DECLARE_CLASS(QQuickView) -QT_FORWARD_DECLARE_CLASS(QQuickItem) - -namespace QmlJSDebugger { -namespace QtQuick2 { - -class QQuickViewInspector; -class HoverHighlight; - -class InspectTool : public AbstractTool -{ - Q_OBJECT -public: - enum ZoomDirection { - ZoomIn, - ZoomOut - }; - - InspectTool(QQuickViewInspector *inspector, QQuickView *view); - ~InspectTool(); - - void enable(bool enable); - - void leaveEvent(QEvent *); - - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseDoubleClickEvent(QMouseEvent *); - - void hoverMoveEvent(QMouseEvent *); -#ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *); -#endif - - void keyPressEvent(QKeyEvent *) {} - void keyReleaseEvent(QKeyEvent *); - - void touchEvent(QTouchEvent *event); - -private: - QQuickViewInspector *inspector() const; - qreal nextZoomScale(ZoomDirection direction); - void scaleView(const qreal &factor, const QPointF &newcenter, const QPointF &oldcenter); - void zoomIn(); - void zoomOut(); - void initializeDrag(const QPointF &pos); - void dragItemToPosition(); - void moveItem(bool valid); - void selectNextItem(); - void selectItem(); - -private slots: - void zoomTo100(); - void showSelectedItemName(); - -private: - bool m_originalSmooth; - bool m_dragStarted; - bool m_pinchStarted; - bool m_didPressAndHold; - bool m_tapEvent; - QPointer<QQuickItem> m_contentItem; - QPointF m_dragStartPosition; - QPointF m_mousePosition; - QPointF m_originalPosition; - qreal m_smoothScaleFactor; - qreal m_minScale; - qreal m_maxScale; - qreal m_originalScale; - ulong m_touchTimestamp; - QTimer m_pressAndHoldTimer; - QTimer m_nameDisplayTimer; - - HoverHighlight *m_hoverHighlight; - QQuickItem *m_lastItem; - QQuickItem *m_lastClickedItem; -}; - -} // namespace QtQuick2 -} // namespace QmlJSDebugger - -#endif // INSPECTTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro b/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro deleted file mode 100644 index 2ee0d703b2..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro +++ /dev/null @@ -1,27 +0,0 @@ -TARGET = qmldbg_qtquick2 -QT += qml-private quick-private core-private gui-private - -PLUGIN_TYPE = qmltooling -PLUGIN_CLASS_NAME = QtQuick2Plugin -load(qt_plugin) - -INCLUDEPATH *= $$PWD $$PWD/../shared - -SOURCES += \ - qtquick2plugin.cpp \ - highlight.cpp \ - qquickviewinspector.cpp \ - ../shared/abstracttool.cpp \ - ../shared/abstractviewinspector.cpp \ - inspecttool.cpp - -HEADERS += \ - qtquick2plugin.h \ - highlight.h \ - qquickviewinspector.h \ - ../shared/abstracttool.h \ - ../shared/abstractviewinspector.h \ - ../shared/qmlinspectorconstants.h \ - inspecttool.h - -OTHER_FILES += qtquick2plugin.json diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp deleted file mode 100644 index e61c421bfa..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickviewinspector.h" - -#include "highlight.h" -#include "inspecttool.h" - -#include <QtQml/private/qqmlengine_p.h> -#include <QtQml/private/qqmldebugservice_p.h> -#include <QtQuick/private/qquickitem_p.h> - -#include <QtQuick/QQuickView> -#include <QtQuick/QQuickItem> - -#include <cfloat> - -namespace QmlJSDebugger { -namespace QtQuick2 { - -/* - * Collects all the items at the given position, from top to bottom. - */ -static void collectItemsAt(QQuickItem *item, const QPointF &pos, - QQuickItem *overlay, QList<QQuickItem *> &resultList) -{ - if (item == overlay) - return; - - if (item->flags() & QQuickItem::ItemClipsChildrenToShape) { - if (!QRectF(0, 0, item->width(), item->height()).contains(pos)) - return; - } - - QList<QQuickItem *> children = QQuickItemPrivate::get(item)->paintOrderChildItems(); - for (int i = children.count() - 1; i >= 0; --i) { - QQuickItem *child = children.at(i); - collectItemsAt(child, item->mapToItem(child, pos), overlay, resultList); - } - - if (!QRectF(0, 0, item->width(), item->height()).contains(pos)) - return; - - resultList.append(item); -} - -/* - * Returns the first visible item at the given position, or 0 when no such - * child exists. - */ -static QQuickItem *itemAt(QQuickItem *item, const QPointF &pos, - QQuickItem *overlay) -{ - if (item == overlay) - return 0; - - if (!item->isVisible() || item->opacity() == 0.0) - return 0; - - if (item->flags() & QQuickItem::ItemClipsChildrenToShape) { - if (!QRectF(0, 0, item->width(), item->height()).contains(pos)) - return 0; - } - - QList<QQuickItem *> children = QQuickItemPrivate::get(item)->paintOrderChildItems(); - for (int i = children.count() - 1; i >= 0; --i) { - QQuickItem *child = children.at(i); - if (QQuickItem *betterCandidate = itemAt(child, item->mapToItem(child, pos), - overlay)) - return betterCandidate; - } - - if (!(item->flags() & QQuickItem::ItemHasContents)) - return 0; - - if (!QRectF(0, 0, item->width(), item->height()).contains(pos)) - return 0; - - return item; -} - - -QQuickViewInspector::QQuickViewInspector(QQuickView *view, QObject *parent) : - AbstractViewInspector(parent), - m_view(view), - m_overlay(new QQuickItem), - m_inspectTool(new InspectTool(this, view)), - m_sendQmlReloadedMessage(false) -{ - // Try to make sure the overlay is always on top - m_overlay->setZ(FLT_MAX); - - if (QQuickItem *root = view->contentItem()) - m_overlay->setParentItem(root); - - view->installEventFilter(this); - appendTool(m_inspectTool); - connect(view, SIGNAL(statusChanged(QQuickView::Status)), - this, SLOT(onViewStatus(QQuickView::Status))); -} - -void QQuickViewInspector::changeCurrentObjects(const QList<QObject*> &objects) -{ - QList<QQuickItem*> items; - foreach (QObject *obj, objects) - if (QQuickItem *item = qobject_cast<QQuickItem*>(obj)) - items << item; - - syncSelectedItems(items); -} - -void QQuickViewInspector::reparentQmlObject(QObject *object, QObject *newParent) -{ - if (!newParent) - return; - - object->setParent(newParent); - QQuickItem *newParentItem = qobject_cast<QQuickItem*>(newParent); - QQuickItem *item = qobject_cast<QQuickItem*>(object); - if (newParentItem && item) - item->setParentItem(newParentItem); -} - -QWindow *getMasterWindow(QWindow *w) -{ - QWindow *p = w->parent(); - while (p) { - w = p; - p = p->parent(); - } - return w; -} - -Qt::WindowFlags QQuickViewInspector::windowFlags() const -{ - return getMasterWindow(m_view)->flags(); -} - -void QQuickViewInspector::setWindowFlags(Qt::WindowFlags flags) -{ - QWindow *w = getMasterWindow(m_view); - w->setFlags(flags); - // make flags are applied - w->setVisible(false); - w->setVisible(true); -} - -QQmlEngine *QQuickViewInspector::declarativeEngine() const -{ - return m_view->engine(); -} - -QQuickItem *QQuickViewInspector::topVisibleItemAt(const QPointF &pos) const -{ - QQuickItem *root = m_view->contentItem(); - return itemAt(root, root->mapFromScene(pos), m_overlay); -} - -QList<QQuickItem *> QQuickViewInspector::itemsAt(const QPointF &pos) const -{ - QQuickItem *root = m_view->contentItem(); - QList<QQuickItem *> resultList; - collectItemsAt(root, root->mapFromScene(pos), m_overlay, - resultList); - return resultList; -} - -QList<QQuickItem*> QQuickViewInspector::selectedItems() const -{ - QList<QQuickItem *> selection; - foreach (const QPointer<QQuickItem> &selectedItem, m_selectedItems) { - if (selectedItem) - selection << selectedItem; - } - return selection; -} - -void QQuickViewInspector::setSelectedItems(const QList<QQuickItem *> &items) -{ - if (!syncSelectedItems(items)) - return; - - QList<QObject*> objectList; - foreach (QQuickItem *item, items) - objectList << item; - - sendCurrentObjects(objectList); -} - -bool QQuickViewInspector::syncSelectedItems(const QList<QQuickItem *> &items) -{ - bool selectionChanged = false; - - // Disconnect and remove items that are no longer selected - foreach (const QPointer<QQuickItem> &item, m_selectedItems) { - if (!item) // Don't see how this can happen due to handling of destroyed() - continue; - if (items.contains(item)) - continue; - - selectionChanged = true; - item->disconnect(this); - m_selectedItems.removeOne(item); - delete m_highlightItems.take(item); - } - - // Connect and add newly selected items - foreach (QQuickItem *item, items) { - if (m_selectedItems.contains(item)) - continue; - - selectionChanged = true; - connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(removeFromSelectedItems(QObject*))); - m_selectedItems.append(item); - SelectionHighlight *selectionHighlightItem; - selectionHighlightItem = new SelectionHighlight(titleForItem(item), item, m_overlay); - m_highlightItems.insert(item, selectionHighlightItem); - } - - return selectionChanged; -} - -void QQuickViewInspector::showSelectedItemName(QQuickItem *item, const QPointF &point) -{ - SelectionHighlight *highlightItem = m_highlightItems.value(item, 0); - if (highlightItem) - highlightItem->showName(point); -} - -void QQuickViewInspector::removeFromSelectedItems(QObject *object) -{ - if (QQuickItem *item = qobject_cast<QQuickItem*>(object)) { - if (m_selectedItems.removeOne(item)) - delete m_highlightItems.take(item); - } -} - -bool QQuickViewInspector::eventFilter(QObject *obj, QEvent *event) -{ - if (obj != m_view) - return QObject::eventFilter(obj, event); - - return AbstractViewInspector::eventFilter(obj, event); -} - -bool QQuickViewInspector::mouseMoveEvent(QMouseEvent *event) -{ - // TODO -// if (QQuickItem *item = topVisibleItemAt(event->pos())) -// m_view->setToolTip(titleForItem(item)); -// else -// m_view->setToolTip(QString()); - - return AbstractViewInspector::mouseMoveEvent(event); -} - -QString QQuickViewInspector::titleForItem(QQuickItem *item) const -{ - QString className = QLatin1String(item->metaObject()->className()); - QString objectStringId = idStringForObject(item); - - className.remove(QRegExp(QLatin1String("_QMLTYPE_\\d+"))); - className.remove(QRegExp(QLatin1String("_QML_\\d+"))); - if (className.startsWith(QLatin1String("QQuick"))) - className = className.mid(6); - - QString constructedName; - - if (!objectStringId.isEmpty()) { - constructedName = objectStringId + QLatin1String(" (") + className + QLatin1Char(')'); - } else if (!item->objectName().isEmpty()) { - constructedName = item->objectName() + QLatin1String(" (") + className + QLatin1Char(')'); - } else { - constructedName = className; - } - - return constructedName; -} - -void QQuickViewInspector::reloadQmlFile(const QHash<QString, QByteArray> &changesHash) -{ - clearComponentCache(); - - // Reset the selection since we are reloading the main qml - setSelectedItems(QList<QQuickItem *>()); - - QQmlDebugService::clearObjectsFromHash(); - - QHash<QUrl, QByteArray> debugCache; - - foreach (const QString &str, changesHash.keys()) - debugCache.insert(QUrl(str), changesHash.value(str, QByteArray())); - - // Updating the cache in engine private such that the QML Data loader - // gets the changes from the cache. - QQmlEnginePrivate::get(declarativeEngine())->setDebugChangesCache(debugCache); - - m_sendQmlReloadedMessage = true; - // reloading the view such that the changes done for the files are - // reflected in view - view()->setSource(view()->source()); -} - -void QQuickViewInspector::setShowAppOnTop(bool appOnTop) -{ - m_appOnTop = appOnTop; - // Hack for QTCREATORBUG-6295. - // TODO: The root cause to be identified and fixed later. - QTimer::singleShot(100, this, SLOT(applyAppOnTop())); -} - -void QQuickViewInspector::onViewStatus(QQuickView::Status status) -{ - bool success = false; - switch (status) { - case QQuickView::Loading: - return; - case QQuickView::Ready: - if (view()->errors().count()) - break; - success = true; - break; - case QQuickView::Null: - case QQuickView::Error: - break; - default: - break; - } - if (m_sendQmlReloadedMessage) { - m_sendQmlReloadedMessage = false; - sendQmlFileReloaded(success); - } -} - -void QQuickViewInspector::applyAppOnTop() -{ - Qt::WindowFlags flags = windowFlags(); - if (m_appOnTop) - flags |= Qt::WindowStaysOnTopHint; - else - flags &= ~Qt::WindowStaysOnTopHint; - - setWindowFlags(flags); -} - -} // namespace QtQuick2 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h deleted file mode 100644 index be3ede4d07..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKVIEWINSPECTOR_H -#define QQUICKVIEWINSPECTOR_H - -#include "abstractviewinspector.h" - -#include <QtCore/QPointer> -#include <QtCore/QHash> -#include <QtQuick/QQuickView> - -QT_BEGIN_NAMESPACE -class QQuickView; -class QQuickItem; -QT_END_NAMESPACE - -namespace QmlJSDebugger { -namespace QtQuick2 { - -class InspectTool; -class SelectionHighlight; - -class QQuickViewInspector : public AbstractViewInspector -{ - Q_OBJECT -public: - explicit QQuickViewInspector(QQuickView *view, QObject *parent = 0); - - // AbstractViewInspector - void changeCurrentObjects(const QList<QObject*> &objects); - void reparentQmlObject(QObject *object, QObject *newParent); - Qt::WindowFlags windowFlags() const; - void setWindowFlags(Qt::WindowFlags flags); - QQmlEngine *declarativeEngine() const; - - QQuickView *view() const { return m_view; } - QQuickItem *overlay() const { return m_overlay; } - - QQuickItem *topVisibleItemAt(const QPointF &pos) const; - QList<QQuickItem *> itemsAt(const QPointF &pos) const; - - QList<QQuickItem *> selectedItems() const; - void setSelectedItems(const QList<QQuickItem*> &items); - - QString titleForItem(QQuickItem *item) const; - void showSelectedItemName(QQuickItem *item, const QPointF &point); - - void reloadQmlFile(const QHash<QString, QByteArray> &changesHash); - -protected: - bool eventFilter(QObject *obj, QEvent *event); - - bool mouseMoveEvent(QMouseEvent *); - - void setShowAppOnTop(bool appOnTop); - -private slots: - void removeFromSelectedItems(QObject *); - void onViewStatus(QQuickView::Status status); - void applyAppOnTop(); - -private: - bool syncSelectedItems(const QList<QQuickItem*> &items); - - QQuickView *m_view; - QQuickItem *m_overlay; - - InspectTool *m_inspectTool; - - QList<QPointer<QQuickItem> > m_selectedItems; - QHash<QQuickItem*, SelectionHighlight*> m_highlightItems; - bool m_sendQmlReloadedMessage; - bool m_appOnTop; -}; - -} // namespace QtQuick2 -} // namespace QmlJSDebugger - -#endif // QQUICKVIEWINSPECTOR_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp deleted file mode 100644 index 88801ec9db..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtquick2plugin.h" -#include "qquickviewinspector.h" - -#include <QtCore/qplugin.h> -#include <QtQml/private/qqmlinspectorservice_p.h> -#include <QtQuick/QQuickView> - -namespace QmlJSDebugger { -namespace QtQuick2 { - -QtQuick2Plugin::QtQuick2Plugin() : - m_inspector(0) -{ -} - -QtQuick2Plugin::~QtQuick2Plugin() -{ - delete m_inspector; -} - -bool QtQuick2Plugin::canHandleView(QObject *view) -{ - return qobject_cast<QQuickView*>(view); -} - -void QtQuick2Plugin::activate(QObject *view) -{ - QQuickView *qtQuickView = qobject_cast<QQuickView*>(view); - Q_ASSERT(qtQuickView); - m_inspector = new QQuickViewInspector(qtQuickView, qtQuickView); -} - -void QtQuick2Plugin::deactivate() -{ - delete m_inspector; -} - -void QtQuick2Plugin::clientMessage(const QByteArray &message) -{ - if (m_inspector) - m_inspector->handleMessage(message); -} - -} // namespace QtQuick2 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h deleted file mode 100644 index 6866e74aa1..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTQUICK2PLUGINPLUGIN_H -#define QTQUICK2PLUGINPLUGIN_H - -#include <QtCore/QPointer> -#include <QtQml/private/qqmlinspectorinterface_p.h> - -namespace QmlJSDebugger { - -class AbstractViewInspector; - -namespace QtQuick2 { - -class QtQuick2Plugin : public QObject, public QQmlInspectorInterface -{ - Q_OBJECT - Q_DISABLE_COPY(QtQuick2Plugin) - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlInspectorInterface") - Q_INTERFACES(QQmlInspectorInterface) - -public: - QtQuick2Plugin(); - ~QtQuick2Plugin(); - - // QQmlInspectorInterface - bool canHandleView(QObject *view); - void activate(QObject *view); - void deactivate(); - void clientMessage(const QByteArray &message); - -private: - QPointer<AbstractViewInspector> m_inspector; -}; - -} // namespace QtQuick2 -} // namespace QmlJSDebugger - -#endif // QTQUICK2PLUGINPLUGIN_H |