Remove support for debugging JS with Qt 4.7
Remove infrastructure to debug/inspect QML applications with Qt 4.7. Change-Id: I277e9884e009475a29017f502bbe1d069317460f Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
@@ -1183,18 +1183,6 @@
|
||||
d.putSubItem("value", value)
|
||||
\endcode
|
||||
|
||||
|
||||
\section1 Debugging Helpers for QML
|
||||
|
||||
The debugging helpers for QML provide you with code completion for custom modules
|
||||
(\c qmldump) and debugging Qt Quick UI projects (\c qmlobserver).
|
||||
|
||||
You have to build the QML Inspector once for each Qt version that you want
|
||||
to debug
|
||||
with. Select \gui{Tools > Options > Build & Run > Qt Versions}.
|
||||
|
||||
\note QML Inspector requires Qt 4.7.1 or later.
|
||||
|
||||
\section1 Enabling Debugging Helpers for Qt's Bootstrapped Applications
|
||||
|
||||
Qt's bootstrapped applications (such as moc and qmake) are built in a way
|
||||
|
||||
@@ -30,12 +30,7 @@
|
||||
|
||||
\title Debugging Qt Quick Projects
|
||||
|
||||
\note You need Qt 4.7.1 or later to debug Qt Quick projects. Debugging
|
||||
projects not created with the Qt Quick wizards is only supported with
|
||||
Qt 4.8, or later.
|
||||
|
||||
To debug Qt Quick applications running on devices, you must install
|
||||
Qt 4.7.4, or later, libraries on devices.
|
||||
\note You need Qt 4.8 or later to debug Qt Quick projects.
|
||||
|
||||
For an example of how to debug Qt Quick Projects, see
|
||||
\l{Debugging a Qt Quick Example Application}.
|
||||
|
||||
@@ -50,12 +50,8 @@
|
||||
|
||||
\li qtc-debugging-helper
|
||||
|
||||
\li qtc-qmldbg
|
||||
|
||||
\li qtc-qmldump
|
||||
|
||||
\li qtc-qmlobserver
|
||||
|
||||
\endlist
|
||||
|
||||
The location depends on the platform. On Linux and other Unix platforms, the files
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "abstractliveedittool.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
|
||||
#include <QDeclarativeEngine>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QGraphicsItem>
|
||||
#include <QDeclarativeItem>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView)
|
||||
: QObject(editorView), m_inspector(editorView)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AbstractLiveEditTool::~AbstractLiveEditTool()
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeViewInspector *AbstractLiveEditTool::inspector() const
|
||||
{
|
||||
return m_inspector;
|
||||
}
|
||||
|
||||
QDeclarativeView *AbstractLiveEditTool::view() const
|
||||
{
|
||||
return m_inspector->declarativeView();
|
||||
}
|
||||
|
||||
QGraphicsScene* AbstractLiveEditTool::scene() const
|
||||
{
|
||||
return view()->scene();
|
||||
}
|
||||
|
||||
void AbstractLiveEditTool::updateSelectedItems()
|
||||
{
|
||||
selectedItemsChanged(items());
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> AbstractLiveEditTool::items() const
|
||||
{
|
||||
return inspector()->selectedItems();
|
||||
}
|
||||
|
||||
bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
|
||||
{
|
||||
QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList);
|
||||
if (firstSelectableItem == 0)
|
||||
return false;
|
||||
if (toQDeclarativeItem(firstSelectableItem) != 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool AbstractLiveEditTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
QList<QGraphicsItem*> selectedItems = inspector()->selectedItems();
|
||||
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
|
||||
if (declarativeItem
|
||||
&& selectedItems.contains(declarativeItem)
|
||||
/*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool AbstractLiveEditTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QDeclarativeItem *AbstractLiveEditTool::toQDeclarativeItem(QGraphicsItem *item)
|
||||
{
|
||||
return qobject_cast<QDeclarativeItem*>(item->toGraphicsObject());
|
||||
}
|
||||
|
||||
QGraphicsItem *AbstractLiveEditTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
if (item->flags().testFlag(QGraphicsItem::ItemIsMovable))
|
||||
return item;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QDeclarativeItem *AbstractLiveEditTool::topMovableDeclarativeItem(const QList<QGraphicsItem*>
|
||||
&itemList)
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
|
||||
if (declarativeItem /*&& (declarativeItem->qmlItemNode().hasShowContent())*/)
|
||||
return declarativeItem;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QList<QGraphicsObject*> AbstractLiveEditTool::toGraphicsObjectList(const QList<QGraphicsItem*>
|
||||
&itemList)
|
||||
{
|
||||
QList<QGraphicsObject*> gfxObjects;
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
QGraphicsObject *obj = item->toGraphicsObject();
|
||||
if (obj)
|
||||
gfxObjects << obj;
|
||||
}
|
||||
|
||||
return gfxObjects;
|
||||
}
|
||||
|
||||
QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item)
|
||||
{
|
||||
QString className("QGraphicsItem");
|
||||
QString objectStringId;
|
||||
|
||||
QString constructedName;
|
||||
|
||||
QGraphicsObject *gfxObject = item->toGraphicsObject();
|
||||
if (gfxObject) {
|
||||
className = gfxObject->metaObject()->className();
|
||||
|
||||
className.remove(QRegExp("_QMLTYPE_\\d+"));
|
||||
className.remove(QRegExp("_QML_\\d+"));
|
||||
if (className.startsWith(QLatin1String("QDeclarative")))
|
||||
className = className.remove(QLatin1String("QDeclarative"));
|
||||
|
||||
QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(gfxObject);
|
||||
if (declarativeItem) {
|
||||
objectStringId = QDeclarativeViewInspector::idStringForObject(declarativeItem);
|
||||
}
|
||||
|
||||
if (!objectStringId.isEmpty()) {
|
||||
constructedName = objectStringId + " (" + className + QLatin1Char(')');
|
||||
} else {
|
||||
if (!gfxObject->objectName().isEmpty()) {
|
||||
constructedName = gfxObject->objectName() + " (" + className + QLatin1Char(')');
|
||||
} else {
|
||||
constructedName = className;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return constructedName;
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,104 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ABSTRACTLIVEEDITTOOL_H
|
||||
#define ABSTRACTLIVEEDITTOOL_H
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMouseEvent;
|
||||
class QGraphicsItem;
|
||||
class QDeclarativeItem;
|
||||
class QKeyEvent;
|
||||
class QGraphicsScene;
|
||||
class QGraphicsObject;
|
||||
class QWheelEvent;
|
||||
class QDeclarativeView;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class FormEditorView;
|
||||
|
||||
class AbstractLiveEditTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AbstractLiveEditTool(QDeclarativeViewInspector *inspector);
|
||||
|
||||
virtual ~AbstractLiveEditTool();
|
||||
|
||||
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;
|
||||
virtual void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList) = 0;
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
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);
|
||||
|
||||
static QString titleForItem(QGraphicsItem *item);
|
||||
static QList<QGraphicsObject*> toGraphicsObjectList(const QList<QGraphicsItem*> &itemList);
|
||||
static QGraphicsItem* topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList);
|
||||
static QDeclarativeItem* topMovableDeclarativeItem(const QList<QGraphicsItem*> &itemList);
|
||||
static QDeclarativeItem *toQDeclarativeItem(QGraphicsItem *item);
|
||||
|
||||
protected:
|
||||
virtual void selectedItemsChanged(const QList<QGraphicsItem*> &objectList) = 0;
|
||||
|
||||
QDeclarativeViewInspector *inspector() const;
|
||||
QDeclarativeView *view() const;
|
||||
QGraphicsScene *scene() const;
|
||||
|
||||
private:
|
||||
QDeclarativeViewInspector *m_inspector;
|
||||
QList<QGraphicsItem*> m_itemList;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ABSTRACTLIVEEDITTOOL_H
|
||||
@@ -1,228 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "boundingrecthighlighter.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QGraphicsPolygonItem>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem,
|
||||
QObject *parent)
|
||||
: QObject(parent),
|
||||
highlightedObject(itemToHighlight),
|
||||
highlightPolygon(0),
|
||||
highlightPolygonEdge(0)
|
||||
{
|
||||
highlightPolygon = new BoundingBoxPolygonItem(parentItem);
|
||||
highlightPolygonEdge = new BoundingBoxPolygonItem(parentItem);
|
||||
|
||||
highlightPolygon->setPen(QPen(QColor(0, 22, 159)));
|
||||
highlightPolygonEdge->setPen(QPen(QColor(158, 199, 255)));
|
||||
|
||||
highlightPolygon->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
highlightPolygonEdge->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
}
|
||||
|
||||
BoundingBox::~BoundingBox()
|
||||
{
|
||||
highlightedObject.clear();
|
||||
}
|
||||
|
||||
BoundingBoxPolygonItem::BoundingBoxPolygonItem(QGraphicsItem *item) : QGraphicsPolygonItem(item)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setColor(QColor(108, 141, 221));
|
||||
pen.setWidth(1);
|
||||
setPen(pen);
|
||||
}
|
||||
|
||||
int BoundingBoxPolygonItem::type() const
|
||||
{
|
||||
return Constants::EditorItemType;
|
||||
}
|
||||
|
||||
BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewInspector *view) :
|
||||
LiveLayerItem(view->declarativeView()->scene()),
|
||||
m_view(view)
|
||||
{
|
||||
}
|
||||
|
||||
BoundingRectHighlighter::~BoundingRectHighlighter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::clear()
|
||||
{
|
||||
foreach (BoundingBox *box, m_boxes)
|
||||
freeBoundingBox(box);
|
||||
}
|
||||
|
||||
BoundingBox *BoundingRectHighlighter::boxFor(QGraphicsObject *item) const
|
||||
{
|
||||
foreach (BoundingBox *box, m_boxes) {
|
||||
if (box->highlightedObject.data() == item)
|
||||
return box;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::highlight(QList<QGraphicsObject*> items)
|
||||
{
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
QList<BoundingBox *> newBoxes;
|
||||
foreach (QGraphicsObject *itemToHighlight, items) {
|
||||
BoundingBox *box = boxFor(itemToHighlight);
|
||||
if (!box)
|
||||
box = createBoundingBox(itemToHighlight);
|
||||
|
||||
newBoxes << box;
|
||||
}
|
||||
qSort(newBoxes);
|
||||
|
||||
if (newBoxes != m_boxes) {
|
||||
clear();
|
||||
m_boxes << newBoxes;
|
||||
}
|
||||
|
||||
highlightAll();
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::highlight(QGraphicsObject* itemToHighlight)
|
||||
{
|
||||
if (!itemToHighlight)
|
||||
return;
|
||||
|
||||
BoundingBox *box = boxFor(itemToHighlight);
|
||||
if (!box) {
|
||||
box = createBoundingBox(itemToHighlight);
|
||||
m_boxes << box;
|
||||
qSort(m_boxes);
|
||||
}
|
||||
|
||||
highlightAll();
|
||||
}
|
||||
|
||||
BoundingBox *BoundingRectHighlighter::createBoundingBox(QGraphicsObject *itemToHighlight)
|
||||
{
|
||||
if (!m_freeBoxes.isEmpty()) {
|
||||
BoundingBox *box = m_freeBoxes.last();
|
||||
if (box->highlightedObject.isNull()) {
|
||||
box->highlightedObject = itemToHighlight;
|
||||
box->highlightPolygon->show();
|
||||
box->highlightPolygonEdge->show();
|
||||
m_freeBoxes.removeLast();
|
||||
return box;
|
||||
}
|
||||
}
|
||||
|
||||
BoundingBox *box = new BoundingBox(itemToHighlight, this, this);
|
||||
|
||||
connect(itemToHighlight, SIGNAL(xChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(yChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(widthChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(heightChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(rotationChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed(QObject*)));
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::removeBoundingBox(BoundingBox *box)
|
||||
{
|
||||
delete box;
|
||||
box = 0;
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::freeBoundingBox(BoundingBox *box)
|
||||
{
|
||||
if (!box->highlightedObject.isNull()) {
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(xChanged()), this, SLOT(refresh()));
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(yChanged()), this, SLOT(refresh()));
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(widthChanged()), this, SLOT(refresh()));
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(heightChanged()), this, SLOT(refresh()));
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(rotationChanged()), this, SLOT(refresh()));
|
||||
}
|
||||
|
||||
box->highlightedObject.clear();
|
||||
box->highlightPolygon->hide();
|
||||
box->highlightPolygonEdge->hide();
|
||||
m_boxes.removeOne(box);
|
||||
m_freeBoxes << box;
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::itemDestroyed(QObject *obj)
|
||||
{
|
||||
foreach (BoundingBox *box, m_boxes) {
|
||||
if (box->highlightedObject.data() == obj) {
|
||||
freeBoundingBox(box);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::highlightAll()
|
||||
{
|
||||
foreach (BoundingBox *box, m_boxes) {
|
||||
Q_ASSERT(box);
|
||||
if (box->highlightedObject.isNull()) {
|
||||
// clear all highlights
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
QGraphicsObject *item = box->highlightedObject.data();
|
||||
|
||||
QRectF boundingRectInSceneSpace(item->mapToScene(item->boundingRect()).boundingRect());
|
||||
QRectF boundingRectInLayerItemSpace = mapRectFromScene(boundingRectInSceneSpace);
|
||||
QRectF bboxRect = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace);
|
||||
QRectF edgeRect = bboxRect;
|
||||
edgeRect.adjust(-1, -1, 1, 1);
|
||||
|
||||
box->highlightPolygon->setPolygon(QPolygonF(bboxRect));
|
||||
box->highlightPolygonEdge->setPolygon(QPolygonF(edgeRect));
|
||||
}
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::refresh()
|
||||
{
|
||||
if (!m_boxes.isEmpty())
|
||||
highlightAll();
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,103 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef BOUNDINGRECTHIGHLIGHTER_H
|
||||
#define BOUNDINGRECTHIGHLIGHTER_H
|
||||
|
||||
#include "livelayeritem.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QWeakPointer>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QPainter)
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||
QT_FORWARD_DECLARE_CLASS(QStyleOptionGraphicsItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
class BoundingBox;
|
||||
|
||||
class BoundingRectHighlighter : public LiveLayerItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BoundingRectHighlighter(QDeclarativeViewInspector *view);
|
||||
~BoundingRectHighlighter();
|
||||
void clear();
|
||||
void highlight(QList<QGraphicsObject*> items);
|
||||
void highlight(QGraphicsObject* item);
|
||||
|
||||
private slots:
|
||||
void refresh();
|
||||
void itemDestroyed(QObject *);
|
||||
|
||||
private:
|
||||
BoundingBox *boxFor(QGraphicsObject *item) const;
|
||||
void highlightAll();
|
||||
BoundingBox *createBoundingBox(QGraphicsObject *itemToHighlight);
|
||||
void removeBoundingBox(BoundingBox *box);
|
||||
void freeBoundingBox(BoundingBox *box);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(BoundingRectHighlighter)
|
||||
|
||||
QDeclarativeViewInspector *m_view;
|
||||
QList<BoundingBox* > m_boxes;
|
||||
QList<BoundingBox* > m_freeBoxes;
|
||||
};
|
||||
|
||||
class BoundingBox : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem,
|
||||
QObject *parent = 0);
|
||||
~BoundingBox();
|
||||
QWeakPointer<QGraphicsObject> highlightedObject;
|
||||
QGraphicsPolygonItem *highlightPolygon;
|
||||
QGraphicsPolygonItem *highlightPolygonEdge;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(BoundingBox)
|
||||
|
||||
};
|
||||
|
||||
class BoundingBoxPolygonItem : public QGraphicsPolygonItem
|
||||
{
|
||||
public:
|
||||
explicit BoundingBoxPolygonItem(QGraphicsItem *item);
|
||||
int type() const;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // BOUNDINGRECTHIGHLIGHTER_H
|
||||
@@ -1,118 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "colorpickertool.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QRectF>
|
||||
#include <QRgb>
|
||||
#include <QImage>
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
ColorPickerTool::ColorPickerTool(QDeclarativeViewInspector *view) :
|
||||
AbstractLiveEditTool(view)
|
||||
{
|
||||
m_selectedColor.setRgb(0,0,0);
|
||||
}
|
||||
|
||||
ColorPickerTool::~ColorPickerTool()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ColorPickerTool::mousePressEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
pickColor(event->pos());
|
||||
}
|
||||
|
||||
void ColorPickerTool::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
pickColor(event->pos());
|
||||
}
|
||||
|
||||
void ColorPickerTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ColorPickerTool::hoverMoveEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::keyPressEvent(QKeyEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
|
||||
{
|
||||
}
|
||||
void ColorPickerTool::wheelEvent(QWheelEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::clear()
|
||||
{
|
||||
view()->setCursor(Qt::CrossCursor);
|
||||
}
|
||||
|
||||
void ColorPickerTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::pickColor(const QPoint &pos)
|
||||
{
|
||||
QRgb fillColor = view()->backgroundBrush().color().rgb();
|
||||
if (view()->backgroundBrush().style() == Qt::NoBrush)
|
||||
fillColor = view()->palette().color(QPalette::Base).rgb();
|
||||
|
||||
QRectF target(0,0, 1, 1);
|
||||
QRect source(pos.x(), pos.y(), 1, 1);
|
||||
QImage img(1, 1, QImage::Format_ARGB32);
|
||||
img.fill(fillColor);
|
||||
QPainter painter(&img);
|
||||
view()->render(&painter, target, source);
|
||||
m_selectedColor = QColor::fromRgb(img.pixel(0, 0));
|
||||
|
||||
emit selectedColorChanged(m_selectedColor);
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef COLORPICKERTOOL_H
|
||||
#define COLORPICKERTOOL_H
|
||||
|
||||
#include "abstractliveedittool.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QPoint)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class ColorPickerTool : public AbstractLiveEditTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ColorPickerTool(QDeclarativeViewInspector *view);
|
||||
|
||||
virtual ~ColorPickerTool();
|
||||
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
|
||||
void hoverMoveEvent(QMouseEvent *event);
|
||||
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void selectedColorChanged(const QColor &color);
|
||||
|
||||
protected:
|
||||
|
||||
void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
private:
|
||||
void pickColor(const QPoint &pos);
|
||||
|
||||
private:
|
||||
QColor m_selectedColor;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // COLORPICKERTOOL_H
|
||||
@@ -1,79 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "livelayeritem.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QGraphicsScene>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveLayerItem::LiveLayerItem(QGraphicsScene* scene)
|
||||
: QGraphicsObject()
|
||||
{
|
||||
scene->addItem(this);
|
||||
setZValue(1);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
}
|
||||
|
||||
LiveLayerItem::~LiveLayerItem()
|
||||
{
|
||||
}
|
||||
|
||||
void LiveLayerItem::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/,
|
||||
QWidget * /*widget*/)
|
||||
{
|
||||
}
|
||||
|
||||
int LiveLayerItem::type() const
|
||||
{
|
||||
return Constants::EditorItemType;
|
||||
}
|
||||
|
||||
QRectF LiveLayerItem::boundingRect() const
|
||||
{
|
||||
return childrenBoundingRect();
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> LiveLayerItem::findAllChildItems() const
|
||||
{
|
||||
return findAllChildItems(this);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> LiveLayerItem::findAllChildItems(const QGraphicsItem *item) const
|
||||
{
|
||||
QList<QGraphicsItem*> itemList(item->childItems());
|
||||
|
||||
foreach (QGraphicsItem *childItem, item->childItems())
|
||||
itemList += findAllChildItems(childItem);
|
||||
|
||||
return itemList;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,55 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVELAYERITEM_H
|
||||
#define LIVELAYERITEM_H
|
||||
|
||||
#include <QGraphicsObject>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class LiveLayerItem : public QGraphicsObject
|
||||
{
|
||||
public:
|
||||
LiveLayerItem(QGraphicsScene *scene);
|
||||
~LiveLayerItem();
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = 0);
|
||||
QRectF boundingRect() const;
|
||||
int type() const;
|
||||
|
||||
QList<QGraphicsItem*> findAllChildItems() const;
|
||||
|
||||
protected:
|
||||
QList<QGraphicsItem*> findAllChildItems(const QGraphicsItem *item) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // LIVELAYERITEM_H
|
||||
@@ -1,152 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "liverubberbandselectionmanipulator.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
|
||||
#include <QGraphicsItem>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
|
||||
QDeclarativeViewInspector *editorView)
|
||||
: m_selectionRectangleElement(layerItem),
|
||||
m_editorView(editorView),
|
||||
m_beginFormEditorItem(0),
|
||||
m_isActive(false)
|
||||
{
|
||||
m_selectionRectangleElement.hide();
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::clear()
|
||||
{
|
||||
m_selectionRectangleElement.clear();
|
||||
m_isActive = false;
|
||||
m_beginPoint = QPointF();
|
||||
m_itemList.clear();
|
||||
m_oldSelectionList.clear();
|
||||
}
|
||||
|
||||
QGraphicsItem *LiveRubberBandSelectionManipulator::topFormEditorItem(const QList<QGraphicsItem*>
|
||||
&itemList)
|
||||
{
|
||||
if (itemList.isEmpty())
|
||||
return 0;
|
||||
|
||||
return itemList.first();
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::begin(const QPointF &beginPoint)
|
||||
{
|
||||
m_beginPoint = beginPoint;
|
||||
m_selectionRectangleElement.setRect(m_beginPoint, m_beginPoint);
|
||||
m_selectionRectangleElement.show();
|
||||
m_isActive = true;
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(m_editorView);
|
||||
m_beginFormEditorItem = topFormEditorItem(inspectorPrivate->selectableItems(beginPoint));
|
||||
m_oldSelectionList = m_editorView->selectedItems();
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::update(const QPointF &updatePoint)
|
||||
{
|
||||
m_selectionRectangleElement.setRect(m_beginPoint, updatePoint);
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::end()
|
||||
{
|
||||
m_oldSelectionList.clear();
|
||||
m_selectionRectangleElement.hide();
|
||||
m_isActive = false;
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::select(SelectionType selectionType)
|
||||
{
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(m_editorView);
|
||||
QList<QGraphicsItem*> itemList
|
||||
= inspectorPrivate->selectableItems(m_selectionRectangleElement.rect(),
|
||||
Qt::IntersectsItemShape);
|
||||
QList<QGraphicsItem*> newSelectionList;
|
||||
|
||||
foreach (QGraphicsItem* item, itemList) {
|
||||
if (item
|
||||
&& item->parentItem()
|
||||
&& !newSelectionList.contains(item)
|
||||
//&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test
|
||||
)
|
||||
{
|
||||
newSelectionList.append(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (newSelectionList.isEmpty() && m_beginFormEditorItem)
|
||||
newSelectionList.append(m_beginFormEditorItem);
|
||||
|
||||
QList<QGraphicsItem*> resultList;
|
||||
|
||||
switch(selectionType) {
|
||||
case AddToSelection: {
|
||||
resultList.append(m_oldSelectionList);
|
||||
resultList.append(newSelectionList);
|
||||
}
|
||||
break;
|
||||
case ReplaceSelection: {
|
||||
resultList.append(newSelectionList);
|
||||
}
|
||||
break;
|
||||
case RemoveFromSelection: {
|
||||
QSet<QGraphicsItem*> oldSelectionSet(m_oldSelectionList.toSet());
|
||||
QSet<QGraphicsItem*> newSelectionSet(newSelectionList.toSet());
|
||||
resultList.append(oldSelectionSet.subtract(newSelectionSet).toList());
|
||||
}
|
||||
}
|
||||
|
||||
m_editorView->setSelectedItems(resultList);
|
||||
}
|
||||
|
||||
|
||||
void LiveRubberBandSelectionManipulator::setItems(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
m_itemList = itemList;
|
||||
}
|
||||
|
||||
QPointF LiveRubberBandSelectionManipulator::beginPoint() const
|
||||
{
|
||||
return m_beginPoint;
|
||||
}
|
||||
|
||||
bool LiveRubberBandSelectionManipulator::isActive() const
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef RUBBERBANDSELECTIONMANIPULATOR_H
|
||||
#define RUBBERBANDSELECTIONMANIPULATOR_H
|
||||
|
||||
|
||||
#include "liveselectionrectangle.h"
|
||||
|
||||
#include <QPointF>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class LiveRubberBandSelectionManipulator
|
||||
{
|
||||
public:
|
||||
enum SelectionType {
|
||||
ReplaceSelection,
|
||||
AddToSelection,
|
||||
RemoveFromSelection
|
||||
};
|
||||
|
||||
LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
|
||||
QDeclarativeViewInspector *editorView);
|
||||
|
||||
void setItems(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
void begin(const QPointF& beginPoint);
|
||||
void update(const QPointF& updatePoint);
|
||||
void end();
|
||||
|
||||
void clear();
|
||||
|
||||
void select(SelectionType selectionType);
|
||||
|
||||
QPointF beginPoint() const;
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
protected:
|
||||
QGraphicsItem *topFormEditorItem(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
private:
|
||||
QList<QGraphicsItem*> m_itemList;
|
||||
QList<QGraphicsItem*> m_oldSelectionList;
|
||||
LiveSelectionRectangle m_selectionRectangleElement;
|
||||
QPointF m_beginPoint;
|
||||
QDeclarativeViewInspector *m_editorView;
|
||||
QGraphicsItem *m_beginFormEditorItem;
|
||||
bool m_isActive;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RUBBERBANDSELECTIONMANIPULATOR_H
|
||||
@@ -1,105 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "liveselectionindicator.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QGraphicsObject>
|
||||
#include <QGraphicsScene>
|
||||
#include <QPen>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector,
|
||||
QGraphicsObject *layerItem)
|
||||
: m_layerItem(layerItem)
|
||||
, m_view(viewInspector)
|
||||
{
|
||||
}
|
||||
|
||||
LiveSelectionIndicator::~LiveSelectionIndicator()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void LiveSelectionIndicator::show()
|
||||
{
|
||||
foreach (QGraphicsRectItem *item, m_indicatorShapeHash)
|
||||
item->show();
|
||||
}
|
||||
|
||||
void LiveSelectionIndicator::hide()
|
||||
{
|
||||
foreach (QGraphicsRectItem *item, m_indicatorShapeHash)
|
||||
item->hide();
|
||||
}
|
||||
|
||||
void LiveSelectionIndicator::clear()
|
||||
{
|
||||
if (!m_layerItem.isNull()) {
|
||||
QGraphicsScene *scene = m_layerItem.data()->scene();
|
||||
foreach (QGraphicsRectItem *item, m_indicatorShapeHash) {
|
||||
scene->removeItem(item);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
m_indicatorShapeHash.clear();
|
||||
|
||||
}
|
||||
|
||||
void LiveSelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList)
|
||||
{
|
||||
clear();
|
||||
|
||||
foreach (const QWeakPointer<QGraphicsObject> &object, itemList) {
|
||||
if (object.isNull())
|
||||
continue;
|
||||
|
||||
QGraphicsItem *item = object.data();
|
||||
|
||||
if (!m_indicatorShapeHash.contains(item)) {
|
||||
QGraphicsRectItem *selectionIndicator = new QGraphicsRectItem(m_layerItem.data());
|
||||
m_indicatorShapeHash.insert(item, selectionIndicator);
|
||||
|
||||
const QRectF boundingRect = m_view->adjustToScreenBoundaries(item->mapRectToScene(item->boundingRect()));
|
||||
const QRectF boundingRectInLayerItemSpace = m_layerItem.data()->mapRectFromScene(boundingRect);
|
||||
|
||||
selectionIndicator->setData(Constants::EditorItemDataKey, true);
|
||||
selectionIndicator->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
selectionIndicator->setRect(boundingRectInLayerItemSpace);
|
||||
selectionIndicator->setPen(QColor(108, 141, 221));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace QmlJSDebugger
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVESELECTIONINDICATOR_H
|
||||
#define LIVESELECTIONINDICATOR_H
|
||||
|
||||
#include <QWeakPointer>
|
||||
#include <QHash>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsObject;
|
||||
class QGraphicsRectItem;
|
||||
class QGraphicsItem;
|
||||
class QPolygonF;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class LiveSelectionIndicator
|
||||
{
|
||||
public:
|
||||
LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, QGraphicsObject *layerItem);
|
||||
~LiveSelectionIndicator();
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
|
||||
void clear();
|
||||
|
||||
void setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList);
|
||||
|
||||
private:
|
||||
QHash<QGraphicsItem*, QGraphicsRectItem *> m_indicatorShapeHash;
|
||||
QWeakPointer<QGraphicsObject> m_layerItem;
|
||||
QDeclarativeViewInspector *m_view;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // LIVESELECTIONINDICATOR_H
|
||||
@@ -1,100 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "liveselectionrectangle.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QPen>
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QGraphicsObject>
|
||||
#include <QGraphicsScene>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class SelectionRectShape : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
SelectionRectShape(QGraphicsItem *parent = 0) : QGraphicsRectItem(parent) {}
|
||||
int type() const { return Constants::EditorItemType; }
|
||||
};
|
||||
|
||||
LiveSelectionRectangle::LiveSelectionRectangle(QGraphicsObject *layerItem)
|
||||
: m_controlShape(new SelectionRectShape(layerItem)),
|
||||
m_layerItem(layerItem)
|
||||
{
|
||||
m_controlShape->setPen(QPen(Qt::black));
|
||||
m_controlShape->setBrush(QColor(128, 128, 128, 50));
|
||||
}
|
||||
|
||||
LiveSelectionRectangle::~LiveSelectionRectangle()
|
||||
{
|
||||
if (m_layerItem)
|
||||
m_layerItem.data()->scene()->removeItem(m_controlShape);
|
||||
}
|
||||
|
||||
void LiveSelectionRectangle::clear()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
void LiveSelectionRectangle::show()
|
||||
{
|
||||
m_controlShape->show();
|
||||
}
|
||||
|
||||
void LiveSelectionRectangle::hide()
|
||||
{
|
||||
m_controlShape->hide();
|
||||
}
|
||||
|
||||
QRectF LiveSelectionRectangle::rect() const
|
||||
{
|
||||
return m_controlShape->mapFromScene(m_controlShape->rect()).boundingRect();
|
||||
}
|
||||
|
||||
void LiveSelectionRectangle::setRect(const QPointF &firstPoint,
|
||||
const QPointF &secondPoint)
|
||||
{
|
||||
double firstX = std::floor(firstPoint.x()) + 0.5;
|
||||
double firstY = std::floor(firstPoint.y()) + 0.5;
|
||||
double secondX = std::floor(secondPoint.x()) + 0.5;
|
||||
double secondY = std::floor(secondPoint.y()) + 0.5;
|
||||
QPointF topLeftPoint(firstX < secondX ? firstX : secondX,
|
||||
firstY < secondY ? firstY : secondY);
|
||||
QPointF bottomRightPoint(firstX > secondX ? firstX : secondX,
|
||||
firstY > secondY ? firstY : secondY);
|
||||
|
||||
QRectF rect(topLeftPoint, bottomRightPoint);
|
||||
m_controlShape->setRect(rect);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVESELECTIONRECTANGLE_H
|
||||
#define LIVESELECTIONRECTANGLE_H
|
||||
|
||||
#include <QWeakPointer>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsObject)
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QPointF)
|
||||
QT_FORWARD_DECLARE_CLASS(QRectF)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class LiveSelectionRectangle
|
||||
{
|
||||
public:
|
||||
LiveSelectionRectangle(QGraphicsObject *layerItem);
|
||||
~LiveSelectionRectangle();
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
|
||||
void clear();
|
||||
|
||||
void setRect(const QPointF &firstPoint,
|
||||
const QPointF &secondPoint);
|
||||
|
||||
QRectF rect() const;
|
||||
|
||||
private:
|
||||
QGraphicsRectItem *m_controlShape;
|
||||
QWeakPointer<QGraphicsObject> m_layerItem;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // LIVESELECTIONRECTANGLE_H
|
||||
@@ -1,424 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "liveselectiontool.h"
|
||||
#include "livelayeritem.h"
|
||||
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWheelEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QGraphicsObject>
|
||||
|
||||
#include <QDeclarativeItem>
|
||||
#include <QDeclarativeEngine>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveSelectionTool::LiveSelectionTool(QDeclarativeViewInspector *editorView) :
|
||||
AbstractLiveEditTool(editorView),
|
||||
m_rubberbandSelectionMode(false),
|
||||
m_rubberbandSelectionManipulator(
|
||||
QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer, editorView),
|
||||
m_singleSelectionManipulator(editorView),
|
||||
m_selectionIndicator(editorView,
|
||||
QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer),
|
||||
//m_resizeIndicator(editorView->manipulatorLayer()),
|
||||
m_selectOnlyContentItems(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LiveSelectionTool::~LiveSelectionTool()
|
||||
{
|
||||
}
|
||||
|
||||
void LiveSelectionTool::setRubberbandSelectionMode(bool value)
|
||||
{
|
||||
m_rubberbandSelectionMode = value;
|
||||
}
|
||||
|
||||
LiveSingleSelectionManipulator::SelectionType LiveSelectionTool::getSelectionType(Qt::KeyboardModifiers
|
||||
modifiers)
|
||||
{
|
||||
LiveSingleSelectionManipulator::SelectionType selectionType
|
||||
= LiveSingleSelectionManipulator::ReplaceSelection;
|
||||
if (modifiers.testFlag(Qt::ControlModifier)) {
|
||||
selectionType = LiveSingleSelectionManipulator::RemoveFromSelection;
|
||||
} else if (modifiers.testFlag(Qt::ShiftModifier)) {
|
||||
selectionType = LiveSingleSelectionManipulator::AddToSelection;
|
||||
}
|
||||
return selectionType;
|
||||
}
|
||||
|
||||
bool LiveSelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
|
||||
{
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(inspector());
|
||||
const QList<QGraphicsItem*> selectedItems = inspectorPrivate->selectedItems();
|
||||
|
||||
if (selectedItems.isEmpty())
|
||||
return false;
|
||||
|
||||
foreach (QGraphicsItem *item, itemList)
|
||||
if (selectedItems.contains(item))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void LiveSelectionTool::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(inspector());
|
||||
QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos());
|
||||
LiveSingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers());
|
||||
|
||||
if (event->buttons() & Qt::LeftButton) {
|
||||
m_mousePressTimer.start();
|
||||
|
||||
if (m_rubberbandSelectionMode) {
|
||||
m_rubberbandSelectionManipulator.begin(event->pos());
|
||||
} else {
|
||||
m_singleSelectionManipulator.begin(event->pos());
|
||||
m_singleSelectionManipulator.select(selectionType, m_selectOnlyContentItems);
|
||||
}
|
||||
} else if (event->buttons() & Qt::RightButton) {
|
||||
createContextMenu(itemList, event->globalPos());
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos)
|
||||
{
|
||||
QMenu contextMenu;
|
||||
connect(&contextMenu, SIGNAL(hovered(QAction*)),
|
||||
this, SLOT(contextMenuElementHovered(QAction*)));
|
||||
|
||||
m_contextMenuItemList = itemList;
|
||||
|
||||
contextMenu.addAction("Items");
|
||||
contextMenu.addSeparator();
|
||||
int shortcutKey = Qt::Key_1;
|
||||
bool addKeySequence = true;
|
||||
int i = 0;
|
||||
|
||||
foreach (QGraphicsItem * const item, itemList) {
|
||||
QString itemTitle = titleForItem(item);
|
||||
QAction *elementAction = contextMenu.addAction(itemTitle, this,
|
||||
SLOT(contextMenuElementSelected()));
|
||||
|
||||
if (inspector()->selectedItems().contains(item)) {
|
||||
QFont boldFont = elementAction->font();
|
||||
boldFont.setBold(true);
|
||||
elementAction->setFont(boldFont);
|
||||
}
|
||||
|
||||
elementAction->setData(i);
|
||||
if (addKeySequence)
|
||||
elementAction->setShortcut(QKeySequence(shortcutKey));
|
||||
|
||||
shortcutKey++;
|
||||
if (shortcutKey > Qt::Key_9)
|
||||
addKeySequence = false;
|
||||
|
||||
++i;
|
||||
}
|
||||
// add root item separately
|
||||
// QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem()));
|
||||
// contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected()));
|
||||
// m_contextMenuItemList.append(view()->currentRootItem());
|
||||
|
||||
contextMenu.exec(globalPos);
|
||||
m_contextMenuItemList.clear();
|
||||
}
|
||||
|
||||
void LiveSelectionTool::contextMenuElementSelected()
|
||||
{
|
||||
QAction *senderAction = static_cast<QAction*>(sender());
|
||||
int itemListIndex = senderAction->data().toInt();
|
||||
if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
|
||||
|
||||
QPointF updatePt(0, 0);
|
||||
QGraphicsItem *item = m_contextMenuItemList.at(itemListIndex);
|
||||
m_singleSelectionManipulator.begin(updatePt);
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection,
|
||||
QList<QGraphicsItem*>() << item,
|
||||
false);
|
||||
m_singleSelectionManipulator.end(updatePt);
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::contextMenuElementHovered(QAction *action)
|
||||
{
|
||||
int itemListIndex = action->data().toInt();
|
||||
if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
|
||||
QGraphicsObject *item = m_contextMenuItemList.at(itemListIndex)->toGraphicsObject();
|
||||
QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item);
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_singleSelectionManipulator.isActive()) {
|
||||
QPointF mouseMovementVector = m_singleSelectionManipulator.beginPoint() - event->pos();
|
||||
|
||||
if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance)
|
||||
&& (m_mousePressTimer.elapsed() > Constants::DragStartTime))
|
||||
{
|
||||
m_singleSelectionManipulator.end(event->pos());
|
||||
//view()->changeToMoveTool(m_singleSelectionManipulator.beginPoint());
|
||||
return;
|
||||
}
|
||||
} else if (m_rubberbandSelectionManipulator.isActive()) {
|
||||
QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos();
|
||||
|
||||
if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance)
|
||||
&& (m_mousePressTimer.elapsed() > Constants::DragStartTime)) {
|
||||
m_rubberbandSelectionManipulator.update(event->pos());
|
||||
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier))
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::RemoveFromSelection);
|
||||
else if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::AddToSelection);
|
||||
else
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::ReplaceSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::hoverMoveEvent(QMouseEvent * event)
|
||||
{
|
||||
// ### commented out until move tool is re-enabled
|
||||
// QList<QGraphicsItem*> itemList = view()->items(event->pos());
|
||||
// if (!itemList.isEmpty() && !m_rubberbandSelectionMode) {
|
||||
//
|
||||
// foreach (QGraphicsItem *item, itemList) {
|
||||
// if (item->type() == Constants::ResizeHandleItemType) {
|
||||
// ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(item);
|
||||
// if (resizeHandle)
|
||||
// view()->changeTool(Constants::ResizeToolMode);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if (topSelectedItemIsMovable(itemList))
|
||||
// view()->changeTool(Constants::MoveToolMode);
|
||||
// }
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(inspector());
|
||||
|
||||
QList<QGraphicsItem*> selectableItemList = inspectorPrivate->selectableItems(event->pos());
|
||||
if (!selectableItemList.isEmpty()) {
|
||||
QGraphicsObject *item = selectableItemList.first()->toGraphicsObject();
|
||||
if (item)
|
||||
QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QDeclarativeViewInspectorPrivate::get(inspector())->clearHighlight();
|
||||
}
|
||||
|
||||
void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_singleSelectionManipulator.isActive()) {
|
||||
m_singleSelectionManipulator.end(event->pos());
|
||||
} else if (m_rubberbandSelectionManipulator.isActive()) {
|
||||
QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos();
|
||||
if (mouseMovementVector.toPoint().manhattanLength() < Constants::DragStartDistance) {
|
||||
m_singleSelectionManipulator.begin(event->pos());
|
||||
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier))
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection,
|
||||
m_selectOnlyContentItems);
|
||||
else if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection,
|
||||
m_selectOnlyContentItems);
|
||||
else
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection,
|
||||
m_selectOnlyContentItems);
|
||||
|
||||
m_singleSelectionManipulator.end(event->pos());
|
||||
} else {
|
||||
m_rubberbandSelectionManipulator.update(event->pos());
|
||||
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier))
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::RemoveFromSelection);
|
||||
else if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::AddToSelection);
|
||||
else
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::ReplaceSelection);
|
||||
|
||||
m_rubberbandSelectionManipulator.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void LiveSelectionTool::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch(event->key()) {
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Right:
|
||||
case Qt::Key_Up:
|
||||
case Qt::Key_Down:
|
||||
// disabled for now, cannot move stuff yet.
|
||||
//view()->changeTool(Constants::MoveToolMode);
|
||||
//view()->currentTool()->keyPressEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LiveSelectionTool::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode)
|
||||
return;
|
||||
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(inspector());
|
||||
QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos());
|
||||
|
||||
if (itemList.isEmpty())
|
||||
return;
|
||||
|
||||
int selectedIdx = 0;
|
||||
if (!inspector()->selectedItems().isEmpty()) {
|
||||
selectedIdx = itemList.indexOf(inspector()->selectedItems().first());
|
||||
if (selectedIdx >= 0) {
|
||||
if (event->delta() > 0) {
|
||||
selectedIdx++;
|
||||
if (selectedIdx == itemList.length())
|
||||
selectedIdx = 0;
|
||||
} else if (event->delta() < 0) {
|
||||
selectedIdx--;
|
||||
if (selectedIdx == -1)
|
||||
selectedIdx = itemList.length() - 1;
|
||||
}
|
||||
} else {
|
||||
selectedIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QPointF updatePt(0, 0);
|
||||
m_singleSelectionManipulator.begin(updatePt);
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::ReplaceSelection,
|
||||
QList<QGraphicsItem*>() << itemList.at(selectedIdx),
|
||||
false);
|
||||
m_singleSelectionManipulator.end(updatePt);
|
||||
|
||||
}
|
||||
|
||||
void LiveSelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems)
|
||||
{
|
||||
m_selectOnlyContentItems = selectOnlyContentItems;
|
||||
}
|
||||
|
||||
void LiveSelectionTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void LiveSelectionTool::clear()
|
||||
{
|
||||
view()->setCursor(Qt::ArrowCursor);
|
||||
m_rubberbandSelectionManipulator.clear(),
|
||||
m_singleSelectionManipulator.clear();
|
||||
m_selectionIndicator.clear();
|
||||
//m_resizeIndicator.clear();
|
||||
}
|
||||
|
||||
void LiveSelectionTool::selectedItemsChanged(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
foreach (const QWeakPointer<QGraphicsObject> &obj, m_selectedItemList) {
|
||||
if (!obj.isNull()) {
|
||||
disconnect(obj.data(), SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
|
||||
disconnect(obj.data(), SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
|
||||
disconnect(obj.data(), SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects()));
|
||||
disconnect(obj.data(), SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects()));
|
||||
disconnect(obj.data(), SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects()));
|
||||
}
|
||||
}
|
||||
|
||||
QList<QGraphicsObject*> objects = toGraphicsObjectList(itemList);
|
||||
m_selectedItemList.clear();
|
||||
|
||||
foreach (QGraphicsObject *obj, objects) {
|
||||
m_selectedItemList.append(obj);
|
||||
connect(obj, SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
|
||||
connect(obj, SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
|
||||
connect(obj, SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects()));
|
||||
connect(obj, SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects()));
|
||||
connect(obj, SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects()));
|
||||
}
|
||||
|
||||
m_selectionIndicator.setItems(m_selectedItemList);
|
||||
//m_resizeIndicator.setItems(toGraphicsObjectList(itemList));
|
||||
}
|
||||
|
||||
void LiveSelectionTool::repaintBoundingRects()
|
||||
{
|
||||
m_selectionIndicator.setItems(m_selectedItemList);
|
||||
}
|
||||
|
||||
void LiveSelectionTool::selectUnderPoint(QMouseEvent *event)
|
||||
{
|
||||
m_singleSelectionManipulator.begin(event->pos());
|
||||
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier))
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection,
|
||||
m_selectOnlyContentItems);
|
||||
else if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection,
|
||||
m_selectOnlyContentItems);
|
||||
else
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection,
|
||||
m_selectOnlyContentItems);
|
||||
|
||||
m_singleSelectionManipulator.end(event->pos());
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,109 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVESELECTIONTOOL_H
|
||||
#define LIVESELECTIONTOOL_H
|
||||
|
||||
|
||||
#include "abstractliveedittool.h"
|
||||
#include "liverubberbandselectionmanipulator.h"
|
||||
#include "livesingleselectionmanipulator.h"
|
||||
#include "liveselectionindicator.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QTime>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QMouseEvent)
|
||||
QT_FORWARD_DECLARE_CLASS(QKeyEvent)
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class LiveSelectionTool : public AbstractLiveEditTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LiveSelectionTool(QDeclarativeViewInspector* editorView);
|
||||
~LiveSelectionTool();
|
||||
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
void hoverMoveEvent(QMouseEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
|
||||
// QVariant itemChange(const QList<QGraphicsItem*> &itemList,
|
||||
// QGraphicsItem::GraphicsItemChange change,
|
||||
// const QVariant &value );
|
||||
|
||||
// void update();
|
||||
|
||||
void clear();
|
||||
|
||||
void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
void selectUnderPoint(QMouseEvent *event);
|
||||
|
||||
void setSelectOnlyContentItems(bool selectOnlyContentItems);
|
||||
|
||||
void setRubberbandSelectionMode(bool value);
|
||||
|
||||
private slots:
|
||||
void contextMenuElementSelected();
|
||||
void contextMenuElementHovered(QAction *action);
|
||||
void repaintBoundingRects();
|
||||
|
||||
private:
|
||||
void createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos);
|
||||
LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers);
|
||||
bool alreadySelected(const QList<QGraphicsItem*> &itemList) const;
|
||||
|
||||
private:
|
||||
bool m_rubberbandSelectionMode;
|
||||
LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator;
|
||||
LiveSingleSelectionManipulator m_singleSelectionManipulator;
|
||||
LiveSelectionIndicator m_selectionIndicator;
|
||||
//ResizeIndicator m_resizeIndicator;
|
||||
QTime m_mousePressTimer;
|
||||
bool m_selectOnlyContentItems;
|
||||
|
||||
QList<QWeakPointer<QGraphicsObject> > m_selectedItemList;
|
||||
|
||||
QList<QGraphicsItem*> m_contextMenuItemList;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // LIVESELECTIONTOOL_H
|
||||
@@ -1,138 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "livesingleselectionmanipulator.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveSingleSelectionManipulator::LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView)
|
||||
: m_editorView(editorView),
|
||||
m_isActive(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LiveSingleSelectionManipulator::begin(const QPointF &beginPoint)
|
||||
{
|
||||
m_beginPoint = beginPoint;
|
||||
m_isActive = true;
|
||||
m_oldSelectionList = QDeclarativeViewInspectorPrivate::get(m_editorView)->selectedItems();
|
||||
}
|
||||
|
||||
void LiveSingleSelectionManipulator::update(const QPointF &/*updatePoint*/)
|
||||
{
|
||||
m_oldSelectionList.clear();
|
||||
}
|
||||
|
||||
void LiveSingleSelectionManipulator::clear()
|
||||
{
|
||||
m_beginPoint = QPointF();
|
||||
m_oldSelectionList.clear();
|
||||
}
|
||||
|
||||
|
||||
void LiveSingleSelectionManipulator::end(const QPointF &/*updatePoint*/)
|
||||
{
|
||||
m_oldSelectionList.clear();
|
||||
m_isActive = false;
|
||||
}
|
||||
|
||||
void LiveSingleSelectionManipulator::select(SelectionType selectionType,
|
||||
const QList<QGraphicsItem*> &items,
|
||||
bool /*selectOnlyContentItems*/)
|
||||
{
|
||||
QGraphicsItem *selectedItem = 0;
|
||||
|
||||
foreach (QGraphicsItem* item, items)
|
||||
{
|
||||
//FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
||||
if (item
|
||||
/*&& !formEditorItem->qmlItemNode().isRootNode()
|
||||
&& (formEditorItem->qmlItemNode().hasShowContent() || !selectOnlyContentItems)*/)
|
||||
{
|
||||
selectedItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> resultList;
|
||||
|
||||
switch(selectionType) {
|
||||
case AddToSelection: {
|
||||
resultList.append(m_oldSelectionList);
|
||||
if (selectedItem && !m_oldSelectionList.contains(selectedItem))
|
||||
resultList.append(selectedItem);
|
||||
}
|
||||
break;
|
||||
case ReplaceSelection: {
|
||||
if (selectedItem)
|
||||
resultList.append(selectedItem);
|
||||
}
|
||||
break;
|
||||
case RemoveFromSelection: {
|
||||
resultList.append(m_oldSelectionList);
|
||||
if (selectedItem)
|
||||
resultList.removeAll(selectedItem);
|
||||
}
|
||||
break;
|
||||
case InvertSelection: {
|
||||
if (selectedItem
|
||||
&& !m_oldSelectionList.contains(selectedItem))
|
||||
{
|
||||
resultList.append(selectedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_editorView->setSelectedItems(resultList);
|
||||
}
|
||||
|
||||
void LiveSingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems)
|
||||
{
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate =
|
||||
QDeclarativeViewInspectorPrivate::get(m_editorView);
|
||||
QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(m_beginPoint);
|
||||
select(selectionType, itemList, selectOnlyContentItems);
|
||||
}
|
||||
|
||||
|
||||
bool LiveSingleSelectionManipulator::isActive() const
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
QPointF LiveSingleSelectionManipulator::beginPoint() const
|
||||
{
|
||||
return m_beginPoint;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVESINGLESELECTIONMANIPULATOR_H
|
||||
#define LIVESINGLESELECTIONMANIPULATOR_H
|
||||
|
||||
#include <QPointF>
|
||||
#include <QList>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsItem);
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class LiveSingleSelectionManipulator
|
||||
{
|
||||
public:
|
||||
LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView);
|
||||
|
||||
enum SelectionType {
|
||||
ReplaceSelection,
|
||||
AddToSelection,
|
||||
RemoveFromSelection,
|
||||
InvertSelection
|
||||
};
|
||||
|
||||
void begin(const QPointF& beginPoint);
|
||||
void update(const QPointF& updatePoint);
|
||||
void end(const QPointF& updatePoint);
|
||||
|
||||
void select(SelectionType selectionType, const QList<QGraphicsItem*> &items,
|
||||
bool selectOnlyContentItems);
|
||||
void select(SelectionType selectionType, bool selectOnlyContentItems);
|
||||
|
||||
void clear();
|
||||
|
||||
QPointF beginPoint() const;
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
private:
|
||||
QList<QGraphicsItem*> m_oldSelectionList;
|
||||
QPointF m_beginPoint;
|
||||
QDeclarativeViewInspector *m_editorView;
|
||||
bool m_isActive;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // LIVESINGLESELECTIONMANIPULATOR_H
|
||||
@@ -1,116 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "subcomponentmasklayeritem.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include <QPolygonF>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector,
|
||||
QGraphicsItem *parentItem) :
|
||||
QGraphicsPolygonItem(parentItem),
|
||||
m_inspector(inspector),
|
||||
m_currentItem(0),
|
||||
m_borderRect(new QGraphicsRectItem(this))
|
||||
{
|
||||
m_borderRect->setRect(0,0,0,0);
|
||||
m_borderRect->setPen(QPen(QColor(60, 60, 60), 1));
|
||||
m_borderRect->setData(Constants::EditorItemDataKey, QVariant(true));
|
||||
|
||||
setBrush(QBrush(QColor(160,160,160)));
|
||||
setPen(Qt::NoPen);
|
||||
}
|
||||
|
||||
int SubcomponentMaskLayerItem::type() const
|
||||
{
|
||||
return Constants::EditorItemType;
|
||||
}
|
||||
|
||||
static QRectF resizeRect(const QRectF &newRect, const QRectF &oldRect)
|
||||
{
|
||||
QRectF result = newRect;
|
||||
if (oldRect.left() < newRect.left())
|
||||
result.setLeft(oldRect.left());
|
||||
|
||||
if (oldRect.top() < newRect.top())
|
||||
result.setTop(oldRect.top());
|
||||
|
||||
if (oldRect.right() > newRect.right())
|
||||
result.setRight(oldRect.right());
|
||||
|
||||
if (oldRect.bottom() > newRect.bottom())
|
||||
result.setBottom(oldRect.bottom());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static QPolygonF regionToPolygon(const QRegion ®ion)
|
||||
{
|
||||
QPainterPath path;
|
||||
foreach (const QRect &rect, region.rects())
|
||||
path.addRect(rect);
|
||||
return path.toFillPolygon();
|
||||
}
|
||||
|
||||
void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item)
|
||||
{
|
||||
QGraphicsItem *prevItem = m_currentItem;
|
||||
m_currentItem = item;
|
||||
|
||||
if (!m_currentItem)
|
||||
return;
|
||||
|
||||
QRect viewRect = m_inspector->declarativeView()->rect();
|
||||
viewRect = m_inspector->declarativeView()->mapToScene(viewRect).boundingRect().toRect();
|
||||
|
||||
QRectF itemRect = item->boundingRect() | item->childrenBoundingRect();
|
||||
itemRect = item->mapRectToScene(itemRect);
|
||||
|
||||
// if updating the same item as before, resize the rectangle only bigger, not smaller.
|
||||
if (prevItem == item && prevItem != 0) {
|
||||
m_itemPolyRect = resizeRect(itemRect, m_itemPolyRect);
|
||||
} else {
|
||||
m_itemPolyRect = itemRect;
|
||||
}
|
||||
QRectF borderRect = m_itemPolyRect;
|
||||
borderRect.adjust(-1, -1, 1, 1);
|
||||
m_borderRect->setRect(borderRect);
|
||||
|
||||
const QRegion externalRegion = QRegion(viewRect).subtracted(m_itemPolyRect.toRect());
|
||||
setPolygon(regionToPolygon(externalRegion));
|
||||
}
|
||||
|
||||
QGraphicsItem *SubcomponentMaskLayerItem::currentItem() const
|
||||
{
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,59 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SUBCOMPONENTMASKLAYERITEM_H
|
||||
#define SUBCOMPONENTMASKLAYERITEM_H
|
||||
|
||||
#include <QGraphicsPolygonItem>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class SubcomponentMaskLayerItem : public QGraphicsPolygonItem
|
||||
{
|
||||
public:
|
||||
explicit SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector,
|
||||
QGraphicsItem *parentItem = 0);
|
||||
int type() const;
|
||||
void setCurrentItem(QGraphicsItem *item);
|
||||
void setBoundingBox(const QRectF &boundingBox);
|
||||
QGraphicsItem *currentItem() const;
|
||||
QRectF itemRect() const;
|
||||
|
||||
private:
|
||||
QDeclarativeViewInspector *m_inspector;
|
||||
QGraphicsItem *m_currentItem;
|
||||
QGraphicsRectItem *m_borderRect;
|
||||
QRectF m_itemPolyRect;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // SUBCOMPONENTMASKLAYERITEM_H
|
||||
@@ -1,323 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "zoomtool.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
#include <QRectF>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
ZoomTool::ZoomTool(QDeclarativeViewInspector *view) :
|
||||
AbstractLiveEditTool(view),
|
||||
m_rubberbandManipulator(),
|
||||
m_smoothZoomMultiplier(0.05f),
|
||||
m_currentScale(1.0f)
|
||||
{
|
||||
m_zoomTo100Action = new QAction(tr("Zoom to &100%"), this);
|
||||
m_zoomInAction = new QAction(tr("Zoom In"), this);
|
||||
m_zoomOutAction = new QAction(tr("Zoom Out"), this);
|
||||
m_zoomInAction->setShortcut(QKeySequence(Qt::Key_Plus));
|
||||
m_zoomOutAction->setShortcut(QKeySequence(Qt::Key_Minus));
|
||||
|
||||
|
||||
LiveLayerItem *layerItem = QDeclarativeViewInspectorPrivate::get(view)->manipulatorLayer;
|
||||
QGraphicsObject *layerObject = reinterpret_cast<QGraphicsObject *>(layerItem);
|
||||
m_rubberbandManipulator = new LiveRubberBandSelectionManipulator(layerObject, view);
|
||||
|
||||
|
||||
connect(m_zoomTo100Action, SIGNAL(triggered()), SLOT(zoomTo100()));
|
||||
connect(m_zoomInAction, SIGNAL(triggered()), SLOT(zoomIn()));
|
||||
connect(m_zoomOutAction, SIGNAL(triggered()), SLOT(zoomOut()));
|
||||
}
|
||||
|
||||
ZoomTool::~ZoomTool()
|
||||
{
|
||||
delete m_rubberbandManipulator;
|
||||
}
|
||||
|
||||
void ZoomTool::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
|
||||
QPointF scenePos = view()->mapToScene(event->pos());
|
||||
|
||||
if (event->buttons() & Qt::RightButton) {
|
||||
QMenu contextMenu;
|
||||
contextMenu.addAction(m_zoomTo100Action);
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction(m_zoomInAction);
|
||||
contextMenu.addAction(m_zoomOutAction);
|
||||
contextMenu.exec(event->globalPos());
|
||||
} else if (event->buttons() & Qt::LeftButton) {
|
||||
m_dragBeginPos = scenePos;
|
||||
m_dragStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ZoomTool::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
|
||||
QPointF scenePos = view()->mapToScene(event->pos());
|
||||
|
||||
if (event->buttons() & Qt::LeftButton
|
||||
&& (QPointF(scenePos - m_dragBeginPos).manhattanLength()
|
||||
> Constants::DragStartDistance / 3)
|
||||
&& !m_dragStarted)
|
||||
{
|
||||
m_dragStarted = true;
|
||||
m_rubberbandManipulator->begin(m_dragBeginPos);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_dragStarted)
|
||||
m_rubberbandManipulator->update(scenePos);
|
||||
|
||||
}
|
||||
|
||||
void ZoomTool::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
QPointF scenePos = view()->mapToScene(event->pos());
|
||||
|
||||
if (m_dragStarted) {
|
||||
m_rubberbandManipulator->end();
|
||||
|
||||
int x1 = qMin(scenePos.x(), m_rubberbandManipulator->beginPoint().x());
|
||||
int x2 = qMax(scenePos.x(), m_rubberbandManipulator->beginPoint().x());
|
||||
int y1 = qMin(scenePos.y(), m_rubberbandManipulator->beginPoint().y());
|
||||
int y2 = qMax(scenePos.y(), m_rubberbandManipulator->beginPoint().y());
|
||||
|
||||
QPointF scenePosTopLeft = QPoint(x1, y1);
|
||||
QPointF scenePosBottomRight = QPoint(x2, y2);
|
||||
|
||||
QRectF sceneArea(scenePosTopLeft, scenePosBottomRight);
|
||||
|
||||
m_currentScale = qMin(view()->rect().width() / sceneArea.width(),
|
||||
view()->rect().height() / sceneArea.height());
|
||||
|
||||
|
||||
QTransform transform;
|
||||
transform.scale(m_currentScale, m_currentScale);
|
||||
|
||||
view()->setTransform(transform);
|
||||
view()->setSceneRect(sceneArea);
|
||||
} else {
|
||||
Qt::KeyboardModifier modifierKey = Qt::ControlModifier;
|
||||
#ifdef Q_OS_MAC
|
||||
modifierKey = Qt::AltModifier;
|
||||
#endif
|
||||
if (event->modifiers() & modifierKey) {
|
||||
zoomOut();
|
||||
} else {
|
||||
zoomIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZoomTool::zoomIn()
|
||||
{
|
||||
m_currentScale = nextZoomScale(ZoomIn);
|
||||
scaleView(view()->mapToScene(m_mousePos));
|
||||
}
|
||||
|
||||
void ZoomTool::zoomOut()
|
||||
{
|
||||
m_currentScale = nextZoomScale(ZoomOut);
|
||||
scaleView(view()->mapToScene(m_mousePos));
|
||||
}
|
||||
|
||||
void ZoomTool::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
}
|
||||
|
||||
|
||||
void ZoomTool::hoverMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
}
|
||||
|
||||
|
||||
void ZoomTool::keyPressEvent(QKeyEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ZoomTool::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (event->orientation() != Qt::Vertical)
|
||||
return;
|
||||
|
||||
Qt::KeyboardModifier smoothZoomModifier = Qt::ControlModifier;
|
||||
if (event->modifiers() & smoothZoomModifier) {
|
||||
int numDegrees = event->delta() / 8;
|
||||
m_currentScale += m_smoothZoomMultiplier * (numDegrees / 15.0f);
|
||||
|
||||
scaleView(view()->mapToScene(m_mousePos));
|
||||
|
||||
} else if (!event->modifiers()) {
|
||||
if (event->delta() > 0) {
|
||||
m_currentScale = nextZoomScale(ZoomIn);
|
||||
} else if (event->delta() < 0) {
|
||||
m_currentScale = nextZoomScale(ZoomOut);
|
||||
}
|
||||
scaleView(view()->mapToScene(m_mousePos));
|
||||
}
|
||||
}
|
||||
|
||||
void ZoomTool::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:
|
||||
{
|
||||
m_currentScale = ((event->key() - Qt::Key_0) * 1.0f);
|
||||
scaleView(view()->mapToScene(m_mousePos)); // view()->mapToScene(view()->rect().center())
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ZoomTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ZoomTool::clear()
|
||||
{
|
||||
view()->setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void ZoomTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ZoomTool::scaleView(const QPointF ¢erPos)
|
||||
{
|
||||
|
||||
QTransform transform;
|
||||
transform.scale(m_currentScale, m_currentScale);
|
||||
view()->setTransform(transform);
|
||||
|
||||
QPointF adjustedCenterPos = centerPos;
|
||||
QSize rectSize(view()->rect().width() / m_currentScale,
|
||||
view()->rect().height() / m_currentScale);
|
||||
|
||||
QRectF sceneRect;
|
||||
if (qAbs(m_currentScale - 1.0f) < Constants::ZoomSnapDelta) {
|
||||
adjustedCenterPos.rx() = rectSize.width() / 2;
|
||||
adjustedCenterPos.ry() = rectSize.height() / 2;
|
||||
}
|
||||
|
||||
if (m_currentScale < 1.0f) {
|
||||
adjustedCenterPos.rx() = rectSize.width() / 2;
|
||||
adjustedCenterPos.ry() = rectSize.height() / 2;
|
||||
sceneRect.setRect(view()->rect().width() / 2 -rectSize.width() / 2,
|
||||
view()->rect().height() / 2 -rectSize.height() / 2,
|
||||
rectSize.width(),
|
||||
rectSize.height());
|
||||
} else {
|
||||
sceneRect.setRect(adjustedCenterPos.x() - rectSize.width() / 2,
|
||||
adjustedCenterPos.y() - rectSize.height() / 2,
|
||||
rectSize.width(),
|
||||
rectSize.height());
|
||||
}
|
||||
|
||||
view()->setSceneRect(sceneRect);
|
||||
}
|
||||
|
||||
void ZoomTool::zoomTo100()
|
||||
{
|
||||
m_currentScale = 1.0f;
|
||||
scaleView(view()->mapToScene(view()->rect().center()));
|
||||
}
|
||||
|
||||
qreal ZoomTool::nextZoomScale(ZoomDirection direction) const
|
||||
{
|
||||
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_currentScale || i == zoomScales.length() - 1)
|
||||
return zoomScales[i];
|
||||
}
|
||||
} else {
|
||||
for (int i = zoomScales.length() - 1; i >= 0; --i) {
|
||||
if (zoomScales[i] < m_currentScale || i == 0)
|
||||
return zoomScales[i];
|
||||
}
|
||||
}
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,94 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ZOOMTOOL_H
|
||||
#define ZOOMTOOL_H
|
||||
|
||||
#include "abstractliveedittool.h"
|
||||
#include "liverubberbandselectionmanipulator.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class ZoomTool : public AbstractLiveEditTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ZoomDirection {
|
||||
ZoomIn,
|
||||
ZoomOut
|
||||
};
|
||||
|
||||
explicit ZoomTool(QDeclarativeViewInspector *view);
|
||||
|
||||
virtual ~ZoomTool();
|
||||
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
|
||||
void hoverMoveEvent(QMouseEvent *event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
void clear();
|
||||
protected:
|
||||
void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
private slots:
|
||||
void zoomTo100();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
private:
|
||||
qreal nextZoomScale(ZoomDirection direction) const;
|
||||
void scaleView(const QPointF ¢erPos);
|
||||
|
||||
private:
|
||||
bool m_dragStarted;
|
||||
QPoint m_mousePos; // in view coords
|
||||
QPointF m_dragBeginPos;
|
||||
QAction *m_zoomTo100Action;
|
||||
QAction *m_zoomInAction;
|
||||
QAction *m_zoomOutAction;
|
||||
LiveRubberBandSelectionManipulator *m_rubberbandManipulator;
|
||||
|
||||
qreal m_smoothZoomMultiplier;
|
||||
qreal m_currentScale;
|
||||
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // ZOOMTOOL_H
|
||||
@@ -1,107 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef JSDEBUGGERAGENT_H
|
||||
#define JSDEBUGGERAGENT_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <qscriptengineagent.h>
|
||||
|
||||
#include "qt_private/qdeclarativedebugservice_p.h"
|
||||
|
||||
#include "qmljsdebugger_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QScriptValue;
|
||||
class QDeclarativeEngine;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class JSDebuggerAgentPrivate;
|
||||
|
||||
class QMLJSDEBUGGER_EXPORT JSDebuggerAgent
|
||||
: public QDeclarativeDebugService
|
||||
, public QScriptEngineAgent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
JSDebuggerAgent(QScriptEngine *engine);
|
||||
JSDebuggerAgent(QDeclarativeEngine *engine);
|
||||
~JSDebuggerAgent();
|
||||
|
||||
// reimplemented
|
||||
void scriptLoad(qint64 id, const QString &program,
|
||||
const QString &fileName, int baseLineNumber);
|
||||
void scriptUnload(qint64 id);
|
||||
|
||||
void contextPush();
|
||||
void contextPop();
|
||||
|
||||
void functionEntry(qint64 scriptId);
|
||||
void functionExit(qint64 scriptId,
|
||||
const QScriptValue &returnValue);
|
||||
|
||||
void positionChange(qint64 scriptId,
|
||||
int lineNumber, int columnNumber);
|
||||
|
||||
void exceptionThrow(qint64 scriptId,
|
||||
const QScriptValue &exception,
|
||||
bool hasHandler);
|
||||
void exceptionCatch(qint64 scriptId,
|
||||
const QScriptValue &exception);
|
||||
|
||||
bool supportsExtension(Extension extension) const;
|
||||
QVariant extension(Extension extension,
|
||||
const QVariant &argument = QVariant());
|
||||
|
||||
void messageReceived(const QByteArray &);
|
||||
void statusChanged(Status status);
|
||||
void baseMessageReceived(const QByteArray &message);
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
JSDebuggerAgentPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // JSDEBUGGERAGENT_H
|
||||
@@ -1,103 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEDINSPECTORSERVICE_H
|
||||
#define QDECLARATIVEDINSPECTORSERVICE_H
|
||||
|
||||
#include "qt_private/qdeclarativedebugservice_p.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
#include "qmljsdebugger_global.h"
|
||||
|
||||
#include <QHash>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QColor)
|
||||
QT_FORWARD_DECLARE_CLASS(QDeclarativeEngine)
|
||||
QT_FORWARD_DECLARE_CLASS(QDeclarativeContext)
|
||||
QT_FORWARD_DECLARE_CLASS(QDeclarativeWatcher)
|
||||
QT_FORWARD_DECLARE_CLASS(QDataStream)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QMLJSDEBUGGER_EXPORT QDeclarativeInspectorService : public QDeclarativeDebugService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDeclarativeInspectorService();
|
||||
static QDeclarativeInspectorService *instance();
|
||||
|
||||
void setDesignModeBehavior(bool inDesignMode);
|
||||
void setCurrentObjects(QList<QObject*> items);
|
||||
void setAnimationSpeed(qreal slowDownFactor);
|
||||
void setAnimationPaused(bool paused);
|
||||
void setCurrentTool(QmlJSDebugger::Constants::DesignTool toolId);
|
||||
void reloaded();
|
||||
void setShowAppOnTop(bool showAppOnTop);
|
||||
|
||||
QString idStringForObject(QObject *obj) const;
|
||||
|
||||
void sendMessage(const QByteArray &message);
|
||||
|
||||
public Q_SLOTS:
|
||||
void selectedColorChanged(const QColor &color);
|
||||
|
||||
Q_SIGNALS:
|
||||
void debuggingClientChanged(bool hasDebuggingClient);
|
||||
|
||||
void currentObjectsChanged(const QList<QObject*> &objects);
|
||||
void designModeBehaviorChanged(bool inDesignMode);
|
||||
void showAppOnTopChanged(bool showAppOnTop);
|
||||
void reloadRequested();
|
||||
void selectToolRequested();
|
||||
void selectMarqueeToolRequested();
|
||||
void zoomToolRequested();
|
||||
void colorPickerToolRequested();
|
||||
|
||||
void objectCreationRequested(const QString &qml, QObject *parent,
|
||||
const QStringList &imports, const QString &filename = QString(), int order = -1);
|
||||
void objectReparentRequested(QObject *object, QObject *newParent);
|
||||
void objectDeletionRequested(QObject *object);
|
||||
|
||||
// 1 = normal speed,
|
||||
// 1 < x < 16 = slowdown by some factor
|
||||
void animationSpeedChangeRequested(qreal speedFactor);
|
||||
void executionPauseChangeRequested(bool paused);
|
||||
|
||||
void clearComponentCacheRequested();
|
||||
|
||||
protected:
|
||||
virtual void statusChanged(Status status);
|
||||
virtual void messageReceived(const QByteArray &);
|
||||
|
||||
private:
|
||||
QHash<int, QString> m_stringIdForObjectId;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QDECLARATIVEDINSPECTORSERVICE_H
|
||||
@@ -1,116 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEVIEWINSPECTOR_H
|
||||
#define QDECLARATIVEVIEWINSPECTOR_H
|
||||
|
||||
#include "qmljsdebugger_global.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QDeclarativeView>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QDeclarativeItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QMouseEvent)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class CrumblePath;
|
||||
class QDeclarativeViewInspectorPrivate;
|
||||
|
||||
class QMLJSDEBUGGER_EXPORT QDeclarativeViewInspector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0);
|
||||
~QDeclarativeViewInspector();
|
||||
|
||||
void setSelectedItems(QList<QGraphicsItem *> items);
|
||||
QList<QGraphicsItem *> selectedItems();
|
||||
|
||||
QDeclarativeView *declarativeView();
|
||||
|
||||
static QString idStringForObject(QObject *obj);
|
||||
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
|
||||
|
||||
bool showAppOnTop() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setDesignModeBehavior(bool value);
|
||||
bool designModeBehavior();
|
||||
|
||||
void setShowAppOnTop(bool appOnTop);
|
||||
|
||||
void setAnimationSpeed(qreal factor);
|
||||
void setAnimationPaused(bool paused);
|
||||
|
||||
Q_SIGNALS:
|
||||
void designModeBehaviorChanged(bool inDesignMode);
|
||||
void showAppOnTopChanged(bool showAppOnTop);
|
||||
void reloadRequested();
|
||||
void marqueeSelectToolActivated();
|
||||
void selectToolActivated();
|
||||
void zoomToolActivated();
|
||||
void colorPickerActivated();
|
||||
void selectedColorChanged(const QColor &color);
|
||||
|
||||
void animationSpeedChanged(qreal factor);
|
||||
void animationPausedChanged(bool paused);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
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);
|
||||
|
||||
void setSelectedItemsForTools(QList<QGraphicsItem *> items);
|
||||
|
||||
private slots:
|
||||
void animationSpeedChangeRequested(qreal factor);
|
||||
void animationPausedChangeRequested(bool paused);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QDeclarativeViewInspector)
|
||||
|
||||
inline QDeclarativeViewInspectorPrivate *d_func() { return data.data(); }
|
||||
QScopedPointer<QDeclarativeViewInspectorPrivate> data;
|
||||
friend class QDeclarativeViewInspectorPrivate;
|
||||
friend class AbstractLiveEditTool;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QDECLARATIVEVIEWINSPECTOR_H
|
||||
@@ -1,50 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEVIEWOBSERVER_H
|
||||
#define QDECLARATIVEVIEWOBSERVER_H
|
||||
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
// Provided for compatibility with QmlApplicationViewer
|
||||
class QMLJSDEBUGGER_EXPORT QDeclarativeViewObserver : public QDeclarativeViewInspector
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QDeclarativeViewObserver(QDeclarativeView *view, QObject *parent = 0)
|
||||
: QDeclarativeViewInspector(view, parent)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QDECLARATIVEVIEWOBSERVER_H
|
||||
@@ -1,68 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMLINSPECTORCONSTANTS_H
|
||||
#define QMLINSPECTORCONSTANTS_H
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
namespace Constants {
|
||||
|
||||
enum DesignTool {
|
||||
NoTool = 0,
|
||||
SelectionToolMode = 1,
|
||||
MarqueeSelectionToolMode = 2,
|
||||
MoveToolMode = 3,
|
||||
ResizeToolMode = 4,
|
||||
ColorPickerMode = 5,
|
||||
ZoomMode = 6
|
||||
};
|
||||
|
||||
enum ToolFlags {
|
||||
NoToolFlags = 0,
|
||||
UseCursorPos = 1
|
||||
};
|
||||
|
||||
static const int DragStartTime = 50;
|
||||
|
||||
static const int DragStartDistance = 20;
|
||||
|
||||
static const double ZoomSnapDelta = 0.04;
|
||||
|
||||
static const int EditorItemDataKey = 1000;
|
||||
|
||||
enum GraphicsItemTypes {
|
||||
EditorItemType = 0xEAAA,
|
||||
ResizeHandleItemType = 0xEAEA
|
||||
};
|
||||
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QMLINSPECTORCONSTANTS_H
|
||||
@@ -1,46 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMLJSDEBUGGER_GLOBAL_H
|
||||
#define QMLJSDEBUGGER_GLOBAL_H
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
# if defined(BUILD_QMLJSDEBUGGER_LIB)
|
||||
# define QMLJSDEBUGGER_EXPORT Q_DECL_EXPORT
|
||||
# define QMLJSDEBUGGER_EXTERN Q_DECL_IMPORT
|
||||
# elif defined(BUILD_QMLJSDEBUGGER_STATIC_LIB)
|
||||
# define QMLJSDEBUGGER_EXPORT
|
||||
# define QMLJSDEBUGGER_EXTERN Q_DECL_IMPORT
|
||||
# else
|
||||
# define QMLJSDEBUGGER_EXPORT
|
||||
# define QMLJSDEBUGGER_EXTERN Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // QMLJSDEBUGGER_GLOBAL_H
|
||||
@@ -1,56 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEDEBUGHELPER_P_H
|
||||
#define QDECLARATIVEDEBUGHELPER_P_H
|
||||
|
||||
#include "../qmljsdebugger_global.h"
|
||||
#include <qglobal.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QScriptEngine;
|
||||
class QDeclarativeEngine;
|
||||
|
||||
// Helper functions to access private API through a stable interface
|
||||
// This is used in the qmljsdebugger library of QtCreator.
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeDebugHelper
|
||||
{
|
||||
public:
|
||||
static QScriptEngine *getScriptEngine(QDeclarativeEngine *engine);
|
||||
static void setAnimationSlowDownFactor(qreal factor);
|
||||
|
||||
// Enables remote debugging functionality
|
||||
// Only use this for debugging in a safe environment!
|
||||
static void enableDebugging();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDECLARATIVEDEBUGHELPER_P_H
|
||||
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEDEBUGSERVICE_H
|
||||
#define QDECLARATIVEDEBUGSERVICE_H
|
||||
|
||||
#include "../qmljsdebugger_global.h"
|
||||
#include <qobject.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Declarative)
|
||||
|
||||
class QDeclarativeDebugServicePrivate;
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeDebugService : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QDeclarativeDebugService)
|
||||
Q_DISABLE_COPY(QDeclarativeDebugService)
|
||||
|
||||
public:
|
||||
explicit QDeclarativeDebugService(const QString &, QObject *parent = 0);
|
||||
~QDeclarativeDebugService();
|
||||
|
||||
QString name() const;
|
||||
|
||||
enum Status { NotConnected, Unavailable, Enabled };
|
||||
Status status() const;
|
||||
|
||||
void sendMessage(const QByteArray &);
|
||||
|
||||
static int idForObject(QObject *);
|
||||
static QObject *objectForId(int);
|
||||
|
||||
static QString objectToString(QObject *obj);
|
||||
|
||||
static bool isDebuggingEnabled();
|
||||
static bool hasDebuggingClient();
|
||||
|
||||
protected:
|
||||
virtual void statusChanged(Status);
|
||||
virtual void messageReceived(const QByteArray &);
|
||||
|
||||
private:
|
||||
friend class QDeclarativeDebugServer;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDECLARATIVEDEBUGSERVICE_H
|
||||
|
||||
@@ -1,194 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVESTATE_H
|
||||
#define QDECLARATIVESTATE_H
|
||||
|
||||
#include "../qmljsdebugger_global.h"
|
||||
|
||||
#include <qdeclarative.h>
|
||||
#include <qdeclarativeproperty.h>
|
||||
#include <qobject.h>
|
||||
#include <qsharedpointer.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Declarative)
|
||||
|
||||
class QDeclarativeActionEvent;
|
||||
class QDeclarativeAbstractBinding;
|
||||
class QDeclarativeBinding;
|
||||
class QDeclarativeExpression;
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeAction
|
||||
{
|
||||
public:
|
||||
QDeclarativeAction();
|
||||
QDeclarativeAction(QObject *, const QString &, const QVariant &);
|
||||
QDeclarativeAction(QObject *, const QString &,
|
||||
QDeclarativeContext *, const QVariant &);
|
||||
|
||||
bool restore:1;
|
||||
bool actionDone:1;
|
||||
bool reverseEvent:1;
|
||||
bool deletableToBinding:1;
|
||||
|
||||
QDeclarativeProperty property;
|
||||
QVariant fromValue;
|
||||
QVariant toValue;
|
||||
|
||||
QDeclarativeAbstractBinding *fromBinding;
|
||||
QWeakPointer<QDeclarativeAbstractBinding> toBinding;
|
||||
QDeclarativeActionEvent *event;
|
||||
|
||||
//strictly for matching
|
||||
QObject *specifiedObject;
|
||||
QString specifiedProperty;
|
||||
|
||||
void deleteFromBinding();
|
||||
};
|
||||
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeActionEvent
|
||||
{
|
||||
public:
|
||||
virtual ~QDeclarativeActionEvent();
|
||||
virtual QString typeName() const;
|
||||
|
||||
enum Reason { ActualChange, FastForward };
|
||||
|
||||
virtual void execute(Reason reason = ActualChange);
|
||||
virtual bool isReversable();
|
||||
virtual void reverse(Reason reason = ActualChange);
|
||||
virtual void saveOriginals() {}
|
||||
virtual bool needsCopy() { return false; }
|
||||
virtual void copyOriginals(QDeclarativeActionEvent *) {}
|
||||
virtual bool isRewindable() { return isReversable(); }
|
||||
virtual void rewind() {}
|
||||
virtual void saveCurrentValues() {}
|
||||
virtual void saveTargetValues() {}
|
||||
|
||||
virtual bool changesBindings();
|
||||
virtual void clearBindings();
|
||||
virtual bool override(QDeclarativeActionEvent*other);
|
||||
};
|
||||
|
||||
//### rename to QDeclarativeStateChange?
|
||||
class QDeclarativeStateGroup;
|
||||
class QDeclarativeState;
|
||||
class QDeclarativeStateOperationPrivate;
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeStateOperation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDeclarativeStateOperation(QObject *parent = 0)
|
||||
: QObject(parent) {}
|
||||
typedef QList<QDeclarativeAction> ActionList;
|
||||
|
||||
virtual ActionList actions();
|
||||
|
||||
QDeclarativeState *state() const;
|
||||
void setState(QDeclarativeState *state);
|
||||
|
||||
protected:
|
||||
QDeclarativeStateOperation(QObjectPrivate &dd, QObject *parent = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QDeclarativeStateOperation)
|
||||
Q_DISABLE_COPY(QDeclarativeStateOperation)
|
||||
};
|
||||
|
||||
typedef QDeclarativeStateOperation::ActionList QDeclarativeStateActions;
|
||||
|
||||
class QDeclarativeTransition;
|
||||
class QDeclarativeStatePrivate;
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeState : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QDeclarativeBinding *when READ when WRITE setWhen)
|
||||
Q_PROPERTY(QString extend READ extends WRITE setExtends)
|
||||
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeStateOperation> changes READ changes)
|
||||
Q_CLASSINFO("DefaultProperty", "changes")
|
||||
Q_CLASSINFO("DeferredPropertyNames", "changes")
|
||||
|
||||
public:
|
||||
QDeclarativeState(QObject *parent=0);
|
||||
virtual ~QDeclarativeState();
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &);
|
||||
bool isNamed() const;
|
||||
|
||||
/*'when' is a QDeclarativeBinding to limit state changes oscillation
|
||||
due to the unpredictable order of evaluation of bound expressions*/
|
||||
bool isWhenKnown() const;
|
||||
QDeclarativeBinding *when() const;
|
||||
void setWhen(QDeclarativeBinding *);
|
||||
|
||||
QString extends() const;
|
||||
void setExtends(const QString &);
|
||||
|
||||
QDeclarativeListProperty<QDeclarativeStateOperation> changes();
|
||||
int operationCount() const;
|
||||
QDeclarativeStateOperation *operationAt(int) const;
|
||||
|
||||
QDeclarativeState &operator<<(QDeclarativeStateOperation *);
|
||||
|
||||
void apply(QDeclarativeStateGroup *, QDeclarativeTransition *, QDeclarativeState *revert);
|
||||
void cancel();
|
||||
|
||||
QDeclarativeStateGroup *stateGroup() const;
|
||||
void setStateGroup(QDeclarativeStateGroup *);
|
||||
|
||||
bool containsPropertyInRevertList(QObject *target, const QString &name) const;
|
||||
bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue);
|
||||
bool changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding);
|
||||
bool removeEntryFromRevertList(QObject *target, const QString &name);
|
||||
void addEntryToRevertList(const QDeclarativeAction &action);
|
||||
void removeAllEntriesFromRevertList(QObject *target);
|
||||
void addEntriesToRevertList(const QList<QDeclarativeAction> &actions);
|
||||
QVariant valueInRevertList(QObject *target, const QString &name) const;
|
||||
QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const;
|
||||
|
||||
bool isStateActive() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void completed();
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QDeclarativeState)
|
||||
Q_DISABLE_COPY(QDeclarativeState)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
//QML_DECLARE_TYPE(QDeclarativeStateOperation)
|
||||
//QML_DECLARE_TYPE(QDeclarativeState)
|
||||
|
||||
#endif // QDECLARATIVESTATE_H
|
||||
@@ -1,672 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "jsdebuggeragent.h"
|
||||
#include "qt_private/qdeclarativedebughelper_p.h"
|
||||
|
||||
#include <qdatetime.h>
|
||||
#include <qdebug.h>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qset.h>
|
||||
#include <qurl.h>
|
||||
#include <qscriptcontextinfo.h>
|
||||
#include <qscriptengine.h>
|
||||
#include <qscriptvalueiterator.h>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
enum JSDebuggerState
|
||||
{
|
||||
NoState,
|
||||
SteppingIntoState,
|
||||
SteppingOverState,
|
||||
SteppingOutState,
|
||||
StoppedState
|
||||
};
|
||||
|
||||
struct JSAgentWatchData
|
||||
{
|
||||
QByteArray exp;
|
||||
QByteArray name;
|
||||
QByteArray value;
|
||||
QByteArray type;
|
||||
bool hasChildren;
|
||||
quint64 objectId;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const JSAgentWatchData &data)
|
||||
{
|
||||
return s << data.exp << data.name << data.value
|
||||
<< data.type << data.hasChildren << data.objectId;
|
||||
}
|
||||
|
||||
struct JSAgentStackData
|
||||
{
|
||||
QByteArray functionName;
|
||||
QByteArray fileUrl;
|
||||
qint32 lineNumber;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const JSAgentStackData &data)
|
||||
{
|
||||
return s << data.functionName << data.fileUrl << data.lineNumber;
|
||||
}
|
||||
|
||||
struct JSAgentBreakpointData
|
||||
{
|
||||
QByteArray functionName;
|
||||
QByteArray fileUrl;
|
||||
qint32 lineNumber;
|
||||
};
|
||||
|
||||
typedef QSet<JSAgentBreakpointData> JSAgentBreakpoints;
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const JSAgentBreakpointData &data)
|
||||
{
|
||||
return s << data.functionName << data.fileUrl << data.lineNumber;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &s, JSAgentBreakpointData &data)
|
||||
{
|
||||
return s >> data.functionName >> data.fileUrl >> data.lineNumber;
|
||||
}
|
||||
|
||||
bool operator==(const JSAgentBreakpointData &b1, const JSAgentBreakpointData &b2)
|
||||
{
|
||||
return b1.lineNumber == b2.lineNumber && b1.fileUrl == b2.fileUrl;
|
||||
}
|
||||
|
||||
uint qHash(const JSAgentBreakpointData &b)
|
||||
{
|
||||
return b.lineNumber ^ qHash(b.fileUrl);
|
||||
}
|
||||
|
||||
class JSDebuggerAgentPrivate
|
||||
{
|
||||
public:
|
||||
JSDebuggerAgentPrivate(JSDebuggerAgent *q)
|
||||
: q(q), state(NoState)
|
||||
{}
|
||||
|
||||
void continueExec();
|
||||
void recordKnownObjects(const QList<JSAgentWatchData> &);
|
||||
QList<JSAgentWatchData> getLocals(QScriptContext *);
|
||||
void positionChange(qint64 scriptId, int lineNumber, int columnNumber);
|
||||
QScriptEngine *engine() { return q->engine(); }
|
||||
void stopped();
|
||||
void messageReceived(const QByteArray &message);
|
||||
void sendMessage(const QByteArray &message) { q->sendMessage(message); }
|
||||
|
||||
public:
|
||||
JSDebuggerAgent *q;
|
||||
JSDebuggerState state;
|
||||
int stepDepth;
|
||||
int stepCount;
|
||||
|
||||
QEventLoop loop;
|
||||
QHash<qint64, QString> filenames;
|
||||
JSAgentBreakpoints breakpoints;
|
||||
// breakpoints by filename (without path)
|
||||
QHash<QString, JSAgentBreakpointData> fileNameToBreakpoints;
|
||||
QStringList watchExpressions;
|
||||
QSet<qint64> knownObjectIds;
|
||||
};
|
||||
|
||||
class SetupExecEnv
|
||||
{
|
||||
public:
|
||||
SetupExecEnv(JSDebuggerAgentPrivate *a)
|
||||
: agent(a),
|
||||
previousState(a->state),
|
||||
hadException(a->engine()->hasUncaughtException())
|
||||
{
|
||||
agent->state = StoppedState;
|
||||
}
|
||||
|
||||
~SetupExecEnv()
|
||||
{
|
||||
if (!hadException && agent->engine()->hasUncaughtException())
|
||||
agent->engine()->clearExceptions();
|
||||
agent->state = previousState;
|
||||
}
|
||||
|
||||
private:
|
||||
JSDebuggerAgentPrivate *agent;
|
||||
JSDebuggerState previousState;
|
||||
bool hadException;
|
||||
};
|
||||
|
||||
static JSAgentWatchData fromScriptValue(const QString &expression,
|
||||
const QScriptValue &value)
|
||||
{
|
||||
static const QString arrayStr = QCoreApplication::translate
|
||||
("Debugger::JSAgentWatchData", "[Array of length %1]");
|
||||
static const QString undefinedStr = QCoreApplication::translate
|
||||
("Debugger::JSAgentWatchData", "<undefined>");
|
||||
|
||||
JSAgentWatchData data;
|
||||
data.exp = expression.toUtf8();
|
||||
data.name = data.exp;
|
||||
data.hasChildren = false;
|
||||
data.value = value.toString().toUtf8();
|
||||
data.objectId = value.objectId();
|
||||
if (value.isArray()) {
|
||||
data.type = "Array";
|
||||
data.value = arrayStr.arg(value.property("length").toString()).toUtf8();
|
||||
data.hasChildren = true;
|
||||
} else if (value.isBool()) {
|
||||
data.type = "Bool";
|
||||
// data.value = value.toBool() ? "true" : "false";
|
||||
} else if (value.isDate()) {
|
||||
data.type = "Date";
|
||||
data.value = value.toDateTime().toString().toUtf8();
|
||||
} else if (value.isError()) {
|
||||
data.type = "Error";
|
||||
} else if (value.isFunction()) {
|
||||
data.type = "Function";
|
||||
} else if (value.isUndefined()) {
|
||||
data.type = undefinedStr.toUtf8();
|
||||
} else if (value.isNumber()) {
|
||||
data.type = "Number";
|
||||
} else if (value.isRegExp()) {
|
||||
data.type = "RegExp";
|
||||
} else if (value.isString()) {
|
||||
data.type = "String";
|
||||
} else if (value.isVariant()) {
|
||||
data.type = "Variant";
|
||||
} else if (value.isQObject()) {
|
||||
const QObject *obj = value.toQObject();
|
||||
data.type = "Object";
|
||||
data.value += '[';
|
||||
data.value += obj->metaObject()->className();
|
||||
data.value += ']';
|
||||
data.hasChildren = true;
|
||||
} else if (value.isObject()) {
|
||||
data.type = "Object";
|
||||
data.hasChildren = true;
|
||||
data.value = "[Object]";
|
||||
} else if (value.isNull()) {
|
||||
data.type = "<null>";
|
||||
} else {
|
||||
data.type = "<unknown>";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static QList<JSAgentWatchData> expandObject(const QScriptValue &object)
|
||||
{
|
||||
QList<JSAgentWatchData> result;
|
||||
QScriptValueIterator it(object);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.flags() & QScriptValue::SkipInEnumeration)
|
||||
continue;
|
||||
if (/*object.isQObject() &&*/ it.value().isFunction()) {
|
||||
// Cosmetics: skip all functions and slot, there are too many of them,
|
||||
// and it is not useful information in the debugger.
|
||||
continue;
|
||||
}
|
||||
JSAgentWatchData data = fromScriptValue(it.name(), it.value());
|
||||
result.append(data);
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
JSAgentWatchData data;
|
||||
data.name = "<no initialized data>";
|
||||
data.hasChildren = false;
|
||||
data.value = " ";
|
||||
data.objectId = 0;
|
||||
result.append(data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::recordKnownObjects(const QList<JSAgentWatchData>& list)
|
||||
{
|
||||
foreach (const JSAgentWatchData &data, list)
|
||||
knownObjectIds << data.objectId;
|
||||
}
|
||||
|
||||
QList<JSAgentWatchData> JSDebuggerAgentPrivate::getLocals(QScriptContext *ctx)
|
||||
{
|
||||
QList<JSAgentWatchData> locals;
|
||||
if (ctx) {
|
||||
QScriptValue activationObject = ctx->activationObject();
|
||||
QScriptValue thisObject = ctx->thisObject();
|
||||
locals = expandObject(activationObject);
|
||||
if (thisObject.isObject()
|
||||
&& thisObject.objectId() != engine()->globalObject().objectId()
|
||||
&& QScriptValueIterator(thisObject).hasNext())
|
||||
locals.prepend(fromScriptValue("this", thisObject));
|
||||
recordKnownObjects(locals);
|
||||
knownObjectIds << activationObject.objectId();
|
||||
}
|
||||
return locals;
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new agent for the given \a engine. The agent will
|
||||
report debugging-related events (e.g. step completion) to the given
|
||||
\a backend.
|
||||
*/
|
||||
JSDebuggerAgent::JSDebuggerAgent(QScriptEngine *engine)
|
||||
: QDeclarativeDebugService("JSDebugger")
|
||||
, QScriptEngineAgent(engine)
|
||||
, d(new JSDebuggerAgentPrivate(this))
|
||||
{
|
||||
if (status() == Enabled)
|
||||
engine->setAgent(this);
|
||||
}
|
||||
|
||||
JSDebuggerAgent::JSDebuggerAgent(QDeclarativeEngine *engine)
|
||||
: QDeclarativeDebugService("JSDebugger")
|
||||
, QScriptEngineAgent(QDeclarativeDebugHelper::getScriptEngine(engine))
|
||||
, d(new JSDebuggerAgentPrivate(this))
|
||||
{
|
||||
if (status() == Enabled)
|
||||
QDeclarativeDebugHelper::getScriptEngine(engine)->setAgent(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this QScriptDebuggerAgent.
|
||||
*/
|
||||
JSDebuggerAgent::~JSDebuggerAgent()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::scriptLoad(qint64 id, const QString &program,
|
||||
const QString &fileName, int)
|
||||
{
|
||||
Q_UNUSED(program);
|
||||
d->filenames.insert(id, fileName);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::scriptUnload(qint64 id)
|
||||
{
|
||||
d->filenames.remove(id);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::contextPush()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::contextPop()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::functionEntry(qint64 scriptId)
|
||||
{
|
||||
Q_UNUSED(scriptId);
|
||||
d->stepDepth++;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnValue)
|
||||
{
|
||||
Q_UNUSED(scriptId);
|
||||
Q_UNUSED(returnValue);
|
||||
d->stepDepth--;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
|
||||
{
|
||||
d->positionChange(scriptId, lineNumber, columnNumber);
|
||||
}
|
||||
|
||||
QString fileName(const QString &fileUrl)
|
||||
{
|
||||
int lastDelimiterPos = fileUrl.lastIndexOf(QLatin1Char('/'));
|
||||
return fileUrl.mid(lastDelimiterPos, fileUrl.size() - lastDelimiterPos);
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
|
||||
{
|
||||
Q_UNUSED(columnNumber);
|
||||
|
||||
if (state == StoppedState)
|
||||
return; //no re-entrency
|
||||
|
||||
// check breakpoints
|
||||
if (!breakpoints.isEmpty()) {
|
||||
QScriptContext *ctx = engine()->currentContext();
|
||||
QScriptContextInfo info(ctx);
|
||||
|
||||
if (info.functionType() == QScriptContextInfo::ScriptFunction) {
|
||||
QHash<qint64, QString>::const_iterator it = filenames.constFind(scriptId);
|
||||
if (it == filenames.constEnd()) {
|
||||
// It is possible that the scripts are loaded before the agent is attached
|
||||
QString filename = info.fileName();
|
||||
|
||||
JSAgentStackData frame;
|
||||
frame.functionName = info.functionName().toUtf8();
|
||||
it = filenames.insert(scriptId, filename);
|
||||
}
|
||||
|
||||
const QString filePath = it->toUtf8();
|
||||
JSAgentBreakpoints bps = fileNameToBreakpoints.values(fileName(filePath)).toSet();
|
||||
|
||||
foreach (const JSAgentBreakpointData &bp, bps) {
|
||||
if (bp.lineNumber == lineNumber) {
|
||||
stopped();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case NoState:
|
||||
case StoppedState:
|
||||
// Do nothing
|
||||
break;
|
||||
case SteppingOutState:
|
||||
if (stepDepth >= 0)
|
||||
break;
|
||||
//fallthough
|
||||
case SteppingOverState:
|
||||
if (stepDepth > 0)
|
||||
break;
|
||||
//fallthough
|
||||
case SteppingIntoState:
|
||||
stopped();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::exceptionThrow(qint64 scriptId,
|
||||
const QScriptValue &exception,
|
||||
bool hasHandler)
|
||||
{
|
||||
Q_UNUSED(scriptId);
|
||||
Q_UNUSED(exception);
|
||||
Q_UNUSED(hasHandler);
|
||||
// qDebug() << Q_FUNC_INFO << exception.toString() << hasHandler;
|
||||
#if 0 //sometimes, we get exceptions that we should just ignore.
|
||||
if (!hasHandler && state != StoppedState)
|
||||
stopped(true, exception);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::exceptionCatch(qint64 scriptId, const QScriptValue &exception)
|
||||
{
|
||||
Q_UNUSED(scriptId);
|
||||
Q_UNUSED(exception);
|
||||
}
|
||||
|
||||
bool JSDebuggerAgent::supportsExtension(Extension extension) const
|
||||
{
|
||||
return extension == QScriptEngineAgent::DebuggerInvocationRequest;
|
||||
}
|
||||
|
||||
QVariant JSDebuggerAgent::extension(Extension extension, const QVariant &argument)
|
||||
{
|
||||
if (extension == QScriptEngineAgent::DebuggerInvocationRequest) {
|
||||
d->stopped();
|
||||
return QVariant();
|
||||
}
|
||||
return QScriptEngineAgent::extension(extension, argument);
|
||||
}
|
||||
|
||||
void JSDebuggerAgent::messageReceived(const QByteArray &message)
|
||||
{
|
||||
d->messageReceived(message);
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::messageReceived(const QByteArray &message)
|
||||
{
|
||||
QDataStream ds(message);
|
||||
QByteArray command;
|
||||
ds >> command;
|
||||
if (command == "BREAKPOINTS") {
|
||||
ds >> breakpoints;
|
||||
|
||||
fileNameToBreakpoints.clear();
|
||||
foreach (const JSAgentBreakpointData &bp, breakpoints) {
|
||||
fileNameToBreakpoints.insertMulti(fileName(bp.fileUrl), bp);
|
||||
}
|
||||
|
||||
//qDebug() << "BREAKPOINTS";
|
||||
//foreach (const JSAgentBreakpointData &bp, breakpoints)
|
||||
// qDebug() << "BREAKPOINT: " << bp.fileName << bp.lineNumber;
|
||||
} else if (command == "WATCH_EXPRESSIONS") {
|
||||
ds >> watchExpressions;
|
||||
} else if (command == "STEPOVER") {
|
||||
stepDepth = 0;
|
||||
state = SteppingOverState;
|
||||
continueExec();
|
||||
} else if (command == "STEPINTO" || command == "INTERRUPT") {
|
||||
stepDepth = 0;
|
||||
state = SteppingIntoState;
|
||||
continueExec();
|
||||
} else if (command == "STEPOUT") {
|
||||
stepDepth = 0;
|
||||
state = SteppingOutState;
|
||||
continueExec();
|
||||
} else if (command == "CONTINUE") {
|
||||
state = NoState;
|
||||
continueExec();
|
||||
} else if (command == "EXEC") {
|
||||
SetupExecEnv execEnv(this);
|
||||
|
||||
QByteArray id;
|
||||
QString expr;
|
||||
ds >> id >> expr;
|
||||
|
||||
JSAgentWatchData data = fromScriptValue(expr, engine()->evaluate(expr));
|
||||
knownObjectIds << data.objectId;
|
||||
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("RESULT") << id << data;
|
||||
sendMessage(reply);
|
||||
} else if (command == "EXPAND") {
|
||||
SetupExecEnv execEnv(this);
|
||||
|
||||
QByteArray requestId;
|
||||
quint64 objectId;
|
||||
ds >> requestId >> objectId;
|
||||
QScriptValue v;
|
||||
if (knownObjectIds.contains(objectId))
|
||||
v = engine()->objectById(objectId);
|
||||
|
||||
QList<JSAgentWatchData> result = expandObject(v);
|
||||
recordKnownObjects(result);
|
||||
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("EXPANDED") << requestId << result;
|
||||
sendMessage(reply);
|
||||
|
||||
} else if (command == "ACTIVATE_FRAME") {
|
||||
SetupExecEnv execEnv(this);
|
||||
|
||||
int frameId;
|
||||
ds >> frameId;
|
||||
|
||||
int deep = 0;
|
||||
QScriptContext *ctx = engine()->currentContext();
|
||||
while (ctx && deep < frameId) {
|
||||
ctx = ctx->parentContext();
|
||||
deep++;
|
||||
}
|
||||
|
||||
QList<JSAgentWatchData> watches;
|
||||
QList<JSAgentWatchData> locals = getLocals(ctx);
|
||||
|
||||
// re-evaluate watches given the frame's context
|
||||
QScriptContext *currentCtx = engine()->pushContext();
|
||||
currentCtx->setActivationObject(ctx->activationObject());
|
||||
currentCtx->setThisObject(ctx->thisObject());
|
||||
foreach (const QString &expr, watchExpressions)
|
||||
watches << fromScriptValue(expr, engine()->evaluate(expr));
|
||||
recordKnownObjects(watches);
|
||||
engine()->popContext();
|
||||
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("LOCALS") << frameId << locals << watches;
|
||||
sendMessage(reply);
|
||||
} else if (command == "SET_PROPERTY") {
|
||||
SetupExecEnv execEnv(this);
|
||||
|
||||
QByteArray id;
|
||||
qint64 objectId;
|
||||
QString property;
|
||||
QString value;
|
||||
ds >> id >> objectId >> property >> value;
|
||||
|
||||
if (knownObjectIds.contains(objectId)) {
|
||||
QScriptValue object;
|
||||
object = engine()->objectById(objectId);
|
||||
|
||||
if (object.isObject()) {
|
||||
QScriptValue result = engine()->evaluate(value);
|
||||
object.setProperty(property, result);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: feedback
|
||||
} else if (command == "PING") {
|
||||
int ping;
|
||||
ds >> ping;
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("PONG") << ping;
|
||||
sendMessage(reply);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "Unknown command" << command;
|
||||
}
|
||||
|
||||
q->baseMessageReceived(message);
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::stopped()
|
||||
{
|
||||
bool becauseOfException = false;
|
||||
const QScriptValue &exception = QScriptValue();
|
||||
|
||||
knownObjectIds.clear();
|
||||
state = StoppedState;
|
||||
QList<JSAgentStackData> backtrace;
|
||||
|
||||
for (QScriptContext* ctx = engine()->currentContext(); ctx; ctx = ctx->parentContext()) {
|
||||
QScriptContextInfo info(ctx);
|
||||
|
||||
JSAgentStackData frame;
|
||||
frame.functionName = info.functionName().toUtf8();
|
||||
if (frame.functionName.isEmpty()) {
|
||||
if (ctx->parentContext()) {
|
||||
switch (info.functionType()) {
|
||||
case QScriptContextInfo::ScriptFunction:
|
||||
frame.functionName = "<anonymous>";
|
||||
break;
|
||||
case QScriptContextInfo::NativeFunction:
|
||||
frame.functionName = "<native>";
|
||||
break;
|
||||
case QScriptContextInfo::QtFunction:
|
||||
case QScriptContextInfo::QtPropertyFunction:
|
||||
frame.functionName = "<native slot>";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
frame.functionName = "<global>";
|
||||
}
|
||||
}
|
||||
frame.lineNumber = info.lineNumber();
|
||||
// if the line number is unknown, fallback to the function line number
|
||||
if (frame.lineNumber == -1)
|
||||
frame.lineNumber = info.functionStartLineNumber();
|
||||
|
||||
frame.fileUrl = info.fileName().toUtf8();
|
||||
backtrace.append(frame);
|
||||
}
|
||||
QList<JSAgentWatchData> watches;
|
||||
foreach (const QString &expr, watchExpressions)
|
||||
watches << fromScriptValue(expr, engine()->evaluate(expr));
|
||||
recordKnownObjects(watches);
|
||||
|
||||
QList<JSAgentWatchData> locals = getLocals(engine()->currentContext());
|
||||
|
||||
if (!becauseOfException) {
|
||||
// Clear any exceptions occurred during locals evaluation.
|
||||
engine()->clearExceptions();
|
||||
}
|
||||
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("STOPPED") << backtrace << watches << locals
|
||||
<< becauseOfException << exception.toString();
|
||||
sendMessage(reply);
|
||||
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::continueExec()
|
||||
{
|
||||
loop.quit();
|
||||
}
|
||||
|
||||
void JSDebuggerAgent::statusChanged(Status status)
|
||||
{
|
||||
engine()->setAgent((status == QDeclarativeDebugService::Enabled) ? this : 0);
|
||||
}
|
||||
|
||||
void JSDebuggerAgent::baseMessageReceived(const QByteArray &message)
|
||||
{
|
||||
QDeclarativeDebugService::messageReceived(message);
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,125 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef INSPECTORPROTOCOL_H
|
||||
#define INSPECTORPROTOCOL_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMetaType>
|
||||
#include <QMetaEnum>
|
||||
#include <QObject>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class InspectorProtocol : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Message Tool)
|
||||
|
||||
public:
|
||||
enum Message {
|
||||
AnimationSpeedChanged = 0,
|
||||
AnimationPausedChanged = 19, // highest value
|
||||
ChangeTool = 1,
|
||||
ClearComponentCache = 2,
|
||||
ColorChanged = 3,
|
||||
CreateObject = 5,
|
||||
CurrentObjectsChanged = 6,
|
||||
DestroyObject = 7,
|
||||
MoveObject = 8,
|
||||
ObjectIdList = 9,
|
||||
Reload = 10,
|
||||
Reloaded = 11,
|
||||
SetAnimationSpeed = 12,
|
||||
SetAnimationPaused = 18,
|
||||
SetCurrentObjects = 14,
|
||||
SetDesignMode = 15,
|
||||
ShowAppOnTop = 16,
|
||||
ToolChanged = 17
|
||||
};
|
||||
|
||||
enum Tool {
|
||||
ColorPickerTool,
|
||||
SelectMarqueeTool,
|
||||
SelectTool,
|
||||
ZoomTool
|
||||
};
|
||||
|
||||
static inline QString toString(Message message)
|
||||
{
|
||||
return staticMetaObject.enumerator(0).valueToKey(message);
|
||||
}
|
||||
|
||||
static inline QString toString(Tool tool)
|
||||
{
|
||||
return staticMetaObject.enumerator(1).valueToKey(tool);
|
||||
}
|
||||
};
|
||||
|
||||
inline QDataStream & operator<< (QDataStream &stream, InspectorProtocol::Message message)
|
||||
{
|
||||
return stream << static_cast<quint32>(message);
|
||||
}
|
||||
|
||||
inline QDataStream & operator>> (QDataStream &stream, InspectorProtocol::Message &message)
|
||||
{
|
||||
quint32 i;
|
||||
stream >> i;
|
||||
message = static_cast<InspectorProtocol::Message>(i);
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline QDebug operator<< (QDebug dbg, InspectorProtocol::Message message)
|
||||
{
|
||||
dbg << InspectorProtocol::toString(message);
|
||||
return dbg;
|
||||
}
|
||||
|
||||
inline QDataStream & operator<< (QDataStream &stream, InspectorProtocol::Tool tool)
|
||||
{
|
||||
return stream << static_cast<quint32>(tool);
|
||||
}
|
||||
|
||||
inline QDataStream & operator>> (QDataStream &stream, InspectorProtocol::Tool &tool)
|
||||
{
|
||||
quint32 i;
|
||||
stream >> i;
|
||||
tool = static_cast<InspectorProtocol::Tool>(i);
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline QDebug operator<< (QDebug dbg, InspectorProtocol::Tool tool)
|
||||
{
|
||||
dbg << InspectorProtocol::toString(tool);
|
||||
return dbg;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // INSPECTORPROTOCOL_H
|
||||
@@ -1,3 +0,0 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
DEPENDPATH += $$PWD
|
||||
HEADERS += $$PWD/inspectorprotocol.h
|
||||
@@ -1,284 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativeinspectorservice.h"
|
||||
|
||||
#include <inspectorprotocol.h>
|
||||
|
||||
#include <QStringList>
|
||||
#include <QColor>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
Q_GLOBAL_STATIC(QDeclarativeInspectorService, serviceInstance)
|
||||
|
||||
QDeclarativeInspectorService::QDeclarativeInspectorService()
|
||||
: QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode"))
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeInspectorService *QDeclarativeInspectorService::instance()
|
||||
{
|
||||
return serviceInstance();
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::statusChanged(Status status)
|
||||
{
|
||||
emit debuggingClientChanged((status == Enabled));
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::messageReceived(const QByteArray &message)
|
||||
{
|
||||
QDataStream ds(message);
|
||||
|
||||
InspectorProtocol::Message type;
|
||||
ds >> type;
|
||||
|
||||
switch (type) {
|
||||
case InspectorProtocol::SetCurrentObjects: {
|
||||
int itemCount = 0;
|
||||
ds >> itemCount;
|
||||
|
||||
QList<QObject*> selectedObjects;
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
int debugId = -1;
|
||||
ds >> debugId;
|
||||
if (QObject *obj = objectForId(debugId))
|
||||
selectedObjects << obj;
|
||||
}
|
||||
|
||||
emit currentObjectsChanged(selectedObjects);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::Reload: {
|
||||
emit reloadRequested();
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::SetAnimationSpeed: {
|
||||
qreal speed;
|
||||
ds >> speed;
|
||||
emit animationSpeedChangeRequested(speed);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::SetAnimationPaused: {
|
||||
bool paused;
|
||||
ds >> paused;
|
||||
emit executionPauseChangeRequested(paused);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::ChangeTool: {
|
||||
InspectorProtocol::Tool tool;
|
||||
ds >> tool;
|
||||
switch (tool) {
|
||||
case InspectorProtocol::ColorPickerTool:
|
||||
emit colorPickerToolRequested();
|
||||
break;
|
||||
case InspectorProtocol::SelectTool:
|
||||
emit selectToolRequested();
|
||||
break;
|
||||
case InspectorProtocol::SelectMarqueeTool:
|
||||
emit selectMarqueeToolRequested();
|
||||
break;
|
||||
case InspectorProtocol::ZoomTool:
|
||||
emit zoomToolRequested();
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Warning: Unhandled tool:" << tool;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::SetDesignMode: {
|
||||
bool inDesignMode;
|
||||
ds >> inDesignMode;
|
||||
emit designModeBehaviorChanged(inDesignMode);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::ShowAppOnTop: {
|
||||
bool showOnTop;
|
||||
ds >> showOnTop;
|
||||
emit showAppOnTopChanged(showOnTop);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::CreateObject: {
|
||||
QString qml;
|
||||
int parentId;
|
||||
QString filename;
|
||||
QStringList imports;
|
||||
ds >> qml >> parentId >> imports >> filename;
|
||||
int order = -1;
|
||||
if (!ds.atEnd()) {
|
||||
ds >> order;
|
||||
}
|
||||
emit objectCreationRequested(qml, objectForId(parentId), imports, filename, order);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::DestroyObject: {
|
||||
int debugId;
|
||||
ds >> debugId;
|
||||
if (QObject* obj = objectForId(debugId)) {
|
||||
emit objectDeletionRequested(obj);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::MoveObject: {
|
||||
int debugId, newParent;
|
||||
ds >> debugId >> newParent;
|
||||
emit objectReparentRequested(objectForId(debugId), objectForId(newParent));
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::ObjectIdList: {
|
||||
int itemCount;
|
||||
ds >> itemCount;
|
||||
m_stringIdForObjectId.clear();
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
int itemDebugId;
|
||||
QString itemIdString;
|
||||
ds >> itemDebugId
|
||||
>> itemIdString;
|
||||
|
||||
m_stringIdForObjectId.insert(itemDebugId, itemIdString);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::ClearComponentCache: {
|
||||
emit clearComponentCacheRequested();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning() << "Warning: Not handling message:" << type;
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setDesignModeBehavior(bool inDesignMode)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::SetDesignMode
|
||||
<< inDesignMode;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setCurrentObjects(QList<QObject*> objects)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::CurrentObjectsChanged
|
||||
<< objects.length();
|
||||
|
||||
foreach (QObject *object, objects) {
|
||||
int id = idForObject(object);
|
||||
ds << id;
|
||||
}
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setCurrentTool(QmlJSDebugger::Constants::DesignTool toolId)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::ToolChanged
|
||||
<< toolId;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setAnimationSpeed(qreal slowDownFactor)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::AnimationSpeedChanged
|
||||
<< slowDownFactor;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setAnimationPaused(bool paused)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::AnimationPausedChanged
|
||||
<< paused;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::reloaded()
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::Reloaded;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setShowAppOnTop(bool showAppOnTop)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::ShowAppOnTop << showAppOnTop;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::selectedColorChanged(const QColor &color)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::ColorChanged
|
||||
<< color;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
QString QDeclarativeInspectorService::idStringForObject(QObject *obj) const
|
||||
{
|
||||
int id = idForObject(obj);
|
||||
QString idString = m_stringIdForObjectId.value(id, QString());
|
||||
return idString;
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::sendMessage(const QByteArray &message)
|
||||
{
|
||||
if (status() != Enabled)
|
||||
return;
|
||||
|
||||
QDeclarativeDebugService::sendMessage(message);
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,835 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "qdeclarativeviewinspector_p.h"
|
||||
#include "qdeclarativeinspectorservice.h"
|
||||
#include "editor/liveselectiontool.h"
|
||||
#include "editor/zoomtool.h"
|
||||
#include "editor/colorpickertool.h"
|
||||
#include "editor/livelayeritem.h"
|
||||
#include "editor/boundingrecthighlighter.h"
|
||||
|
||||
#include "qt_private/qdeclarativedebughelper_p.h"
|
||||
|
||||
#include <QDeclarativeItem>
|
||||
#include <QDeclarativeEngine>
|
||||
#include <QDeclarativeContext>
|
||||
#include <QDeclarativeExpression>
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <QGraphicsObject>
|
||||
#include <QApplication>
|
||||
|
||||
#include "qt_private/qdeclarativestate_p.h"
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
QDeclarativeViewInspectorPrivate::QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *q) :
|
||||
q(q),
|
||||
designModeBehavior(false),
|
||||
showAppOnTop(false),
|
||||
animationPaused(false),
|
||||
slowDownFactor(1.0f)
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeViewInspectorPrivate::~QDeclarativeViewInspectorPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent) :
|
||||
QObject(parent), data(new QDeclarativeViewInspectorPrivate(this))
|
||||
{
|
||||
data->view = view;
|
||||
data->manipulatorLayer = new LiveLayerItem(view->scene());
|
||||
data->selectionTool = new LiveSelectionTool(this);
|
||||
data->zoomTool = new ZoomTool(this);
|
||||
data->colorPickerTool = new ColorPickerTool(this);
|
||||
data->boundingRectHighlighter = new BoundingRectHighlighter(this);
|
||||
data->currentTool = data->selectionTool;
|
||||
|
||||
// to capture ChildRemoved event when viewport changes
|
||||
data->view->installEventFilter(this);
|
||||
|
||||
data->setViewport(data->view->viewport());
|
||||
|
||||
data->debugService = QDeclarativeInspectorService::instance();
|
||||
|
||||
connect(data->debugService, SIGNAL(designModeBehaviorChanged(bool)),
|
||||
SLOT(setDesignModeBehavior(bool)));
|
||||
connect(data->debugService, SIGNAL(showAppOnTopChanged(bool)),
|
||||
SLOT(setShowAppOnTop(bool)));
|
||||
connect(data->debugService, SIGNAL(reloadRequested()), data.data(), SLOT(_q_reloadView()));
|
||||
connect(data->debugService, SIGNAL(currentObjectsChanged(QList<QObject*>)),
|
||||
data.data(), SLOT(_q_onCurrentObjectsChanged(QList<QObject*>)));
|
||||
connect(data->debugService, SIGNAL(animationSpeedChangeRequested(qreal)),
|
||||
SLOT(animationSpeedChangeRequested(qreal)));
|
||||
connect(data->debugService, SIGNAL(executionPauseChangeRequested(bool)),
|
||||
SLOT(animationPausedChangeRequested(bool)));
|
||||
connect(data->debugService, SIGNAL(colorPickerToolRequested()),
|
||||
data.data(), SLOT(_q_changeToColorPickerTool()));
|
||||
connect(data->debugService, SIGNAL(selectMarqueeToolRequested()),
|
||||
data.data(), SLOT(_q_changeToMarqueeSelectTool()));
|
||||
connect(data->debugService, SIGNAL(selectToolRequested()), data.data(), SLOT(_q_changeToSingleSelectTool()));
|
||||
connect(data->debugService, SIGNAL(zoomToolRequested()), data.data(), SLOT(_q_changeToZoomTool()));
|
||||
connect(data->debugService,
|
||||
SIGNAL(objectCreationRequested(QString,QObject*,QStringList,QString,int)),
|
||||
data.data(), SLOT(_q_createQmlObject(QString,QObject*,QStringList,QString,int)));
|
||||
connect(data->debugService,
|
||||
SIGNAL(objectDeletionRequested(QObject*)), data.data(), SLOT(_q_deleteQmlObject(QObject*)));
|
||||
connect(data->debugService,
|
||||
SIGNAL(objectReparentRequested(QObject*,QObject*)),
|
||||
data.data(), SLOT(_q_reparentQmlObject(QObject*,QObject*)));
|
||||
connect(data->debugService, SIGNAL(clearComponentCacheRequested()),
|
||||
data.data(), SLOT(_q_clearComponentCache()));
|
||||
connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)),
|
||||
data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status)));
|
||||
|
||||
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
|
||||
SIGNAL(selectedColorChanged(QColor)));
|
||||
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
|
||||
data->debugService, SLOT(selectedColorChanged(QColor)));
|
||||
|
||||
data->_q_changeToSingleSelectTool();
|
||||
}
|
||||
|
||||
QDeclarativeViewInspector::~QDeclarativeViewInspector()
|
||||
{
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_reloadView()
|
||||
{
|
||||
clearHighlight();
|
||||
emit q->reloadRequested();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::setViewport(QWidget *widget)
|
||||
{
|
||||
if (viewport.data() == widget)
|
||||
return;
|
||||
|
||||
if (viewport)
|
||||
viewport.data()->removeEventFilter(q);
|
||||
|
||||
viewport = widget;
|
||||
if (viewport) {
|
||||
// make sure we get mouse move events
|
||||
viewport.data()->setMouseTracking(true);
|
||||
viewport.data()->installEventFilter(q);
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::clearEditorItems()
|
||||
{
|
||||
clearHighlight();
|
||||
setSelectedItems(QList<QGraphicsItem*>());
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::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))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonPress: {
|
||||
if (mousePressEvent(static_cast<QMouseEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseMove: {
|
||||
if (mouseMoveEvent(static_cast<QMouseEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonRelease: {
|
||||
if (mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::KeyPress: {
|
||||
if (keyPressEvent(static_cast<QKeyEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::KeyRelease: {
|
||||
if (keyReleaseEvent(static_cast<QKeyEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonDblClick: {
|
||||
if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::Wheel: {
|
||||
if (wheelEvent(static_cast<QWheelEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
} //switch
|
||||
|
||||
// standard event processing
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::leaveEvent(QEvent * /*event*/)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
data->clearHighlight();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
data->cursorPos = event->pos();
|
||||
data->currentTool->mousePressEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior) {
|
||||
data->clearEditorItems();
|
||||
return false;
|
||||
}
|
||||
data->cursorPos = event->pos();
|
||||
|
||||
QList<QGraphicsItem*> selItems = data->selectableItems(event->pos());
|
||||
if (!selItems.isEmpty()) {
|
||||
declarativeView()->setToolTip(AbstractLiveEditTool::titleForItem(selItems.first()));
|
||||
} else {
|
||||
declarativeView()->setToolTip(QString());
|
||||
}
|
||||
if (event->buttons()) {
|
||||
data->currentTool->mouseMoveEvent(event);
|
||||
} else {
|
||||
data->currentTool->hoverMoveEvent(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
|
||||
data->cursorPos = event->pos();
|
||||
data->currentTool->mouseReleaseEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
|
||||
data->currentTool->keyPressEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
|
||||
switch(event->key()) {
|
||||
case Qt::Key_V:
|
||||
data->_q_changeToSingleSelectTool();
|
||||
break;
|
||||
// disabled because multiselection does not do anything useful without design mode
|
||||
// case Qt::Key_M:
|
||||
// data->_q_changeToMarqueeSelectTool();
|
||||
// break;
|
||||
case Qt::Key_I:
|
||||
data->_q_changeToColorPickerTool();
|
||||
break;
|
||||
case Qt::Key_Z:
|
||||
data->_q_changeToZoomTool();
|
||||
break;
|
||||
case Qt::Key_Space:
|
||||
setAnimationPaused(!data->animationPaused);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
data->currentTool->keyReleaseEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool insertObjectInListProperty(QDeclarativeListReference &fromList, int position, QObject *object)
|
||||
{
|
||||
QList<QObject *> tmpList;
|
||||
int i;
|
||||
|
||||
if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
|
||||
return false;
|
||||
|
||||
if (position == fromList.count()) {
|
||||
fromList.append(object);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (i=0; i<fromList.count(); ++i)
|
||||
tmpList << fromList.at(i);
|
||||
|
||||
fromList.clear();
|
||||
for (i=0; i<position; ++i)
|
||||
fromList.append(tmpList.at(i));
|
||||
|
||||
fromList.append(object);
|
||||
for (; i<tmpList.count(); ++i)
|
||||
fromList.append(tmpList.at(i));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool removeObjectFromListProperty(QDeclarativeListReference &fromList, QObject *object)
|
||||
{
|
||||
QList<QObject *> tmpList;
|
||||
int i;
|
||||
|
||||
if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
|
||||
return false;
|
||||
|
||||
for (i=0; i<fromList.count(); ++i)
|
||||
if (object != fromList.at(i))
|
||||
tmpList << fromList.at(i);
|
||||
|
||||
fromList.clear();
|
||||
|
||||
foreach (QObject *item, tmpList)
|
||||
fromList.append(item);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_createQmlObject(const QString &qml, QObject *parent,
|
||||
const QStringList &importList,
|
||||
const QString &filename, int order)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
QString imports;
|
||||
foreach (const QString &s, importList) {
|
||||
imports += s;
|
||||
imports += QLatin1Char('\n');
|
||||
}
|
||||
|
||||
QDeclarativeContext *parentContext = view->engine()->contextForObject(parent);
|
||||
QDeclarativeComponent component(view->engine(), q);
|
||||
QByteArray constructedQml = QString(imports + qml).toLatin1();
|
||||
|
||||
component.setData(constructedQml, filename);
|
||||
QObject *newObject = component.create(parentContext);
|
||||
if (newObject) {
|
||||
newObject->setParent(parent);
|
||||
do {
|
||||
// add child item
|
||||
QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent);
|
||||
QDeclarativeItem *newItem = qobject_cast<QDeclarativeItem*>(newObject);
|
||||
if (parentItem && newItem) {
|
||||
newItem->setParentItem(parentItem);
|
||||
break;
|
||||
}
|
||||
|
||||
// add property change
|
||||
QDeclarativeState *parentState = qobject_cast<QDeclarativeState*>(parent);
|
||||
QDeclarativeStateOperation *newPropertyChanges = qobject_cast<QDeclarativeStateOperation *>(newObject);
|
||||
if (parentState && newPropertyChanges) {
|
||||
(*parentState) << newPropertyChanges;
|
||||
break;
|
||||
}
|
||||
|
||||
// add states
|
||||
QDeclarativeState *newState = qobject_cast<QDeclarativeState*>(newObject);
|
||||
if (parentItem && newState) {
|
||||
QDeclarativeListReference statesList(parentItem, "states");
|
||||
statesList.append(newObject);
|
||||
break;
|
||||
}
|
||||
|
||||
// add animation to transition
|
||||
if (parent->inherits("QDeclarativeTransition") &&
|
||||
newObject->inherits("QDeclarativeAbstractAnimation")) {
|
||||
QDeclarativeListReference animationsList(parent, "animations");
|
||||
animationsList.append(newObject);
|
||||
break;
|
||||
}
|
||||
|
||||
// add animation to animation
|
||||
if (parent->inherits("QDeclarativeAnimationGroup") &&
|
||||
newObject->inherits("QDeclarativeAbstractAnimation")) {
|
||||
QDeclarativeListReference animationsList(parent, "animations");
|
||||
if (order==-1) {
|
||||
animationsList.append(newObject);
|
||||
} else {
|
||||
if (!insertObjectInListProperty(animationsList, order, newObject)) {
|
||||
animationsList.append(newObject);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// add transition
|
||||
if (parentItem && newObject->inherits("QDeclarativeTransition")) {
|
||||
QDeclarativeListReference transitionsList(parentItem,"transitions");
|
||||
if (transitionsList.count() == 1 && transitionsList.at(0) == 0) {
|
||||
transitionsList.clear();
|
||||
}
|
||||
transitionsList.append(newObject);
|
||||
break;
|
||||
}
|
||||
|
||||
} while (false);
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_reparentQmlObject(QObject *object, QObject *newParent)
|
||||
{
|
||||
if (!newParent)
|
||||
return;
|
||||
|
||||
object->setParent(newParent);
|
||||
QDeclarativeItem *newParentItem = qobject_cast<QDeclarativeItem*>(newParent);
|
||||
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(object);
|
||||
if (newParentItem && item)
|
||||
item->setParentItem(newParentItem);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_deleteQmlObject(QObject *object)
|
||||
{
|
||||
// special cases for transitions/animations
|
||||
if (object->inherits("QDeclarativeAbstractAnimation")) {
|
||||
if (object->parent()) {
|
||||
QDeclarativeListReference animationsList(object->parent(), "animations");
|
||||
if (removeObjectFromListProperty(animationsList, object))
|
||||
object->deleteLater();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (object->inherits("QDeclarativeTransition")) {
|
||||
QDeclarativeListReference transitionsList(object->parent(), "transitions");
|
||||
if (removeObjectFromListProperty(transitionsList, object))
|
||||
object->deleteLater();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_clearComponentCache()
|
||||
{
|
||||
view->engine()->clearComponentCache();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj)
|
||||
{
|
||||
QList<QGraphicsItem*> items = selectedItems();
|
||||
if (QGraphicsItem *item = qobject_cast<QGraphicsObject*>(obj))
|
||||
items.removeOne(item);
|
||||
setSelectedItems(items);
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::mouseDoubleClickEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
data->currentTool->wheelEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setDesignModeBehavior(bool value)
|
||||
{
|
||||
emit designModeBehaviorChanged(value);
|
||||
|
||||
data->debugService->setDesignModeBehavior(value);
|
||||
|
||||
data->designModeBehavior = value;
|
||||
|
||||
if (!data->designModeBehavior)
|
||||
data->clearEditorItems();
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::designModeBehavior()
|
||||
{
|
||||
return data->designModeBehavior;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::showAppOnTop() const
|
||||
{
|
||||
return data->showAppOnTop;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setShowAppOnTop(bool appOnTop)
|
||||
{
|
||||
if (data->view) {
|
||||
QWidget *window = data->view->window();
|
||||
Qt::WindowFlags flags = window->windowFlags();
|
||||
if (appOnTop)
|
||||
flags |= Qt::WindowStaysOnTopHint;
|
||||
else
|
||||
flags &= ~Qt::WindowStaysOnTopHint;
|
||||
|
||||
window->setWindowFlags(flags);
|
||||
window->show();
|
||||
}
|
||||
|
||||
data->showAppOnTop = appOnTop;
|
||||
data->debugService->setShowAppOnTop(appOnTop);
|
||||
|
||||
emit showAppOnTopChanged(appOnTop);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::changeTool(Constants::DesignTool tool,
|
||||
Constants::ToolFlags /*flags*/)
|
||||
{
|
||||
switch(tool) {
|
||||
case Constants::SelectionToolMode:
|
||||
_q_changeToSingleSelectTool();
|
||||
break;
|
||||
case Constants::NoTool:
|
||||
default:
|
||||
currentTool = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(QList<QGraphicsItem *> items)
|
||||
{
|
||||
foreach (const QWeakPointer<QGraphicsObject> &obj, currentSelection) {
|
||||
if (QGraphicsItem *item = obj.data()) {
|
||||
if (!items.contains(item)) {
|
||||
QObject::disconnect(obj.data(), SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(_q_removeFromSelection(QObject*)));
|
||||
currentSelection.removeOne(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (QGraphicsItem *item, items) {
|
||||
if (QGraphicsObject *obj = item->toGraphicsObject()) {
|
||||
if (!currentSelection.contains(obj)) {
|
||||
QObject::connect(obj, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(_q_removeFromSelection(QObject*)));
|
||||
currentSelection.append(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentTool->updateSelectedItems();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::setSelectedItems(QList<QGraphicsItem *> items)
|
||||
{
|
||||
QList<QWeakPointer<QGraphicsObject> > oldList = currentSelection;
|
||||
setSelectedItemsForTools(items);
|
||||
if (oldList != currentSelection) {
|
||||
QList<QObject*> objectList;
|
||||
foreach (const QWeakPointer<QGraphicsObject> &graphicsObject, currentSelection) {
|
||||
if (graphicsObject)
|
||||
objectList << graphicsObject.data();
|
||||
}
|
||||
|
||||
debugService->setCurrentObjects(objectList);
|
||||
}
|
||||
}
|
||||
|
||||
QList<QGraphicsItem *> QDeclarativeViewInspectorPrivate::selectedItems()
|
||||
{
|
||||
QList<QGraphicsItem *> selection;
|
||||
foreach (const QWeakPointer<QGraphicsObject> &selectedObject, currentSelection) {
|
||||
if (selectedObject.data())
|
||||
selection << selectedObject.data();
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setSelectedItems(QList<QGraphicsItem *> items)
|
||||
{
|
||||
data->setSelectedItems(items);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem *> QDeclarativeViewInspector::selectedItems()
|
||||
{
|
||||
return data->selectedItems();
|
||||
}
|
||||
|
||||
QDeclarativeView *QDeclarativeViewInspector::declarativeView()
|
||||
{
|
||||
return data->view;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::clearHighlight()
|
||||
{
|
||||
boundingRectHighlighter->clear();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::highlight(const QList<QGraphicsObject *> &items)
|
||||
{
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
QList<QGraphicsObject*> objectList;
|
||||
foreach (QGraphicsItem *item, items) {
|
||||
QGraphicsItem *child = item;
|
||||
|
||||
if (child) {
|
||||
QGraphicsObject *childObject = child->toGraphicsObject();
|
||||
if (childObject)
|
||||
objectList << childObject;
|
||||
}
|
||||
}
|
||||
|
||||
boundingRectHighlighter->highlight(objectList);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(
|
||||
const QPointF &scenePos) const
|
||||
{
|
||||
QList<QGraphicsItem*> itemlist = view->scene()->items(scenePos);
|
||||
return filterForSelection(itemlist);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(const QPoint &pos) const
|
||||
{
|
||||
QList<QGraphicsItem*> itemlist = view->items(pos);
|
||||
return filterForSelection(itemlist);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(
|
||||
const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const
|
||||
{
|
||||
QList<QGraphicsItem*> itemlist = view->scene()->items(sceneRect, selectionMode);
|
||||
return filterForSelection(itemlist);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_changeToSingleSelectTool()
|
||||
{
|
||||
currentToolMode = Constants::SelectionToolMode;
|
||||
selectionTool->setRubberbandSelectionMode(false);
|
||||
|
||||
changeToSelectTool();
|
||||
|
||||
emit q->selectToolActivated();
|
||||
debugService->setCurrentTool(Constants::SelectionToolMode);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::changeToSelectTool()
|
||||
{
|
||||
if (currentTool == selectionTool)
|
||||
return;
|
||||
|
||||
currentTool->clear();
|
||||
currentTool = selectionTool;
|
||||
currentTool->clear();
|
||||
currentTool->updateSelectedItems();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_changeToMarqueeSelectTool()
|
||||
{
|
||||
changeToSelectTool();
|
||||
currentToolMode = Constants::MarqueeSelectionToolMode;
|
||||
selectionTool->setRubberbandSelectionMode(true);
|
||||
|
||||
emit q->marqueeSelectToolActivated();
|
||||
debugService->setCurrentTool(Constants::MarqueeSelectionToolMode);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_changeToZoomTool()
|
||||
{
|
||||
currentToolMode = Constants::ZoomMode;
|
||||
currentTool->clear();
|
||||
currentTool = zoomTool;
|
||||
currentTool->clear();
|
||||
|
||||
emit q->zoomToolActivated();
|
||||
debugService->setCurrentTool(Constants::ZoomMode);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_changeToColorPickerTool()
|
||||
{
|
||||
if (currentTool == colorPickerTool)
|
||||
return;
|
||||
|
||||
currentToolMode = Constants::ColorPickerMode;
|
||||
currentTool->clear();
|
||||
currentTool = colorPickerTool;
|
||||
currentTool->clear();
|
||||
|
||||
emit q->colorPickerActivated();
|
||||
debugService->setCurrentTool(Constants::ColorPickerMode);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setAnimationSpeed(qreal slowDownFactor)
|
||||
{
|
||||
Q_ASSERT(slowDownFactor > 0);
|
||||
if (data->slowDownFactor == slowDownFactor)
|
||||
return;
|
||||
|
||||
animationSpeedChangeRequested(slowDownFactor);
|
||||
data->debugService->setAnimationSpeed(slowDownFactor);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setAnimationPaused(bool paused)
|
||||
{
|
||||
if (data->animationPaused == paused)
|
||||
return;
|
||||
|
||||
animationPausedChangeRequested(paused);
|
||||
data->debugService->setAnimationPaused(paused);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::animationSpeedChangeRequested(qreal factor)
|
||||
{
|
||||
if (data->slowDownFactor != factor) {
|
||||
data->slowDownFactor = factor;
|
||||
emit animationSpeedChanged(factor);
|
||||
}
|
||||
|
||||
const float effectiveFactor = data->animationPaused ? 0 : factor;
|
||||
QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::animationPausedChangeRequested(bool paused)
|
||||
{
|
||||
if (data->animationPaused != paused) {
|
||||
data->animationPaused = paused;
|
||||
emit animationPausedChanged(paused);
|
||||
}
|
||||
|
||||
const float effectiveFactor = paused ? 0 : data->slowDownFactor;
|
||||
QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
|
||||
}
|
||||
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_applyChangesFromClient()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::filterForSelection(
|
||||
QList<QGraphicsItem*> &itemlist) const
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemlist) {
|
||||
if (isEditorItem(item))
|
||||
itemlist.removeOne(item);
|
||||
}
|
||||
|
||||
return itemlist;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspectorPrivate::isEditorItem(QGraphicsItem *item) const
|
||||
{
|
||||
return (item->type() == Constants::EditorItemType
|
||||
|| item->type() == Constants::ResizeHandleItemType
|
||||
|| item->data(Constants::EditorItemDataKey).toBool());
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_onStatusChanged(QDeclarativeView::Status status)
|
||||
{
|
||||
if (status == QDeclarativeView::Ready)
|
||||
debugService->reloaded();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_onCurrentObjectsChanged(QList<QObject*> objects)
|
||||
{
|
||||
QList<QGraphicsItem*> items;
|
||||
QList<QGraphicsObject*> gfxObjects;
|
||||
foreach (QObject *obj, objects) {
|
||||
if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) {
|
||||
items << declarativeItem;
|
||||
gfxObjects << declarativeItem;
|
||||
}
|
||||
}
|
||||
if (designModeBehavior) {
|
||||
setSelectedItemsForTools(items);
|
||||
clearHighlight();
|
||||
highlight(gfxObjects);
|
||||
}
|
||||
}
|
||||
|
||||
QString QDeclarativeViewInspector::idStringForObject(QObject *obj)
|
||||
{
|
||||
return QDeclarativeInspectorService::instance()->idStringForObject(obj);
|
||||
}
|
||||
|
||||
// adjusts bounding boxes on edges of screen to be visible
|
||||
QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
|
||||
{
|
||||
int marginFromEdge = 1;
|
||||
QRectF boundingRect(boundingRectInSceneSpace);
|
||||
if (qAbs(boundingRect.left()) - 1 < 2)
|
||||
boundingRect.setLeft(marginFromEdge);
|
||||
|
||||
QRect rect = data->view->rect();
|
||||
|
||||
if (boundingRect.right() >= rect.right())
|
||||
boundingRect.setRight(rect.right() - marginFromEdge);
|
||||
|
||||
if (qAbs(boundingRect.top()) - 1 < 2)
|
||||
boundingRect.setTop(marginFromEdge);
|
||||
|
||||
if (boundingRect.bottom() >= rect.bottom())
|
||||
boundingRect.setBottom(rect.bottom() - marginFromEdge);
|
||||
|
||||
return boundingRect;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,129 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEVIEWINSPECTOR_P_H
|
||||
#define QDECLARATIVEVIEWINSPECTOR_P_H
|
||||
|
||||
#include <QWeakPointer>
|
||||
#include <QPointF>
|
||||
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "qdeclarativeinspectorservice.h"
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class JSDebuggerAgent;
|
||||
class QDeclarativeViewInspector;
|
||||
class LiveSelectionTool;
|
||||
class ZoomTool;
|
||||
class ColorPickerTool;
|
||||
class LiveLayerItem;
|
||||
class BoundingRectHighlighter;
|
||||
class CrumblePath;
|
||||
class AbstractLiveEditTool;
|
||||
|
||||
class QDeclarativeViewInspectorPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *);
|
||||
~QDeclarativeViewInspectorPrivate();
|
||||
|
||||
QDeclarativeView *view;
|
||||
QDeclarativeViewInspector *q;
|
||||
QDeclarativeInspectorService *debugService;
|
||||
QWeakPointer<QWidget> viewport;
|
||||
|
||||
QPointF cursorPos;
|
||||
QList<QWeakPointer<QGraphicsObject> > currentSelection;
|
||||
|
||||
Constants::DesignTool currentToolMode;
|
||||
AbstractLiveEditTool *currentTool;
|
||||
|
||||
LiveSelectionTool *selectionTool;
|
||||
ZoomTool *zoomTool;
|
||||
ColorPickerTool *colorPickerTool;
|
||||
LiveLayerItem *manipulatorLayer;
|
||||
|
||||
BoundingRectHighlighter *boundingRectHighlighter;
|
||||
|
||||
bool designModeBehavior;
|
||||
bool showAppOnTop;
|
||||
|
||||
bool animationPaused;
|
||||
qreal slowDownFactor;
|
||||
|
||||
void setViewport(QWidget *widget);
|
||||
|
||||
void clearEditorItems();
|
||||
void changeToSelectTool();
|
||||
QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const;
|
||||
|
||||
QList<QGraphicsItem*> selectableItems(const QPoint &pos) const;
|
||||
QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
|
||||
QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
|
||||
|
||||
void setSelectedItemsForTools(QList<QGraphicsItem *> items);
|
||||
void setSelectedItems(QList<QGraphicsItem *> items);
|
||||
QList<QGraphicsItem *> selectedItems();
|
||||
|
||||
void changeTool(Constants::DesignTool tool,
|
||||
Constants::ToolFlags flags = Constants::NoToolFlags);
|
||||
|
||||
void clearHighlight();
|
||||
void highlight(const QList<QGraphicsObject *> &item);
|
||||
inline void highlight(QGraphicsObject *item)
|
||||
{ highlight(QList<QGraphicsObject*>() << item); }
|
||||
|
||||
bool isEditorItem(QGraphicsItem *item) const;
|
||||
|
||||
public slots:
|
||||
void _q_reloadView();
|
||||
void _q_onStatusChanged(QDeclarativeView::Status status);
|
||||
void _q_onCurrentObjectsChanged(QList<QObject*> objects);
|
||||
void _q_applyChangesFromClient();
|
||||
void _q_createQmlObject(const QString &qml, QObject *parent,
|
||||
const QStringList &imports, const QString &filename = QString(), int order = 0);
|
||||
void _q_reparentQmlObject(QObject *, QObject *);
|
||||
void _q_deleteQmlObject(QObject *);
|
||||
|
||||
void _q_changeToSingleSelectTool();
|
||||
void _q_changeToMarqueeSelectTool();
|
||||
void _q_changeToZoomTool();
|
||||
void _q_changeToColorPickerTool();
|
||||
void _q_clearComponentCache();
|
||||
void _q_removeFromSelection(QObject *);
|
||||
|
||||
public:
|
||||
static QDeclarativeViewInspectorPrivate *get(QDeclarativeViewInspector *v) { return v->d_func(); }
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QDECLARATIVEVIEWINSPECTOR_P_H
|
||||
@@ -1,14 +0,0 @@
|
||||
# This file is part of Qt Creator
|
||||
# It enables debugging of Qt Quick applications
|
||||
|
||||
QT += declarative script
|
||||
INCLUDEPATH += $$PWD/include
|
||||
|
||||
windows:CONFIG(debug, debug|release) {
|
||||
LIBNAME = QmlJSDebuggerd
|
||||
} else {
|
||||
LIBNAME = QmlJSDebugger
|
||||
}
|
||||
LIBS += -L$$PWD -l$$LIBNAME
|
||||
|
||||
DEFINES += QMLJSDEBUGGER
|
||||
@@ -1,45 +0,0 @@
|
||||
INCLUDEPATH += $$PWD/include
|
||||
|
||||
include($$PWD/protocol/protocol.pri)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/include/jsdebuggeragent.h \
|
||||
$$PWD/include/qmljsdebugger_global.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/jsdebuggeragent.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/include/qdeclarativeviewinspector.h \
|
||||
$$PWD/include/qdeclarativeviewobserver.h \
|
||||
$$PWD/include/qdeclarativeinspectorservice.h \
|
||||
$$PWD/include/qmlinspectorconstants.h \
|
||||
$$PWD/editor/abstractliveedittool.h \
|
||||
$$PWD/editor/liveselectiontool.h \
|
||||
$$PWD/editor/livelayeritem.h \
|
||||
$$PWD/editor/livesingleselectionmanipulator.h \
|
||||
$$PWD/editor/liverubberbandselectionmanipulator.h \
|
||||
$$PWD/editor/liveselectionrectangle.h \
|
||||
$$PWD/editor/liveselectionindicator.h \
|
||||
$$PWD/editor/boundingrecthighlighter.h \
|
||||
$$PWD/editor/subcomponentmasklayeritem.h \
|
||||
$$PWD/editor/zoomtool.h \
|
||||
$$PWD/editor/colorpickertool.h \
|
||||
$$PWD/qdeclarativeviewinspector_p.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/qdeclarativeviewinspector.cpp \
|
||||
$$PWD/qdeclarativeinspectorservice.cpp \
|
||||
$$PWD/editor/abstractliveedittool.cpp \
|
||||
$$PWD/editor/liveselectiontool.cpp \
|
||||
$$PWD/editor/livelayeritem.cpp \
|
||||
$$PWD/editor/livesingleselectionmanipulator.cpp \
|
||||
$$PWD/editor/liverubberbandselectionmanipulator.cpp \
|
||||
$$PWD/editor/liveselectionrectangle.cpp \
|
||||
$$PWD/editor/liveselectionindicator.cpp \
|
||||
$$PWD/editor/boundingrecthighlighter.cpp \
|
||||
$$PWD/editor/subcomponentmasklayeritem.cpp \
|
||||
$$PWD/editor/zoomtool.cpp \
|
||||
$$PWD/editor/colorpickertool.cpp
|
||||
|
||||
DEFINES += QMLJSDEBUGGER
|
||||
@@ -1,18 +0,0 @@
|
||||
# This file is part of Qt Creator
|
||||
# It enables debugging of Qt Quick applications
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += staticlib create_prl
|
||||
QT += declarative script
|
||||
|
||||
DEFINES += BUILD_QMLJSDEBUGGER_STATIC_LIB
|
||||
|
||||
unix:QMAKE_CXXFLAGS_DEBUG += -O3
|
||||
|
||||
DESTDIR = $$PWD
|
||||
TARGET=QmlJSDebugger
|
||||
CONFIG(debug, debug|release) {
|
||||
windows:TARGET=QmlJSDebuggerd
|
||||
}
|
||||
|
||||
include(qmljsdebugger-src.pri)
|
||||
@@ -1,77 +0,0 @@
|
||||
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">
|
||||
<plist version=\"0.1\">
|
||||
<dict>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>This file is part of Qt Creator
|
||||
|
||||
Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
|
||||
Contact: http://www.qt-project.org/
|
||||
|
||||
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, Digia gives you certain additional
|
||||
rights. These rights are described in the Digia Qt LGPL Exception
|
||||
version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
|
||||
Other Usage
|
||||
|
||||
Alternatively, this file may be used in accordance with the terms and
|
||||
conditions contained in a signed written agreement between you and Digia.</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>@ICON@</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.nokia.qt.qml</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>Created by Qt/QMake</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>@TYPEINFO@</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>@EXECUTABLE@</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$$QTCREATOR_VERSION</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$$QTCREATOR_VERSION</string>
|
||||
<key>UTExportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>com.nokia.qt.qml</string>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>Qt Markup Language</string>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.plain-text</string>
|
||||
</array>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
<array>
|
||||
<string>qml</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>com.nokia.qt.qml</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,22 +0,0 @@
|
||||
Digia Qt LGPL Exception version 1.1
|
||||
|
||||
As an additional permission to the GNU Lesser General Public License version
|
||||
2.1, the object code form of a "work that uses the Library" may incorporate
|
||||
material from a header file that is part of the Library. You may distribute
|
||||
such object code under terms of your choice, provided that:
|
||||
(i) the header files of the Library have not been modified; and
|
||||
(ii) the incorporated material is limited to numerical parameters, data
|
||||
structure layouts, accessors, macros, inline functions and
|
||||
templates; and
|
||||
(iii) you comply with the terms of Section 6 of the GNU Lesser General
|
||||
Public License version 2.1.
|
||||
|
||||
Moreover, you may apply this exception to a modified version of the Library,
|
||||
provided that such modification does not involve copying material from the
|
||||
Library into the modified Library's header files unless such material is
|
||||
limited to (i) numerical parameters; (ii) data structure layouts;
|
||||
(iii) accessors; and (iv) small macros, templates and inline functions of
|
||||
five lines or less in length.
|
||||
|
||||
Furthermore, you are not required to apply this additional permission to a
|
||||
modified version of the Library.
|
||||
@@ -1,504 +0,0 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
@@ -1,306 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 1.0
|
||||
import Qt.labs.folderlistmodel 1.0
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
property bool showFocusHighlight: false
|
||||
property variant folders: folders1
|
||||
property variant view: view1
|
||||
width: 320
|
||||
height: 480
|
||||
color: palette.window
|
||||
|
||||
FolderListModel {
|
||||
id: folders1
|
||||
nameFilters: [ "*.qml" ]
|
||||
folder: qmlViewerFolder
|
||||
}
|
||||
FolderListModel {
|
||||
id: folders2
|
||||
nameFilters: [ "*.qml" ]
|
||||
folder: qmlViewerFolder
|
||||
}
|
||||
|
||||
SystemPalette { id: palette }
|
||||
|
||||
function down(path) {
|
||||
if (folders == folders1) {
|
||||
view = view2
|
||||
folders = folders2;
|
||||
view1.state = "exitLeft";
|
||||
} else {
|
||||
view = view1
|
||||
folders = folders1;
|
||||
view2.state = "exitLeft";
|
||||
}
|
||||
view.x = root.width;
|
||||
view.state = "current";
|
||||
view.focus = true;
|
||||
folders.folder = path;
|
||||
}
|
||||
function up() {
|
||||
var path = folders.parentFolder;
|
||||
if (folders == folders1) {
|
||||
view = view2
|
||||
folders = folders2;
|
||||
view1.state = "exitRight";
|
||||
} else {
|
||||
view = view1
|
||||
folders = folders1;
|
||||
view2.state = "exitRight";
|
||||
}
|
||||
view.x = -root.width;
|
||||
view.state = "current";
|
||||
view.focus = true;
|
||||
folders.folder = path;
|
||||
}
|
||||
function keyPressed(key) {
|
||||
switch (key) {
|
||||
case Qt.Key_Up:
|
||||
case Qt.Key_Down:
|
||||
case Qt.Key_Left:
|
||||
case Qt.Key_Right:
|
||||
root.showFocusHighlight = true;
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: folderDelegate
|
||||
Rectangle {
|
||||
id: wrapper
|
||||
function launch() {
|
||||
if (folders.isFolder(index)) {
|
||||
down(filePath);
|
||||
} else {
|
||||
qmlViewer.launch(filePath);
|
||||
}
|
||||
}
|
||||
width: root.width
|
||||
height: 52
|
||||
color: "transparent"
|
||||
Rectangle {
|
||||
id: highlight; visible: false
|
||||
anchors.fill: parent
|
||||
color: palette.highlight
|
||||
gradient: Gradient {
|
||||
GradientStop { id: t1; position: 0.0; color: palette.highlight }
|
||||
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
|
||||
}
|
||||
}
|
||||
Item {
|
||||
width: 48; height: 48
|
||||
Image { source: "images/folder.png"; anchors.centerIn: parent; visible: folders.isFolder(index)}
|
||||
}
|
||||
Text {
|
||||
id: nameText
|
||||
anchors.fill: parent; verticalAlignment: Text.AlignVCenter
|
||||
text: fileName
|
||||
anchors.leftMargin: 54
|
||||
font.pixelSize: 32
|
||||
color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : palette.windowText
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
MouseArea {
|
||||
id: mouseRegion
|
||||
anchors.fill: parent
|
||||
onPressed: {
|
||||
root.showFocusHighlight = false;
|
||||
wrapper.ListView.view.currentIndex = index;
|
||||
}
|
||||
onClicked: { if (folders == wrapper.ListView.view.model) launch() }
|
||||
}
|
||||
states: [
|
||||
State {
|
||||
name: "pressed"
|
||||
when: mouseRegion.pressed
|
||||
PropertyChanges { target: highlight; visible: true }
|
||||
PropertyChanges { target: nameText; color: palette.highlightedText }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: view1
|
||||
anchors.top: titleBar.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
x: 0
|
||||
width: parent.width
|
||||
model: folders1
|
||||
delegate: folderDelegate
|
||||
highlight: Rectangle {
|
||||
color: palette.highlight
|
||||
visible: root.showFocusHighlight && view1.count != 0
|
||||
gradient: Gradient {
|
||||
GradientStop { id: t1; position: 0.0; color: palette.highlight }
|
||||
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
|
||||
}
|
||||
width: view1.currentItem == null ? 0 : view1.currentItem.width
|
||||
}
|
||||
highlightMoveSpeed: 1000
|
||||
pressDelay: 100
|
||||
focus: true
|
||||
state: "current"
|
||||
states: [
|
||||
State {
|
||||
name: "current"
|
||||
PropertyChanges { target: view1; x: 0 }
|
||||
},
|
||||
State {
|
||||
name: "exitLeft"
|
||||
PropertyChanges { target: view1; x: -root.width }
|
||||
},
|
||||
State {
|
||||
name: "exitRight"
|
||||
PropertyChanges { target: view1; x: root.width }
|
||||
}
|
||||
]
|
||||
transitions: [
|
||||
Transition {
|
||||
to: "current"
|
||||
SequentialAnimation {
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
}
|
||||
]
|
||||
Keys.onPressed: root.keyPressed(event.key)
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: view2
|
||||
anchors.top: titleBar.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
x: parent.width
|
||||
width: parent.width
|
||||
model: folders2
|
||||
delegate: folderDelegate
|
||||
highlight: Rectangle {
|
||||
color: palette.highlight
|
||||
visible: root.showFocusHighlight && view2.count != 0
|
||||
gradient: Gradient {
|
||||
GradientStop { id: t1; position: 0.0; color: palette.highlight }
|
||||
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
|
||||
}
|
||||
width: view1.currentItem == null ? 0 : view1.currentItem.width
|
||||
}
|
||||
highlightMoveSpeed: 1000
|
||||
pressDelay: 100
|
||||
states: [
|
||||
State {
|
||||
name: "current"
|
||||
PropertyChanges { target: view2; x: 0 }
|
||||
},
|
||||
State {
|
||||
name: "exitLeft"
|
||||
PropertyChanges { target: view2; x: -root.width }
|
||||
},
|
||||
State {
|
||||
name: "exitRight"
|
||||
PropertyChanges { target: view2; x: root.width }
|
||||
}
|
||||
]
|
||||
transitions: [
|
||||
Transition {
|
||||
to: "current"
|
||||
SequentialAnimation {
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
}
|
||||
]
|
||||
Keys.onPressed: root.keyPressed(event.key)
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
root.keyPressed(event.key);
|
||||
if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) {
|
||||
view.currentItem.launch();
|
||||
event.accepted = true;
|
||||
} else if (event.key == Qt.Key_Left) {
|
||||
up();
|
||||
}
|
||||
}
|
||||
|
||||
BorderImage {
|
||||
source: "images/titlebar.sci";
|
||||
width: parent.width;
|
||||
height: 52
|
||||
y: -7
|
||||
id: titleBar
|
||||
|
||||
Rectangle {
|
||||
id: upButton
|
||||
width: 48
|
||||
height: titleBar.height - 7
|
||||
color: "transparent"
|
||||
|
||||
Image { anchors.centerIn: parent; source: "images/up.png" }
|
||||
MouseArea { id: upRegion; anchors.centerIn: parent
|
||||
width: 56
|
||||
height: 56
|
||||
onClicked: if (folders.parentFolder != "") up()
|
||||
}
|
||||
states: [
|
||||
State {
|
||||
name: "pressed"
|
||||
when: upRegion.pressed
|
||||
PropertyChanges { target: upButton; color: palette.highlight }
|
||||
}
|
||||
]
|
||||
}
|
||||
Rectangle {
|
||||
color: "gray"
|
||||
x: 48
|
||||
width: 1
|
||||
height: 44
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.left: upButton.right; anchors.right: parent.right; height: parent.height
|
||||
anchors.leftMargin: 4; anchors.rightMargin: 4
|
||||
text: folders.folder
|
||||
color: "white"
|
||||
elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
|
||||
font.pixelSize: 32
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/browser">
|
||||
<file>Browser.qml</file>
|
||||
<file>images/up.png</file>
|
||||
<file>images/folder.png</file>
|
||||
<file>images/titlebar.sci</file>
|
||||
<file>images/titlebar.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1,5 +0,0 @@
|
||||
border.left: 10
|
||||
border.top: 12
|
||||
border.bottom: 12
|
||||
border.right: 10
|
||||
source: titlebar.png
|
||||
|
Before Width: | Height: | Size: 662 B |
@@ -1,68 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "deviceorientation.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class DefaultDeviceOrientation : public DeviceOrientation
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DefaultDeviceOrientation() : DeviceOrientation(), m_orientation(DeviceOrientation::Portrait) {}
|
||||
|
||||
Orientation orientation() const {
|
||||
return m_orientation;
|
||||
}
|
||||
|
||||
void pauseListening() {
|
||||
}
|
||||
void resumeListening() {
|
||||
}
|
||||
|
||||
void setOrientation(Orientation o) {
|
||||
if (o != m_orientation) {
|
||||
m_orientation = o;
|
||||
emit orientationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Orientation m_orientation;
|
||||
};
|
||||
|
||||
DeviceOrientation* DeviceOrientation::instance()
|
||||
{
|
||||
static DefaultDeviceOrientation *o = 0;
|
||||
if (!o)
|
||||
o = new DefaultDeviceOrientation;
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "deviceorientation.moc"
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ORIENTATION_H
|
||||
#define ORIENTATION_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class DeviceOrientationPrivate;
|
||||
class DeviceOrientation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Orientation)
|
||||
public:
|
||||
enum Orientation {
|
||||
UnknownOrientation,
|
||||
Portrait,
|
||||
Landscape,
|
||||
PortraitInverted,
|
||||
LandscapeInverted
|
||||
};
|
||||
|
||||
virtual Orientation orientation() const = 0;
|
||||
virtual void setOrientation(Orientation) = 0;
|
||||
|
||||
virtual void pauseListening() = 0;
|
||||
virtual void resumeListening() = 0;
|
||||
|
||||
static DeviceOrientation *instance();
|
||||
|
||||
signals:
|
||||
void orientationChanged();
|
||||
|
||||
protected:
|
||||
DeviceOrientation() {}
|
||||
|
||||
private:
|
||||
DeviceOrientationPrivate *d_ptr;
|
||||
friend class DeviceOrientationPrivate;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
@@ -1,180 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "deviceorientation.h"
|
||||
|
||||
#include <e32base.h>
|
||||
#include <sensrvchannelfinder.h>
|
||||
#include <sensrvdatalistener.h>
|
||||
#include <sensrvchannel.h>
|
||||
#include <sensrvorientationsensor.h>
|
||||
|
||||
class SymbianOrientation : public DeviceOrientation, public MSensrvDataListener
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SymbianOrientation()
|
||||
: DeviceOrientation(), m_current(UnknownOrientation), m_sensorChannel(0), m_channelOpen(false)
|
||||
{
|
||||
TRAP_IGNORE(initL());
|
||||
if (!m_sensorChannel)
|
||||
qWarning("No valid sensors found.");
|
||||
}
|
||||
|
||||
~SymbianOrientation()
|
||||
{
|
||||
if (m_sensorChannel) {
|
||||
m_sensorChannel->StopDataListening();
|
||||
m_sensorChannel->CloseChannel();
|
||||
delete m_sensorChannel;
|
||||
}
|
||||
}
|
||||
|
||||
void initL()
|
||||
{
|
||||
CSensrvChannelFinder *channelFinder = CSensrvChannelFinder::NewLC();
|
||||
RSensrvChannelInfoList channelInfoList;
|
||||
CleanupClosePushL(channelInfoList);
|
||||
|
||||
TSensrvChannelInfo searchConditions;
|
||||
searchConditions.iChannelType = KSensrvChannelTypeIdOrientationData;
|
||||
channelFinder->FindChannelsL(channelInfoList, searchConditions);
|
||||
|
||||
for (int i = 0; i < channelInfoList.Count(); ++i) {
|
||||
TRAPD(error, m_sensorChannel = CSensrvChannel::NewL(channelInfoList[i]));
|
||||
if (!error)
|
||||
TRAP(error, m_sensorChannel->OpenChannelL());
|
||||
if (!error) {
|
||||
TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
|
||||
m_channelOpen = true;
|
||||
break;
|
||||
}
|
||||
if (error) {
|
||||
delete m_sensorChannel;
|
||||
m_sensorChannel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
channelInfoList.Close();
|
||||
CleanupStack::Pop(&channelInfoList);
|
||||
CleanupStack::PopAndDestroy(channelFinder);
|
||||
}
|
||||
|
||||
Orientation orientation() const
|
||||
{
|
||||
return m_current;
|
||||
}
|
||||
|
||||
void setOrientation(Orientation) { }
|
||||
|
||||
private:
|
||||
DeviceOrientation::Orientation m_current;
|
||||
CSensrvChannel *m_sensorChannel;
|
||||
bool m_channelOpen;
|
||||
void pauseListening() {
|
||||
if (m_sensorChannel && m_channelOpen) {
|
||||
m_sensorChannel->StopDataListening();
|
||||
m_sensorChannel->CloseChannel();
|
||||
m_channelOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
void resumeListening() {
|
||||
if (m_sensorChannel && !m_channelOpen) {
|
||||
TRAPD(error, m_sensorChannel->OpenChannelL());
|
||||
if (!error) {
|
||||
TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
|
||||
if (!error) {
|
||||
m_channelOpen = true;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
delete m_sensorChannel;
|
||||
m_sensorChannel = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataReceived(CSensrvChannel &channel, TInt count, TInt dataLost)
|
||||
{
|
||||
Q_UNUSED(dataLost)
|
||||
if (channel.GetChannelInfo().iChannelType == KSensrvChannelTypeIdOrientationData) {
|
||||
TSensrvOrientationData data;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
TPckgBuf<TSensrvOrientationData> dataBuf;
|
||||
channel.GetData(dataBuf);
|
||||
data = dataBuf();
|
||||
Orientation orientation = UnknownOrientation;
|
||||
switch (data.iDeviceOrientation) {
|
||||
case TSensrvOrientationData::EOrientationDisplayUp:
|
||||
orientation = Portrait;
|
||||
break;
|
||||
case TSensrvOrientationData::EOrientationDisplayRightUp:
|
||||
orientation = Landscape;
|
||||
break;
|
||||
case TSensrvOrientationData::EOrientationDisplayLeftUp:
|
||||
orientation = LandscapeInverted;
|
||||
break;
|
||||
case TSensrvOrientationData::EOrientationDisplayDown:
|
||||
orientation = PortraitInverted;
|
||||
break;
|
||||
case TSensrvOrientationData::EOrientationUndefined:
|
||||
case TSensrvOrientationData::EOrientationDisplayUpwards:
|
||||
case TSensrvOrientationData::EOrientationDisplayDownwards:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_current != orientation && orientation != UnknownOrientation) {
|
||||
m_current = orientation;
|
||||
emit orientationChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataError(CSensrvChannel& /* channel */, TSensrvErrorSeverity /* error */)
|
||||
{
|
||||
}
|
||||
|
||||
void GetDataListenerInterfaceL(TUid /* interfaceUid */, TAny*& /* interface */)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
DeviceOrientation* DeviceOrientation::instance()
|
||||
{
|
||||
static SymbianOrientation *o = 0;
|
||||
if (!o)
|
||||
o = new SymbianOrientation;
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "deviceorientation_symbian.moc"
|
||||
@@ -1,189 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qglobal.h>
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QActionGroup>
|
||||
#include <QMenu>
|
||||
#include <QPlainTextEdit>
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
# include <QScrollArea>
|
||||
# include <QVBoxLayout>
|
||||
# include "texteditautoresizer_maemo5.h"
|
||||
#endif
|
||||
|
||||
#include "loggerwidget.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
LoggerWidget::LoggerWidget(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
m_visibilityOrigin(SettingsOrigin)
|
||||
{
|
||||
setAttribute(Qt::WA_QuitOnClose, false);
|
||||
setWindowTitle(tr("Warnings"));
|
||||
|
||||
m_plainTextEdit = new QPlainTextEdit();
|
||||
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
new TextEditAutoResizer(m_plainTextEdit);
|
||||
setAttribute(Qt::WA_Maemo5StackedWindow);
|
||||
QScrollArea *area = new QScrollArea();
|
||||
area->setWidget(m_plainTextEdit);
|
||||
area->setWidgetResizable(true);
|
||||
setCentralWidget(area);
|
||||
#else
|
||||
setCentralWidget(m_plainTextEdit);
|
||||
#endif
|
||||
readSettings();
|
||||
setupPreferencesMenu();
|
||||
}
|
||||
|
||||
void LoggerWidget::append(const QString &msg)
|
||||
{
|
||||
m_plainTextEdit->appendPlainText(msg);
|
||||
|
||||
if (!isVisible() && (defaultVisibility() == AutoShowWarnings))
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
LoggerWidget::Visibility LoggerWidget::defaultVisibility() const
|
||||
{
|
||||
return m_visibility;
|
||||
}
|
||||
|
||||
void LoggerWidget::setDefaultVisibility(LoggerWidget::Visibility visibility)
|
||||
{
|
||||
if (m_visibility == visibility)
|
||||
return;
|
||||
|
||||
m_visibility = visibility;
|
||||
m_visibilityOrigin = CommandLineOrigin;
|
||||
|
||||
m_preferencesMenu->setEnabled(m_visibilityOrigin == SettingsOrigin);
|
||||
}
|
||||
|
||||
QMenu *LoggerWidget::preferencesMenu()
|
||||
{
|
||||
return m_preferencesMenu;
|
||||
}
|
||||
|
||||
QAction *LoggerWidget::showAction()
|
||||
{
|
||||
return m_showWidgetAction;
|
||||
}
|
||||
|
||||
void LoggerWidget::readSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
QString warningsPreferences = settings.value("warnings", "hide").toString();
|
||||
if (warningsPreferences == "show") {
|
||||
m_visibility = ShowWarnings;
|
||||
} else if (warningsPreferences == "hide") {
|
||||
m_visibility = HideWarnings;
|
||||
} else {
|
||||
m_visibility = AutoShowWarnings;
|
||||
}
|
||||
}
|
||||
|
||||
void LoggerWidget::saveSettings()
|
||||
{
|
||||
if (m_visibilityOrigin != SettingsOrigin)
|
||||
return;
|
||||
|
||||
QString value = "autoShow";
|
||||
if (defaultVisibility() == ShowWarnings) {
|
||||
value = "show";
|
||||
} else if (defaultVisibility() == HideWarnings) {
|
||||
value = "hide";
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
settings.setValue("warnings", value);
|
||||
}
|
||||
|
||||
void LoggerWidget::warningsPreferenceChanged(QAction *action)
|
||||
{
|
||||
Visibility newSetting = static_cast<Visibility>(action->data().toInt());
|
||||
m_visibility = newSetting;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
void LoggerWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
QWidget::showEvent(event);
|
||||
emit opened();
|
||||
}
|
||||
|
||||
void LoggerWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QWidget::closeEvent(event);
|
||||
emit closed();
|
||||
}
|
||||
|
||||
void LoggerWidget::setupPreferencesMenu()
|
||||
{
|
||||
m_preferencesMenu = new QMenu(tr("Warnings"));
|
||||
QActionGroup *warnings = new QActionGroup(m_preferencesMenu);
|
||||
warnings->setExclusive(true);
|
||||
|
||||
connect(warnings, SIGNAL(triggered(QAction*)), this, SLOT(warningsPreferenceChanged(QAction*)));
|
||||
|
||||
QAction *showWarningsPreference = new QAction(tr("Show by default"), m_preferencesMenu);
|
||||
showWarningsPreference->setCheckable(true);
|
||||
showWarningsPreference->setData(LoggerWidget::ShowWarnings);
|
||||
warnings->addAction(showWarningsPreference);
|
||||
m_preferencesMenu->addAction(showWarningsPreference);
|
||||
|
||||
QAction *hideWarningsPreference = new QAction(tr("Hide by default"), m_preferencesMenu);
|
||||
hideWarningsPreference->setCheckable(true);
|
||||
hideWarningsPreference->setData(LoggerWidget::HideWarnings);
|
||||
warnings->addAction(hideWarningsPreference);
|
||||
m_preferencesMenu->addAction(hideWarningsPreference);
|
||||
|
||||
QAction *autoWarningsPreference = new QAction(tr("Show for first warning"), m_preferencesMenu);
|
||||
autoWarningsPreference->setCheckable(true);
|
||||
autoWarningsPreference->setData(LoggerWidget::AutoShowWarnings);
|
||||
warnings->addAction(autoWarningsPreference);
|
||||
m_preferencesMenu->addAction(autoWarningsPreference);
|
||||
|
||||
switch (defaultVisibility()) {
|
||||
case LoggerWidget::ShowWarnings:
|
||||
showWarningsPreference->setChecked(true);
|
||||
break;
|
||||
case LoggerWidget::HideWarnings:
|
||||
hideWarningsPreference->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
autoWarningsPreference->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
@@ -1,87 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LOGGERWIDGET_H
|
||||
#define LOGGERWIDGET_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMetaType>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QPlainTextEdit;
|
||||
class QMenu;
|
||||
class QAction;
|
||||
|
||||
class LoggerWidget : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
LoggerWidget(QWidget *parent=0);
|
||||
|
||||
enum Visibility { ShowWarnings, HideWarnings, AutoShowWarnings };
|
||||
|
||||
Visibility defaultVisibility() const;
|
||||
void setDefaultVisibility(Visibility visibility);
|
||||
|
||||
QMenu *preferencesMenu();
|
||||
QAction *showAction();
|
||||
|
||||
public slots:
|
||||
void append(const QString &msg);
|
||||
|
||||
private slots:
|
||||
void warningsPreferenceChanged(QAction *action);
|
||||
void readSettings();
|
||||
void saveSettings();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
signals:
|
||||
void opened();
|
||||
void closed();
|
||||
|
||||
private:
|
||||
void setupPreferencesMenu();
|
||||
|
||||
QMenu *m_preferencesMenu;
|
||||
QAction *m_showWidgetAction;
|
||||
QPlainTextEdit *m_plainTextEdit;
|
||||
|
||||
enum ConfigOrigin { CommandLineOrigin, SettingsOrigin };
|
||||
ConfigOrigin m_visibilityOrigin;
|
||||
Visibility m_visibility;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(LoggerWidget::Visibility)
|
||||
|
||||
#endif // LOGGERWIDGET_H
|
||||
@@ -1,562 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarative.h"
|
||||
#include "qmlruntime.h"
|
||||
#include "qdeclarativeengine.h"
|
||||
#include "loggerwidget.h"
|
||||
#include <QWidget>
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QAtomicInt>
|
||||
#include "qdeclarativetester.h"
|
||||
#include "qt_private/qdeclarativedebughelper_p.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
QtMsgHandler systemMsgOutput = 0;
|
||||
|
||||
static QDeclarativeViewer *openFile(const QString &fileName);
|
||||
static void showViewer(QDeclarativeViewer *viewer);
|
||||
|
||||
QWeakPointer<LoggerWidget> logger;
|
||||
|
||||
QString warnings;
|
||||
void exitApp(int i)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
// Debugging output is not visible by default on Windows -
|
||||
// therefore show modal dialog with errors instead.
|
||||
if (!warnings.isEmpty()) {
|
||||
QMessageBox::warning(0, QApplication::tr("Qt QML Viewer"), warnings);
|
||||
}
|
||||
#endif
|
||||
exit(i);
|
||||
}
|
||||
|
||||
static QAtomicInt recursiveLock(0);
|
||||
|
||||
void myMessageOutput(QtMsgType type, const char *msg)
|
||||
{
|
||||
QString strMsg = QString::fromLatin1(msg);
|
||||
|
||||
if (!QCoreApplication::closingDown()) {
|
||||
if (!logger.isNull()) {
|
||||
if (recursiveLock.testAndSetOrdered(0, 1)) {
|
||||
QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
|
||||
recursiveLock = 0;
|
||||
}
|
||||
} else {
|
||||
warnings += strMsg;
|
||||
warnings += QLatin1Char('\n');
|
||||
}
|
||||
}
|
||||
if (systemMsgOutput) { // Windows
|
||||
systemMsgOutput(type, msg);
|
||||
} else { // Unix
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
static QDeclarativeViewer* globalViewer = 0;
|
||||
|
||||
// The qml file that is shown if the user didn't specify a QML file
|
||||
QString initialFile = "qrc:/startup/startup.qml";
|
||||
|
||||
void usage()
|
||||
{
|
||||
qWarning("Usage: qmlobserver [options] <filename>");
|
||||
qWarning(" ");
|
||||
qWarning(" options:");
|
||||
qWarning(" -v, -version ............................. display version");
|
||||
qWarning(" -frameless ............................... run with no window frame");
|
||||
qWarning(" -maximized................................ run maximized");
|
||||
qWarning(" -fullscreen............................... run fullscreen");
|
||||
qWarning(" -stayontop................................ keep viewer window on top");
|
||||
qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content");
|
||||
qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view (default)");
|
||||
qWarning(" -qmlbrowser .............................. use a QML-based file browser");
|
||||
qWarning(" -warnings [show|hide]..................... show warnings in a separate log window");
|
||||
#ifndef NO_PRIVATE_HEADERS
|
||||
qWarning(" -recordfile <output> ..................... set video recording file");
|
||||
qWarning(" - ImageMagick 'convert' for GIF)");
|
||||
qWarning(" - png file for raw frames");
|
||||
qWarning(" - 'ffmpeg' for other formats");
|
||||
qWarning(" -recorddither ordered|threshold|floyd .... set GIF dither recording mode");
|
||||
qWarning(" -recordrate <fps> ........................ set recording frame rate");
|
||||
qWarning(" -record arg .............................. add a recording process argument");
|
||||
qWarning(" -autorecord [from-]<tomilliseconds> ...... set recording to start and stop");
|
||||
#endif
|
||||
qWarning(" -devicekeys .............................. use numeric keys (see F1)");
|
||||
qWarning(" -dragthreshold <size> .................... set mouse drag threshold size");
|
||||
qWarning(" -netcache <size> ......................... set disk cache to size bytes");
|
||||
qWarning(" -translation <translationfile> ........... set the language to run in");
|
||||
qWarning(" -I <directory> ........................... prepend to the module import search path,");
|
||||
qWarning(" display path if <directory> is empty");
|
||||
qWarning(" -P <directory> ........................... prepend to the plugin search path");
|
||||
#if defined(Q_OS_MAC)
|
||||
qWarning(" -no-opengl ............................... don't use a QGLWidget for the viewport");
|
||||
#else
|
||||
qWarning(" -opengl .................................. use a QGLWidget for the viewport");
|
||||
#endif
|
||||
#ifndef NO_PRIVATE_HEADERS
|
||||
qWarning(" -script <path> ........................... set the script to use");
|
||||
qWarning(" -scriptopts <options>|help ............... set the script options to use");
|
||||
#endif
|
||||
|
||||
qWarning(" ");
|
||||
qWarning(" Press F1 for interactive help");
|
||||
|
||||
exitApp(1);
|
||||
}
|
||||
|
||||
void scriptOptsUsage()
|
||||
{
|
||||
qWarning("Usage: qmlobserver -scriptopts <option>[,<option>...] ...");
|
||||
qWarning(" options:");
|
||||
qWarning(" record ................................... record a new script");
|
||||
qWarning(" play ..................................... playback an existing script");
|
||||
qWarning(" testimages ............................... record images or compare images on playback");
|
||||
qWarning(" testerror ................................ test 'error' property of root item on playback");
|
||||
qWarning(" testskip ................................ test 'skip' property of root item on playback");
|
||||
qWarning(" snapshot ................................. file being recorded is static,");
|
||||
qWarning(" only one frame will be recorded or tested");
|
||||
qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion");
|
||||
qWarning(" exitonfailure ............................ immediately exit the viewer on script failure");
|
||||
qWarning(" saveonexit ............................... save recording on viewer exit");
|
||||
qWarning(" ");
|
||||
qWarning(" One of record, play or both must be specified.");
|
||||
|
||||
exitApp(1);
|
||||
}
|
||||
|
||||
enum WarningsConfig { ShowWarnings, HideWarnings, DefaultWarnings };
|
||||
|
||||
struct ViewerOptions
|
||||
{
|
||||
ViewerOptions()
|
||||
: frameless(false),
|
||||
fps(0.0),
|
||||
autorecord_from(0),
|
||||
autorecord_to(0),
|
||||
dither("none"),
|
||||
runScript(false),
|
||||
devkeys(false),
|
||||
cache(0),
|
||||
useGL(false),
|
||||
fullScreen(false),
|
||||
stayOnTop(false),
|
||||
maximized(false),
|
||||
useNativeFileBrowser(true),
|
||||
experimentalGestures(false),
|
||||
warningsConfig(DefaultWarnings),
|
||||
sizeToView(true)
|
||||
{
|
||||
#if defined(Q_OS_MAC)
|
||||
useGL = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool frameless;
|
||||
double fps;
|
||||
int autorecord_from;
|
||||
int autorecord_to;
|
||||
QString dither;
|
||||
QString recordfile;
|
||||
QStringList recordargs;
|
||||
QStringList imports;
|
||||
QStringList plugins;
|
||||
QString script;
|
||||
QString scriptopts;
|
||||
bool runScript;
|
||||
bool devkeys;
|
||||
int cache;
|
||||
QString translationFile;
|
||||
bool useGL;
|
||||
bool fullScreen;
|
||||
bool stayOnTop;
|
||||
bool maximized;
|
||||
bool useNativeFileBrowser;
|
||||
bool experimentalGestures;
|
||||
|
||||
WarningsConfig warningsConfig;
|
||||
bool sizeToView;
|
||||
|
||||
QDeclarativeViewer::ScriptOptions scriptOptions;
|
||||
};
|
||||
|
||||
static ViewerOptions opts;
|
||||
static QStringList fileNames;
|
||||
|
||||
class Application : public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Application(int &argc, char **&argv)
|
||||
: QApplication(argc, argv)
|
||||
{}
|
||||
|
||||
protected:
|
||||
bool event(QEvent *ev)
|
||||
{
|
||||
if (ev->type() != QEvent::FileOpen)
|
||||
return QApplication::event(ev);
|
||||
|
||||
QFileOpenEvent *fev = static_cast<QFileOpenEvent *>(ev);
|
||||
|
||||
globalViewer->open(fev->file());
|
||||
if (!globalViewer->isVisible())
|
||||
showViewer(globalViewer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void showInitialViewer()
|
||||
{
|
||||
QApplication::processEvents();
|
||||
|
||||
QDeclarativeViewer *viewer = globalViewer;
|
||||
if (!viewer)
|
||||
return;
|
||||
if (viewer->currentFile().isEmpty()) {
|
||||
if(opts.useNativeFileBrowser)
|
||||
viewer->open(initialFile);
|
||||
else
|
||||
viewer->openFile();
|
||||
}
|
||||
if (!viewer->isVisible())
|
||||
showViewer(viewer);
|
||||
}
|
||||
};
|
||||
|
||||
static void parseScriptOptions()
|
||||
{
|
||||
QStringList options =
|
||||
opts.scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts);
|
||||
|
||||
QDeclarativeViewer::ScriptOptions scriptOptions = 0;
|
||||
for (int i = 0; i < options.count(); ++i) {
|
||||
const QString &option = options.at(i);
|
||||
if (option == QLatin1String("help")) {
|
||||
scriptOptsUsage();
|
||||
} else if (option == QLatin1String("play")) {
|
||||
scriptOptions |= QDeclarativeViewer::Play;
|
||||
} else if (option == QLatin1String("record")) {
|
||||
scriptOptions |= QDeclarativeViewer::Record;
|
||||
} else if (option == QLatin1String("testimages")) {
|
||||
scriptOptions |= QDeclarativeViewer::TestImages;
|
||||
} else if (option == QLatin1String("testerror")) {
|
||||
scriptOptions |= QDeclarativeViewer::TestErrorProperty;
|
||||
} else if (option == QLatin1String("testskip")) {
|
||||
scriptOptions |= QDeclarativeViewer::TestSkipProperty;
|
||||
} else if (option == QLatin1String("exitoncomplete")) {
|
||||
scriptOptions |= QDeclarativeViewer::ExitOnComplete;
|
||||
} else if (option == QLatin1String("exitonfailure")) {
|
||||
scriptOptions |= QDeclarativeViewer::ExitOnFailure;
|
||||
} else if (option == QLatin1String("saveonexit")) {
|
||||
scriptOptions |= QDeclarativeViewer::SaveOnExit;
|
||||
} else if (option == QLatin1String("snapshot")) {
|
||||
scriptOptions |= QDeclarativeViewer::Snapshot;
|
||||
} else {
|
||||
scriptOptsUsage();
|
||||
}
|
||||
}
|
||||
|
||||
opts.scriptOptions = scriptOptions;
|
||||
}
|
||||
|
||||
static void parseCommandLineOptions(const QStringList &arguments)
|
||||
{
|
||||
for (int i = 1; i < arguments.count(); ++i) {
|
||||
bool lastArg = (i == arguments.count() - 1);
|
||||
QString arg = arguments.at(i);
|
||||
if (arg == "-frameless") {
|
||||
opts.frameless = true;
|
||||
} else if (arg == "-maximized") {
|
||||
opts.maximized = true;
|
||||
} else if (arg == "-fullscreen") {
|
||||
opts.fullScreen = true;
|
||||
} else if (arg == "-stayontop") {
|
||||
opts.stayOnTop = true;
|
||||
} else if (arg == "-netcache") {
|
||||
if (lastArg) usage();
|
||||
opts.cache = arguments.at(++i).toInt();
|
||||
} else if (arg == "-recordrate") {
|
||||
if (lastArg) usage();
|
||||
opts.fps = arguments.at(++i).toDouble();
|
||||
} else if (arg == "-recordfile") {
|
||||
if (lastArg) usage();
|
||||
opts.recordfile = arguments.at(++i);
|
||||
} else if (arg == "-record") {
|
||||
if (lastArg) usage();
|
||||
opts.recordargs << arguments.at(++i);
|
||||
} else if (arg == "-recorddither") {
|
||||
if (lastArg) usage();
|
||||
opts.dither = arguments.at(++i);
|
||||
} else if (arg == "-autorecord") {
|
||||
if (lastArg) usage();
|
||||
QString range = arguments.at(++i);
|
||||
int dash = range.indexOf('-');
|
||||
if (dash > 0)
|
||||
opts.autorecord_from = range.left(dash).toInt();
|
||||
opts.autorecord_to = range.mid(dash+1).toInt();
|
||||
} else if (arg == "-devicekeys") {
|
||||
opts.devkeys = true;
|
||||
} else if (arg == "-dragthreshold") {
|
||||
if (lastArg) usage();
|
||||
qApp->setStartDragDistance(arguments.at(++i).toInt());
|
||||
} else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
|
||||
qWarning("Qt QML Viewer version %s", qVersion());
|
||||
exitApp(0);
|
||||
} else if (arg == "-translation") {
|
||||
if (lastArg) usage();
|
||||
opts.translationFile = arguments.at(++i);
|
||||
#if defined(Q_OS_MAC)
|
||||
} else if (arg == "-no-opengl") {
|
||||
opts.useGL = false;
|
||||
#else
|
||||
} else if (arg == "-opengl") {
|
||||
opts.useGL = true;
|
||||
#endif
|
||||
} else if (arg == "-qmlbrowser") {
|
||||
opts.useNativeFileBrowser = false;
|
||||
} else if (arg == "-warnings") {
|
||||
if (lastArg) usage();
|
||||
QString warningsStr = arguments.at(++i);
|
||||
if (warningsStr == QLatin1String("show")) {
|
||||
opts.warningsConfig = ShowWarnings;
|
||||
} else if (warningsStr == QLatin1String("hide")) {
|
||||
opts.warningsConfig = HideWarnings;
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
} else if (arg == "-I" || arg == "-L") {
|
||||
if (arg == "-L")
|
||||
qWarning("-L option provided for compatibility only, use -I instead");
|
||||
if (lastArg) {
|
||||
QDeclarativeEngine tmpEngine;
|
||||
QString paths = tmpEngine.importPathList().join(QLatin1String(":"));
|
||||
qWarning("Current search path: %s", paths.toLocal8Bit().constData());
|
||||
exitApp(0);
|
||||
}
|
||||
opts.imports << arguments.at(++i);
|
||||
} else if (arg == "-P") {
|
||||
if (lastArg) usage();
|
||||
opts.plugins << arguments.at(++i);
|
||||
} else if (arg == "-script") {
|
||||
if (lastArg) usage();
|
||||
opts.script = arguments.at(++i);
|
||||
} else if (arg == "-scriptopts") {
|
||||
if (lastArg) usage();
|
||||
opts.scriptopts = arguments.at(++i);
|
||||
} else if (arg == "-savescript") {
|
||||
if (lastArg) usage();
|
||||
opts.script = arguments.at(++i);
|
||||
opts.runScript = false;
|
||||
} else if (arg == "-playscript") {
|
||||
if (lastArg) usage();
|
||||
opts.script = arguments.at(++i);
|
||||
opts.runScript = true;
|
||||
} else if (arg == "-sizeviewtorootobject") {
|
||||
opts.sizeToView = false;
|
||||
} else if (arg == "-sizerootobjecttoview") {
|
||||
opts.sizeToView = true;
|
||||
} else if (arg == "-experimentalgestures") {
|
||||
opts.experimentalGestures = true;
|
||||
} else if (!arg.startsWith('-')) {
|
||||
fileNames.append(arg);
|
||||
} else if (true || arg == "-help") {
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (!opts.scriptopts.isEmpty()) {
|
||||
|
||||
parseScriptOptions();
|
||||
|
||||
if (opts.script.isEmpty())
|
||||
usage();
|
||||
|
||||
if (!(opts.scriptOptions & QDeclarativeViewer::Record) && !(opts.scriptOptions & QDeclarativeViewer::Play))
|
||||
scriptOptsUsage();
|
||||
} else if (!opts.script.isEmpty()) {
|
||||
usage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static QDeclarativeViewer *createViewer()
|
||||
{
|
||||
Qt::WFlags wflags = (opts.frameless ? Qt::FramelessWindowHint : Qt::Widget);
|
||||
if (opts.stayOnTop)
|
||||
wflags |= Qt::WindowStaysOnTopHint;
|
||||
|
||||
QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags);
|
||||
viewer->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
viewer->setUseGL(opts.useGL);
|
||||
|
||||
if (!opts.scriptopts.isEmpty()) {
|
||||
viewer->setScriptOptions(opts.scriptOptions);
|
||||
viewer->setScript(opts.script);
|
||||
}
|
||||
|
||||
logger = viewer->warningsWidget();
|
||||
if (opts.warningsConfig == ShowWarnings) {
|
||||
logger.data()->setDefaultVisibility(LoggerWidget::ShowWarnings);
|
||||
logger.data()->show();
|
||||
} else if (opts.warningsConfig == HideWarnings){
|
||||
logger.data()->setDefaultVisibility(LoggerWidget::HideWarnings);
|
||||
}
|
||||
|
||||
if (opts.experimentalGestures)
|
||||
viewer->enableExperimentalGestures();
|
||||
|
||||
foreach (const QString &lib, opts.imports)
|
||||
viewer->addLibraryPath(lib);
|
||||
|
||||
foreach (const QString &plugin, opts.plugins)
|
||||
viewer->addPluginPath(plugin);
|
||||
|
||||
viewer->setNetworkCacheSize(opts.cache);
|
||||
viewer->setRecordFile(opts.recordfile);
|
||||
viewer->setSizeToView(opts.sizeToView);
|
||||
if (opts.fps > 0)
|
||||
viewer->setRecordRate(opts.fps);
|
||||
if (opts.autorecord_to)
|
||||
viewer->setAutoRecord(opts.autorecord_from, opts.autorecord_to);
|
||||
if (opts.devkeys)
|
||||
viewer->setDeviceKeys(true);
|
||||
viewer->setRecordDither(opts.dither);
|
||||
if (opts.recordargs.count())
|
||||
viewer->setRecordArgs(opts.recordargs);
|
||||
|
||||
viewer->setUseNativeFileBrowser(opts.useNativeFileBrowser);
|
||||
|
||||
return viewer;
|
||||
}
|
||||
|
||||
void showViewer(QDeclarativeViewer *viewer)
|
||||
{
|
||||
if (opts.fullScreen)
|
||||
viewer->showFullScreen();
|
||||
else if (opts.maximized)
|
||||
viewer->showMaximized();
|
||||
else
|
||||
viewer->show();
|
||||
viewer->raise();
|
||||
}
|
||||
|
||||
QDeclarativeViewer *openFile(const QString &fileName)
|
||||
{
|
||||
QDeclarativeViewer *viewer = globalViewer;
|
||||
|
||||
viewer->open(fileName);
|
||||
showViewer(viewer);
|
||||
|
||||
return viewer;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
systemMsgOutput = qInstallMsgHandler(myMessageOutput);
|
||||
|
||||
#if defined (Q_WS_X11) || defined (Q_OS_MAC)
|
||||
//### default to using raster graphics backend for now
|
||||
bool gsSpecified = false;
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
QString arg = argv[i];
|
||||
if (arg == "-graphicssystem") {
|
||||
gsSpecified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gsSpecified)
|
||||
QApplication::setGraphicsSystem("raster");
|
||||
#endif
|
||||
|
||||
Application app(argc, argv);
|
||||
app.setApplicationName("QtQmlViewer");
|
||||
app.setOrganizationName("QtProject");
|
||||
app.setOrganizationDomain("qt-project.org");
|
||||
|
||||
QDeclarativeViewer::registerTypes();
|
||||
QDeclarativeTester::registerTypes();
|
||||
|
||||
parseCommandLineOptions(app.arguments());
|
||||
|
||||
QTranslator qmlTranslator;
|
||||
if (!opts.translationFile.isEmpty()) {
|
||||
qmlTranslator.load(opts.translationFile);
|
||||
app.installTranslator(&qmlTranslator);
|
||||
}
|
||||
|
||||
if (opts.fullScreen && opts.maximized)
|
||||
qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen.";
|
||||
|
||||
if (fileNames.isEmpty()) {
|
||||
QFile qmlapp(QLatin1String("qmlapp"));
|
||||
if (qmlapp.exists() && qmlapp.open(QFile::ReadOnly)) {
|
||||
QString content = QString::fromUtf8(qmlapp.readAll());
|
||||
qmlapp.close();
|
||||
|
||||
int newline = content.indexOf(QLatin1Char('\n'));
|
||||
if (newline >= 0)
|
||||
fileNames += content.left(newline);
|
||||
else
|
||||
fileNames += content;
|
||||
}
|
||||
}
|
||||
|
||||
//enable remote debugging
|
||||
QDeclarativeDebugHelper::enableDebugging();
|
||||
|
||||
globalViewer = createViewer();
|
||||
|
||||
if (fileNames.isEmpty()) {
|
||||
// show the initial viewer delayed.
|
||||
// This prevents an initial viewer popping up while there
|
||||
// are FileOpen events coming through the event queue
|
||||
QTimer::singleShot(1, &app, SLOT(showInitialViewer()));
|
||||
} else {
|
||||
foreach (const QString &fileName, fileNames)
|
||||
openFile(fileName);
|
||||
}
|
||||
|
||||
QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
||||
@@ -1,99 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QIntValidator>
|
||||
#include <QSettings>
|
||||
|
||||
#include "proxysettings.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
ProxySettings::ProxySettings (QWidget * parent)
|
||||
: QDialog (parent), Ui::ProxySettings()
|
||||
{
|
||||
setupUi (this);
|
||||
|
||||
#if !defined Q_WS_MAEMO_5
|
||||
// the onscreen keyboard can't cope with masks
|
||||
proxyServerEdit->setInputMask ("000.000.000.000;_");
|
||||
#endif
|
||||
QIntValidator *validator = new QIntValidator (0, 9999, this);
|
||||
proxyPortEdit->setValidator (validator);
|
||||
|
||||
QSettings settings;
|
||||
proxyCheckBox->setChecked (settings.value ("http_proxy/use", 0).toBool ());
|
||||
proxyServerEdit->insert (settings.value ("http_proxy/hostname", "").toString ());
|
||||
proxyPortEdit->insert (settings.value ("http_proxy/port", "80").toString ());
|
||||
usernameEdit->insert (settings.value ("http_proxy/username", "").toString ());
|
||||
passwordEdit->insert (settings.value ("http_proxy/password", "").toString ());
|
||||
}
|
||||
|
||||
ProxySettings::~ProxySettings()
|
||||
{
|
||||
}
|
||||
|
||||
void ProxySettings::accept ()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
settings.setValue ("http_proxy/use", proxyCheckBox->isChecked ());
|
||||
settings.setValue ("http_proxy/hostname", proxyServerEdit->text ());
|
||||
settings.setValue ("http_proxy/port", proxyPortEdit->text ());
|
||||
settings.setValue ("http_proxy/username", usernameEdit->text ());
|
||||
settings.setValue ("http_proxy/password", passwordEdit->text ());
|
||||
|
||||
QDialog::accept ();
|
||||
}
|
||||
|
||||
QNetworkProxy ProxySettings::httpProxy ()
|
||||
{
|
||||
QSettings settings;
|
||||
QNetworkProxy proxy;
|
||||
|
||||
bool proxyInUse = settings.value ("http_proxy/use", 0).toBool ();
|
||||
if (proxyInUse) {
|
||||
proxy.setType (QNetworkProxy::HttpProxy);
|
||||
proxy.setHostName (settings.value ("http_proxy/hostname", "").toString ());// "192.168.220.5"
|
||||
proxy.setPort (settings.value ("http_proxy/port", 80).toInt ()); // 8080
|
||||
proxy.setUser (settings.value ("http_proxy/username", "").toString ());
|
||||
proxy.setPassword (settings.value ("http_proxy/password", "").toString ());
|
||||
//QNetworkProxy::setApplicationProxy (proxy);
|
||||
} else {
|
||||
proxy.setType (QNetworkProxy::NoProxy);
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
bool ProxySettings::httpProxyInUse()
|
||||
{
|
||||
QSettings settings;
|
||||
return settings.value ("http_proxy/use", 0).toBool ();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
@@ -1,63 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef PROXYSETTINGS_H
|
||||
#define PROXYSETTINGS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QNetworkProxy>
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
#include "ui_proxysettings_maemo5.h"
|
||||
#else
|
||||
#include "ui_proxysettings.h"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
/**
|
||||
*/
|
||||
class ProxySettings : public QDialog, public Ui::ProxySettings
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ProxySettings(QWidget * parent = 0);
|
||||
|
||||
~ProxySettings();
|
||||
|
||||
static QNetworkProxy httpProxy ();
|
||||
static bool httpProxyInUse ();
|
||||
|
||||
public slots:
|
||||
virtual void accept ();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // PROXYSETTINGS_H
|
||||
@@ -1,115 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ProxySettings</class>
|
||||
<widget class="QDialog" name="ProxySettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>318</width>
|
||||
<height>199</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="proxyCheckBox">
|
||||
<property name="text">
|
||||
<string>Use http proxy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="serverAddressLabel">
|
||||
<property name="text">
|
||||
<string>Server Address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="proxyServerEdit"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="proxyPortEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="usernameLabel">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="usernameEdit"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="passwordEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ProxySettings</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ProxySettings</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -1,177 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ProxySettings</class>
|
||||
<widget class="QDialog" name="ProxySettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>449</width>
|
||||
<height>164</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>HTTP Proxy</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="proxyCheckBox">
|
||||
<property name="text">
|
||||
<string>Use HTTP Proxy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="2">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="serverAddressLabel">
|
||||
<property name="text">
|
||||
<string>Server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="proxyServerEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Name or IP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="proxyPortEdit">
|
||||
<property name="text">
|
||||
<string>8080</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="usernameLabel">
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="usernameEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="passwordEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>proxyCheckBox</tabstop>
|
||||
<tabstop>proxyServerEdit</tabstop>
|
||||
<tabstop>proxyPortEdit</tabstop>
|
||||
<tabstop>usernameEdit</tabstop>
|
||||
<tabstop>passwordEdit</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ProxySettings</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>318</x>
|
||||
<y>100</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>116</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ProxySettings</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>318</x>
|
||||
<y>100</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>116</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -1,445 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qdeclarativetester.h>
|
||||
#include <qdeclarativeview.h>
|
||||
#include <QDeclarativeComponent>
|
||||
#include <QGraphicsObject>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
#ifndef NO_PRIVATE_HEADERS
|
||||
#include <private/qabstractanimation_p.h>
|
||||
#include <private/qdeclarativeitem_p.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled;
|
||||
|
||||
QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions opts,
|
||||
QDeclarativeView *parent)
|
||||
: QAbstractAnimation(parent), m_script(script), m_view(parent), filterEvents(true), options(opts),
|
||||
testscript(0), hasCompleted(false), hasFailed(false)
|
||||
{
|
||||
parent->viewport()->installEventFilter(this);
|
||||
parent->installEventFilter(this);
|
||||
#ifndef NO_PRIVATE_HEADERS
|
||||
QUnifiedTimer::instance()->setConsistentTiming(true);
|
||||
#endif
|
||||
|
||||
//Font antialiasing makes tests system-specific, so disable it
|
||||
QFont noAA = QApplication::font();
|
||||
noAA.setStyleStrategy(QFont::NoAntialias);
|
||||
QApplication::setFont(noAA);
|
||||
|
||||
if (options & QDeclarativeViewer::Play)
|
||||
this->run();
|
||||
start();
|
||||
}
|
||||
|
||||
QDeclarativeTester::~QDeclarativeTester()
|
||||
{
|
||||
if (!hasFailed &&
|
||||
options & QDeclarativeViewer::Record &&
|
||||
options & QDeclarativeViewer::SaveOnExit)
|
||||
save();
|
||||
}
|
||||
|
||||
int QDeclarativeTester::duration() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void QDeclarativeTester::addMouseEvent(Destination dest, QMouseEvent *me)
|
||||
{
|
||||
MouseEvent e(me);
|
||||
e.destination = dest;
|
||||
m_mouseEvents << e;
|
||||
}
|
||||
|
||||
void QDeclarativeTester::addKeyEvent(Destination dest, QKeyEvent *ke)
|
||||
{
|
||||
KeyEvent e(ke);
|
||||
e.destination = dest;
|
||||
m_keyEvents << e;
|
||||
}
|
||||
|
||||
bool QDeclarativeTester::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
if (!filterEvents)
|
||||
return false;
|
||||
|
||||
Destination destination;
|
||||
if (o == m_view) {
|
||||
destination = View;
|
||||
} else if (o == m_view->viewport()) {
|
||||
destination = ViewPort;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (e->type()) {
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyRelease:
|
||||
addKeyEvent(destination, (QKeyEvent *)e);
|
||||
return true;
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseMove:
|
||||
case QEvent::MouseButtonDblClick:
|
||||
addMouseEvent(destination, (QMouseEvent *)e);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QDeclarativeTester::executefailure()
|
||||
{
|
||||
hasFailed = true;
|
||||
|
||||
if (options & QDeclarativeViewer::ExitOnFailure)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void QDeclarativeTester::imagefailure()
|
||||
{
|
||||
hasFailed = true;
|
||||
|
||||
if (options & QDeclarativeViewer::ExitOnFailure){
|
||||
testSkip();
|
||||
exit(hasFailed?-1:0);
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeTester::testSkip()
|
||||
{
|
||||
if (options & QDeclarativeViewer::TestSkipProperty){
|
||||
QString e = m_view->rootObject()->property("skip").toString();
|
||||
if (!e.isEmpty()) {
|
||||
if(hasFailed){
|
||||
qWarning() << "Test failed, but skipping it: " << e;
|
||||
}else{
|
||||
qWarning() << "Test skipped: " << e;
|
||||
}
|
||||
hasFailed = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeTester::complete()
|
||||
{
|
||||
if ((options & QDeclarativeViewer::TestErrorProperty) && !hasFailed) {
|
||||
QString e = m_view->rootObject()->property("error").toString();
|
||||
if (!e.isEmpty()) {
|
||||
qWarning() << "Test failed:" << e;
|
||||
hasFailed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
testSkip();
|
||||
if (options & QDeclarativeViewer::ExitOnComplete)
|
||||
QApplication::exit(hasFailed?-1:0);
|
||||
|
||||
if (hasCompleted)
|
||||
return;
|
||||
hasCompleted = true;
|
||||
|
||||
if (options & QDeclarativeViewer::Play)
|
||||
qWarning("Script playback complete");
|
||||
}
|
||||
|
||||
void QDeclarativeTester::run()
|
||||
{
|
||||
QDeclarativeComponent c(m_view->engine(), m_script + QLatin1String(".qml"));
|
||||
|
||||
testscript = qobject_cast<QDeclarativeVisualTest *>(c.create());
|
||||
if (testscript) testscript->setParent(this);
|
||||
else { executefailure(); exit(-1); }
|
||||
testscriptidx = 0;
|
||||
}
|
||||
|
||||
void QDeclarativeTester::save()
|
||||
{
|
||||
QString filename = m_script + QLatin1String(".qml");
|
||||
QFileInfo filenameInfo(filename);
|
||||
QDir saveDir = filenameInfo.absoluteDir();
|
||||
saveDir.mkpath(".");
|
||||
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
QTextStream ts(&file);
|
||||
|
||||
ts << "import Qt.VisualTest 4.7\n\n";
|
||||
ts << "VisualTest {\n";
|
||||
|
||||
int imgCount = 0;
|
||||
QList<KeyEvent> keyevents = m_savedKeyEvents;
|
||||
QList<MouseEvent> mouseevents = m_savedMouseEvents;
|
||||
for (int ii = 0; ii < m_savedFrameEvents.count(); ++ii) {
|
||||
const FrameEvent &fe = m_savedFrameEvents.at(ii);
|
||||
ts << " Frame {\n";
|
||||
ts << " msec: " << fe.msec << "\n";
|
||||
if (!fe.hash.isEmpty()) {
|
||||
ts << " hash: \"" << fe.hash.toHex() << "\"\n";
|
||||
} else if (!fe.image.isNull()) {
|
||||
QString filename = filenameInfo.baseName() + QLatin1Char('.')
|
||||
+ QString::number(imgCount) + ".png";
|
||||
fe.image.save(m_script + QLatin1Char('.') + QString::number(imgCount) + ".png");
|
||||
imgCount++;
|
||||
ts << " image: \"" << filename << "\"\n";
|
||||
}
|
||||
ts << " }\n";
|
||||
|
||||
while (!mouseevents.isEmpty() &&
|
||||
mouseevents.first().msec == fe.msec) {
|
||||
MouseEvent me = mouseevents.takeFirst();
|
||||
|
||||
ts << " Mouse {\n";
|
||||
ts << " type: " << me.type << "\n";
|
||||
ts << " button: " << me.button << "\n";
|
||||
ts << " buttons: " << me.buttons << "\n";
|
||||
ts << " x: " << me.pos.x() << "; y: " << me.pos.y() << "\n";
|
||||
ts << " modifiers: " << me.modifiers << "\n";
|
||||
if (me.destination == ViewPort)
|
||||
ts << " sendToViewport: true\n";
|
||||
ts << " }\n";
|
||||
}
|
||||
|
||||
while (!keyevents.isEmpty() &&
|
||||
keyevents.first().msec == fe.msec) {
|
||||
KeyEvent ke = keyevents.takeFirst();
|
||||
|
||||
ts << " Key {\n";
|
||||
ts << " type: " << ke.type << "\n";
|
||||
ts << " key: " << ke.key << "\n";
|
||||
ts << " modifiers: " << ke.modifiers << "\n";
|
||||
ts << " text: \"" << ke.text.toUtf8().toHex() << "\"\n";
|
||||
ts << " autorep: " << (ke.autorep?"true":"false") << "\n";
|
||||
ts << " count: " << ke.count << "\n";
|
||||
if (ke.destination == ViewPort)
|
||||
ts << " sendToViewport: true\n";
|
||||
ts << " }\n";
|
||||
}
|
||||
}
|
||||
|
||||
ts << "}\n";
|
||||
file.close();
|
||||
}
|
||||
|
||||
void QDeclarativeTester::updateCurrentTime(int msec)
|
||||
{
|
||||
#ifndef NO_PRIVATE_HEADERS
|
||||
QDeclarativeItemPrivate::setConsistentTime(msec);
|
||||
#endif
|
||||
if (!testscript && msec > 16 && options & QDeclarativeViewer::Snapshot)
|
||||
return;
|
||||
|
||||
QImage img(m_view->width(), m_view->height(), QImage::Format_RGB32);
|
||||
|
||||
if (options & QDeclarativeViewer::TestImages) {
|
||||
img.fill(qRgb(255,255,255));
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
bool oldSmooth = qt_applefontsmoothing_enabled;
|
||||
qt_applefontsmoothing_enabled = false;
|
||||
#endif
|
||||
QPainter p(&img);
|
||||
#ifdef Q_OS_MAC
|
||||
qt_applefontsmoothing_enabled = oldSmooth;
|
||||
#endif
|
||||
|
||||
m_view->render(&p);
|
||||
}
|
||||
|
||||
bool snapshot = msec == 16 && (options & QDeclarativeViewer::Snapshot
|
||||
|| (testscript && testscript->count() == 2));
|
||||
|
||||
FrameEvent fe;
|
||||
fe.msec = msec;
|
||||
if (msec == 0 || !(options & QDeclarativeViewer::TestImages)) {
|
||||
// Skip first frame, skip if not doing images
|
||||
} else if (0 == ((m_savedFrameEvents.count()-1) % 60) || snapshot) {
|
||||
fe.image = img;
|
||||
} else {
|
||||
QCryptographicHash hash(QCryptographicHash::Md5);
|
||||
hash.addData((const char *)img.bits(), img.bytesPerLine() * img.height());
|
||||
fe.hash = hash.result();
|
||||
}
|
||||
m_savedFrameEvents.append(fe);
|
||||
|
||||
// Deliver mouse events
|
||||
filterEvents = false;
|
||||
|
||||
if (!testscript) {
|
||||
for (int ii = 0; ii < m_mouseEvents.count(); ++ii) {
|
||||
MouseEvent &me = m_mouseEvents[ii];
|
||||
me.msec = msec;
|
||||
QMouseEvent event(me.type, me.pos, me.button, me.buttons, me.modifiers);
|
||||
|
||||
if (me.destination == View) {
|
||||
QCoreApplication::sendEvent(m_view, &event);
|
||||
} else {
|
||||
QCoreApplication::sendEvent(m_view->viewport(), &event);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ii = 0; ii < m_keyEvents.count(); ++ii) {
|
||||
KeyEvent &ke = m_keyEvents[ii];
|
||||
ke.msec = msec;
|
||||
QKeyEvent event(ke.type, ke.key, ke.modifiers, ke.text, ke.autorep, ke.count);
|
||||
|
||||
if (ke.destination == View) {
|
||||
QCoreApplication::sendEvent(m_view, &event);
|
||||
} else {
|
||||
QCoreApplication::sendEvent(m_view->viewport(), &event);
|
||||
}
|
||||
}
|
||||
m_savedMouseEvents.append(m_mouseEvents);
|
||||
m_savedKeyEvents.append(m_keyEvents);
|
||||
}
|
||||
|
||||
m_mouseEvents.clear();
|
||||
m_keyEvents.clear();
|
||||
|
||||
// Advance test script
|
||||
while (testscript && testscript->count() > testscriptidx) {
|
||||
|
||||
QObject *event = testscript->event(testscriptidx);
|
||||
|
||||
if (QDeclarativeVisualTestFrame *frame = qobject_cast<QDeclarativeVisualTestFrame *>(event)) {
|
||||
if (frame->msec() < msec) {
|
||||
if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) {
|
||||
qWarning() << "QDeclarativeTester(" << m_script << "): Extra frame. Seen:"
|
||||
<< msec << "Expected:" << frame->msec();
|
||||
imagefailure();
|
||||
}
|
||||
} else if (frame->msec() == msec) {
|
||||
if (!frame->hash().isEmpty() && frame->hash().toUtf8() != fe.hash.toHex()) {
|
||||
if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) {
|
||||
qWarning() << "QDeclarativeTester(" << m_script << "): Mismatched frame hash at" << msec
|
||||
<< ". Seen:" << fe.hash.toHex()
|
||||
<< "Expected:" << frame->hash().toUtf8();
|
||||
imagefailure();
|
||||
}
|
||||
}
|
||||
} else if (frame->msec() > msec) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record) && !frame->image().isEmpty()) {
|
||||
QImage goodImage(frame->image().toLocalFile());
|
||||
if (frame->msec() == 16 && goodImage.size() != img.size()){
|
||||
//Also an image mismatch, but this warning is more informative. Only checked at start though.
|
||||
qWarning() << "QDeclarativeTester(" << m_script << "): Size mismatch. This test must be run at " << goodImage.size();
|
||||
imagefailure();
|
||||
}
|
||||
if (goodImage != img) {
|
||||
QString reject(frame->image().toLocalFile() + ".reject.png");
|
||||
qWarning() << "QDeclarativeTester(" << m_script << "): Image mismatch. Reject saved to:"
|
||||
<< reject;
|
||||
img.save(reject);
|
||||
bool doDiff = (goodImage.size() == img.size());
|
||||
if (doDiff) {
|
||||
QImage diffimg(m_view->width(), m_view->height(), QImage::Format_RGB32);
|
||||
diffimg.fill(qRgb(255,255,255));
|
||||
QPainter p(&diffimg);
|
||||
int diffCount = 0;
|
||||
for (int x = 0; x < img.width(); ++x) {
|
||||
for (int y = 0; y < img.height(); ++y) {
|
||||
if (goodImage.pixel(x,y) != img.pixel(x,y)) {
|
||||
++diffCount;
|
||||
p.drawPoint(x,y);
|
||||
}
|
||||
}
|
||||
}
|
||||
QString diff(frame->image().toLocalFile() + ".diff.png");
|
||||
diffimg.save(diff);
|
||||
qWarning().nospace() << " Diff (" << diffCount << " pixels differed) saved to: " << diff;
|
||||
}
|
||||
imagefailure();
|
||||
}
|
||||
}
|
||||
} else if (QDeclarativeVisualTestMouse *mouse = qobject_cast<QDeclarativeVisualTestMouse *>(event)) {
|
||||
QPoint pos(mouse->x(), mouse->y());
|
||||
QPoint globalPos = m_view->mapToGlobal(QPoint(0, 0)) + pos;
|
||||
QMouseEvent event((QEvent::Type)mouse->type(), pos, globalPos, (Qt::MouseButton)mouse->button(), (Qt::MouseButtons)mouse->buttons(), (Qt::KeyboardModifiers)mouse->modifiers());
|
||||
|
||||
MouseEvent me(&event);
|
||||
me.msec = msec;
|
||||
if (!mouse->sendToViewport()) {
|
||||
QCoreApplication::sendEvent(m_view, &event);
|
||||
me.destination = View;
|
||||
} else {
|
||||
QCoreApplication::sendEvent(m_view->viewport(), &event);
|
||||
me.destination = ViewPort;
|
||||
}
|
||||
m_savedMouseEvents.append(me);
|
||||
} else if (QDeclarativeVisualTestKey *key = qobject_cast<QDeclarativeVisualTestKey *>(event)) {
|
||||
|
||||
QKeyEvent event((QEvent::Type)key->type(), key->key(), (Qt::KeyboardModifiers)key->modifiers(), QString::fromUtf8(QByteArray::fromHex(key->text().toUtf8())), key->autorep(), key->count());
|
||||
|
||||
KeyEvent ke(&event);
|
||||
ke.msec = msec;
|
||||
if (!key->sendToViewport()) {
|
||||
QCoreApplication::sendEvent(m_view, &event);
|
||||
ke.destination = View;
|
||||
} else {
|
||||
QCoreApplication::sendEvent(m_view->viewport(), &event);
|
||||
ke.destination = ViewPort;
|
||||
}
|
||||
m_savedKeyEvents.append(ke);
|
||||
}
|
||||
testscriptidx++;
|
||||
}
|
||||
|
||||
filterEvents = true;
|
||||
|
||||
if (testscript && testscript->count() <= testscriptidx) {
|
||||
//if (msec == 16) //for a snapshot, leave it up long enough to see
|
||||
// (void)::sleep(1);
|
||||
complete();
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeTester::registerTypes()
|
||||
{
|
||||
qmlRegisterType<QDeclarativeVisualTest>("Qt.VisualTest", 4,7, "VisualTest");
|
||||
qmlRegisterType<QDeclarativeVisualTestFrame>("Qt.VisualTest", 4,7, "Frame");
|
||||
qmlRegisterType<QDeclarativeVisualTestMouse>("Qt.VisualTest", 4,7, "Mouse");
|
||||
qmlRegisterType<QDeclarativeVisualTestKey>("Qt.VisualTest", 4,7, "Key");
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
@@ -1,280 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVETESTER_H
|
||||
#define QDECLARATIVETESTER_H
|
||||
|
||||
#include <qmlruntime.h>
|
||||
|
||||
#include <qdeclarativelist.h>
|
||||
#include <qdeclarative.h>
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QImage>
|
||||
#include <QUrl>
|
||||
#include <QEvent>
|
||||
#include <QAbstractAnimation>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeclarativeVisualTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QDeclarativeListProperty<QObject> events READ events CONSTANT)
|
||||
Q_CLASSINFO("DefaultProperty", "events")
|
||||
public:
|
||||
QDeclarativeVisualTest() {}
|
||||
|
||||
QDeclarativeListProperty<QObject> events() { return QDeclarativeListProperty<QObject>(this, m_events); }
|
||||
|
||||
int count() const { return m_events.count(); }
|
||||
QObject *event(int idx) { return m_events.at(idx); }
|
||||
|
||||
private:
|
||||
QList<QObject *> m_events;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(QDeclarativeVisualTest)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeclarativeVisualTestFrame : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int msec READ msec WRITE setMsec)
|
||||
Q_PROPERTY(QString hash READ hash WRITE setHash)
|
||||
Q_PROPERTY(QUrl image READ image WRITE setImage)
|
||||
public:
|
||||
QDeclarativeVisualTestFrame() : m_msec(-1) {}
|
||||
|
||||
int msec() const { return m_msec; }
|
||||
void setMsec(int m) { m_msec = m; }
|
||||
|
||||
QString hash() const { return m_hash; }
|
||||
void setHash(const QString &hash) { m_hash = hash; }
|
||||
|
||||
QUrl image() const { return m_image; }
|
||||
void setImage(const QUrl &image) { m_image = image; }
|
||||
|
||||
private:
|
||||
int m_msec;
|
||||
QString m_hash;
|
||||
QUrl m_image;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(QDeclarativeVisualTestFrame)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeclarativeVisualTestMouse : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int type READ type WRITE setType)
|
||||
Q_PROPERTY(int button READ button WRITE setButton)
|
||||
Q_PROPERTY(int buttons READ buttons WRITE setButtons)
|
||||
Q_PROPERTY(int x READ x WRITE setX)
|
||||
Q_PROPERTY(int y READ y WRITE setY)
|
||||
Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers)
|
||||
Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport)
|
||||
public:
|
||||
QDeclarativeVisualTestMouse() : m_type(0), m_button(0), m_buttons(0), m_x(0), m_y(0), m_modifiers(0), m_viewport(false) {}
|
||||
|
||||
int type() const { return m_type; }
|
||||
void setType(int t) { m_type = t; }
|
||||
|
||||
int button() const { return m_button; }
|
||||
void setButton(int b) { m_button = b; }
|
||||
|
||||
int buttons() const { return m_buttons; }
|
||||
void setButtons(int b) { m_buttons = b; }
|
||||
|
||||
int x() const { return m_x; }
|
||||
void setX(int x) { m_x = x; }
|
||||
|
||||
int y() const { return m_y; }
|
||||
void setY(int y) { m_y = y; }
|
||||
|
||||
int modifiers() const { return m_modifiers; }
|
||||
void setModifiers(int modifiers) { m_modifiers = modifiers; }
|
||||
|
||||
bool sendToViewport() const { return m_viewport; }
|
||||
void setSendToViewport(bool v) { m_viewport = v; }
|
||||
private:
|
||||
int m_type;
|
||||
int m_button;
|
||||
int m_buttons;
|
||||
int m_x;
|
||||
int m_y;
|
||||
int m_modifiers;
|
||||
bool m_viewport;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(QDeclarativeVisualTestMouse)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeclarativeVisualTestKey : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int type READ type WRITE setType)
|
||||
Q_PROPERTY(int key READ key WRITE setKey)
|
||||
Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers)
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(bool autorep READ autorep WRITE setAutorep)
|
||||
Q_PROPERTY(int count READ count WRITE setCount)
|
||||
Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport)
|
||||
public:
|
||||
QDeclarativeVisualTestKey() : m_type(0), m_key(0), m_modifiers(0), m_autorep(false), m_count(0), m_viewport(false) {}
|
||||
|
||||
int type() const { return m_type; }
|
||||
void setType(int t) { m_type = t; }
|
||||
|
||||
int key() const { return m_key; }
|
||||
void setKey(int k) { m_key = k; }
|
||||
|
||||
int modifiers() const { return m_modifiers; }
|
||||
void setModifiers(int m) { m_modifiers = m; }
|
||||
|
||||
QString text() const { return m_text; }
|
||||
void setText(const QString &t) { m_text = t; }
|
||||
|
||||
bool autorep() const { return m_autorep; }
|
||||
void setAutorep(bool a) { m_autorep = a; }
|
||||
|
||||
int count() const { return m_count; }
|
||||
void setCount(int c) { m_count = c; }
|
||||
|
||||
bool sendToViewport() const { return m_viewport; }
|
||||
void setSendToViewport(bool v) { m_viewport = v; }
|
||||
private:
|
||||
int m_type;
|
||||
int m_key;
|
||||
int m_modifiers;
|
||||
QString m_text;
|
||||
bool m_autorep;
|
||||
int m_count;
|
||||
bool m_viewport;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(QDeclarativeVisualTestKey)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeclarativeTester : public QAbstractAnimation
|
||||
{
|
||||
public:
|
||||
QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions options, QDeclarativeView *parent);
|
||||
~QDeclarativeTester();
|
||||
|
||||
static void registerTypes();
|
||||
|
||||
virtual int duration() const;
|
||||
|
||||
void run();
|
||||
void save();
|
||||
|
||||
void executefailure();
|
||||
protected:
|
||||
virtual void updateCurrentTime(int msecs);
|
||||
virtual bool eventFilter(QObject *, QEvent *);
|
||||
|
||||
private:
|
||||
QString m_script;
|
||||
|
||||
void imagefailure();
|
||||
void complete();
|
||||
void testSkip();
|
||||
|
||||
enum Destination { View, ViewPort };
|
||||
void addKeyEvent(Destination, QKeyEvent *);
|
||||
void addMouseEvent(Destination, QMouseEvent *);
|
||||
QDeclarativeView *m_view;
|
||||
|
||||
struct MouseEvent {
|
||||
MouseEvent(QMouseEvent *e)
|
||||
: type(e->type()), button(e->button()), buttons(e->buttons()),
|
||||
pos(e->pos()), modifiers(e->modifiers()), destination(View) {}
|
||||
|
||||
QEvent::Type type;
|
||||
Qt::MouseButton button;
|
||||
Qt::MouseButtons buttons;
|
||||
QPoint pos;
|
||||
Qt::KeyboardModifiers modifiers;
|
||||
Destination destination;
|
||||
|
||||
int msec;
|
||||
};
|
||||
struct KeyEvent {
|
||||
KeyEvent(QKeyEvent *e)
|
||||
: type(e->type()), key(e->key()), modifiers(e->modifiers()), text(e->text()),
|
||||
autorep(e->isAutoRepeat()), count(e->count()), destination(View) {}
|
||||
QEvent::Type type;
|
||||
int key;
|
||||
Qt::KeyboardModifiers modifiers;
|
||||
QString text;
|
||||
bool autorep;
|
||||
ushort count;
|
||||
Destination destination;
|
||||
|
||||
int msec;
|
||||
};
|
||||
struct FrameEvent {
|
||||
QImage image;
|
||||
QByteArray hash;
|
||||
int msec;
|
||||
};
|
||||
QList<MouseEvent> m_mouseEvents;
|
||||
QList<KeyEvent> m_keyEvents;
|
||||
|
||||
QList<MouseEvent> m_savedMouseEvents;
|
||||
QList<KeyEvent> m_savedKeyEvents;
|
||||
QList<FrameEvent> m_savedFrameEvents;
|
||||
bool filterEvents;
|
||||
|
||||
QDeclarativeViewer::ScriptOptions options;
|
||||
int testscriptidx;
|
||||
QDeclarativeVisualTest *testscript;
|
||||
|
||||
bool hasCompleted;
|
||||
bool hasFailed;
|
||||
};
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDECLARATIVETESTER_H
|
||||
@@ -1,37 +0,0 @@
|
||||
QT += declarative script network sql
|
||||
contains(QT_CONFIG, opengl) {
|
||||
QT += opengl
|
||||
DEFINES += GL_SUPPORTED
|
||||
}
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += $$PWD/qmlruntime.h \
|
||||
$$PWD/proxysettings.h \
|
||||
$$PWD/qdeclarativetester.h \
|
||||
$$PWD/deviceorientation.h \
|
||||
$$PWD/loggerwidget.h
|
||||
SOURCES += $$PWD/qmlruntime.cpp \
|
||||
$$PWD/proxysettings.cpp \
|
||||
$$PWD/qdeclarativetester.cpp \
|
||||
$$PWD/loggerwidget.cpp
|
||||
|
||||
RESOURCES = $$PWD/browser/browser.qrc \
|
||||
$$PWD/startup/startup.qrc
|
||||
|
||||
maemo5 {
|
||||
QT += dbus
|
||||
HEADERS += $$PWD/texteditautoresizer_maemo5.h
|
||||
SOURCES += $$PWD/deviceorientation_maemo5.cpp
|
||||
FORMS = $$PWD/recopts_maemo5.ui \
|
||||
$$PWD/proxysettings_maemo5.ui
|
||||
} else:linux-g++-maemo {
|
||||
QT += dbus
|
||||
SOURCES += $$PWD/deviceorientation_harmattan.cpp
|
||||
FORMS = $$PWD/recopts.ui \
|
||||
$$PWD/proxysettings.ui
|
||||
} else {
|
||||
SOURCES += $$PWD/deviceorientation.cpp
|
||||
FORMS = $$PWD/recopts.ui \
|
||||
$$PWD/proxysettings.ui
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += qt uic
|
||||
|
||||
include(qml.pri)
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
exists($$PWD/../qmljsdebugger/qmljsdebugger-src.pri) {
|
||||
# directly compile in debugger files
|
||||
include($$PWD/../qmljsdebugger/qmljsdebugger-src.pri)
|
||||
} else {
|
||||
# INCLUDEPATH and library path has to be extended by qmake call
|
||||
DEBUGLIB=QmlJSDebugger
|
||||
CONFIG(debug, debug|release) {
|
||||
windows:DEBUGLIB = QmlJSDebuggerd
|
||||
}
|
||||
LIBS+=-l$$DEBUGLIB
|
||||
}
|
||||
|
||||
#INCLUDEPATH += ../../include/QtDeclarative
|
||||
#INCLUDEPATH += ../../src/declarative/util
|
||||
#INCLUDEPATH += ../../src/declarative/graphicsitems
|
||||
|
||||
!exists($$[QT_INSTALL_HEADERS]/QtCore/private/qabstractanimation_p.h) {
|
||||
DEFINES += NO_PRIVATE_HEADERS
|
||||
}
|
||||
|
||||
target.path = $$[QT_INSTALL_BINS]
|
||||
INSTALLS += target
|
||||
|
||||
wince* {
|
||||
QT += xml
|
||||
|
||||
contains(QT_CONFIG, scripttools) {
|
||||
QT += scripttools
|
||||
}
|
||||
contains(QT_CONFIG, phonon) {
|
||||
QT += phonon
|
||||
}
|
||||
contains(QT_CONFIG, xmlpatterns) {
|
||||
QT += xmlpatterns
|
||||
}
|
||||
contains(QT_CONFIG, webkit) {
|
||||
QT += webkit
|
||||
}
|
||||
}
|
||||
maemo5 {
|
||||
QT += maemo5
|
||||
}
|
||||
symbian {
|
||||
TARGET.UID3 = 0x20021317
|
||||
include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
|
||||
TARGET.EPOCHEAPSIZE = 0x20000 0x4000000
|
||||
TARGET.CAPABILITY = NetworkServices ReadUserData
|
||||
!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) {
|
||||
LIBS += -lsensrvclient -lsensrvutil
|
||||
}
|
||||
contains(QT_CONFIG, s60): {
|
||||
LIBS += -lavkon -lcone
|
||||
}
|
||||
}
|
||||
|
||||
# generation of Info.plist from Info.plist.in is handled by static.pro
|
||||
# compiling this project directly from the Qt Creator source tree does not work
|
||||
OTHER_FILES+=Info.plist
|
||||
mac {
|
||||
QMAKE_INFO_PLIST=Info.plist
|
||||
TARGET=QMLObserver
|
||||
ICON=qml.icns
|
||||
} else {
|
||||
TARGET=qmlobserver
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMLRUNTIME_H
|
||||
#define QMLRUNTIME_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include <QTime>
|
||||
#include <QList>
|
||||
|
||||
#include "loggerwidget.h"
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
class QDeclarativeViewInspector;
|
||||
}
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeclarativeView;
|
||||
class PreviewDeviceSkin;
|
||||
class QDeclarativeTestEngine;
|
||||
class QProcess;
|
||||
class RecordingDialog;
|
||||
class QDeclarativeTester;
|
||||
class QNetworkReply;
|
||||
class QNetworkCookieJar;
|
||||
class NetworkAccessManagerFactory;
|
||||
class QTranslator;
|
||||
class QActionGroup;
|
||||
class QMenuBar;
|
||||
|
||||
class QDeclarativeViewer
|
||||
: public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
~QDeclarativeViewer();
|
||||
|
||||
static void registerTypes();
|
||||
|
||||
enum ScriptOption {
|
||||
Play = 0x00000001,
|
||||
Record = 0x00000002,
|
||||
TestImages = 0x00000004,
|
||||
TestErrorProperty = 0x00000008,
|
||||
SaveOnExit = 0x00000010,
|
||||
ExitOnComplete = 0x00000020,
|
||||
ExitOnFailure = 0x00000040,
|
||||
Snapshot = 0x00000080,
|
||||
TestSkipProperty = 0x00000100
|
||||
};
|
||||
Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
|
||||
void setScript(const QString &s) { m_script = s; }
|
||||
void setScriptOptions(ScriptOptions opt) { m_scriptOptions = opt; }
|
||||
void setRecordDither(const QString& s) { record_dither = s; }
|
||||
void setRecordRate(int fps);
|
||||
void setRecordFile(const QString&);
|
||||
void setRecordArgs(const QStringList&);
|
||||
void setRecording(bool on);
|
||||
bool isRecording() const { return recordTimer.isActive(); }
|
||||
void setAutoRecord(int from, int to);
|
||||
void setDeviceKeys(bool);
|
||||
void setNetworkCacheSize(int size);
|
||||
void addLibraryPath(const QString& lib);
|
||||
void addPluginPath(const QString& plugin);
|
||||
void setUseGL(bool use);
|
||||
void setUseNativeFileBrowser(bool);
|
||||
void setSizeToView(bool sizeToView);
|
||||
void setStayOnTop(bool stayOnTop);
|
||||
|
||||
QDeclarativeView *view() const;
|
||||
LoggerWidget *warningsWidget() const;
|
||||
QString currentFile() const { return currentFileOrUrl; }
|
||||
|
||||
void enableExperimentalGestures();
|
||||
|
||||
public slots:
|
||||
void setDesignModeBehavior(bool value);
|
||||
void sceneResized(QSize size);
|
||||
bool open(const QString&);
|
||||
void openFile();
|
||||
void openUrl();
|
||||
void reload();
|
||||
void takeSnapShot();
|
||||
void toggleRecording();
|
||||
void toggleRecordingWithSelection();
|
||||
void ffmpegFinished(int code);
|
||||
void showProxySettings ();
|
||||
void proxySettingsChanged ();
|
||||
void rotateOrientation();
|
||||
void statusChanged();
|
||||
void pauseAnimations();
|
||||
void stepAnimations();
|
||||
void setAnimationStep();
|
||||
void changeAnimationSpeed();
|
||||
void launch(const QString &);
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
virtual bool event(QEvent *);
|
||||
void createMenu();
|
||||
|
||||
private slots:
|
||||
void appAboutToQuit();
|
||||
|
||||
void autoStartRecording();
|
||||
void autoStopRecording();
|
||||
void recordFrame();
|
||||
void chooseRecordingOptions();
|
||||
void pickRecordingFile();
|
||||
void toggleFullScreen();
|
||||
void changeOrientation(QAction*);
|
||||
void orientationChanged();
|
||||
|
||||
void animationSpeedChanged(qreal factor);
|
||||
|
||||
void showWarnings(bool show);
|
||||
void warningsWidgetOpened();
|
||||
void warningsWidgetClosed();
|
||||
|
||||
private:
|
||||
void updateSizeHints(bool initial = false);
|
||||
|
||||
QString getVideoFileName();
|
||||
|
||||
LoggerWidget *loggerWindow;
|
||||
QDeclarativeView *canvas;
|
||||
QmlJSDebugger::QDeclarativeViewInspector *inspector;
|
||||
QSize initialSize;
|
||||
QString currentFileOrUrl;
|
||||
QTimer recordTimer;
|
||||
QString frame_fmt;
|
||||
QImage frame;
|
||||
QList<QImage*> frames;
|
||||
QProcess* frame_stream;
|
||||
QTimer autoStartTimer;
|
||||
QTimer autoStopTimer;
|
||||
QString record_dither;
|
||||
QString record_file;
|
||||
QSize record_outsize;
|
||||
QStringList record_args;
|
||||
int record_rate;
|
||||
int record_autotime;
|
||||
bool devicemode;
|
||||
QAction *recordAction;
|
||||
RecordingDialog *recdlg;
|
||||
|
||||
void senseImageMagick();
|
||||
void senseFfmpeg();
|
||||
QWidget *ffmpegHelpWindow;
|
||||
bool ffmpegAvailable;
|
||||
bool convertAvailable;
|
||||
|
||||
int m_stepSize;
|
||||
QActionGroup *playSpeedMenuActions;
|
||||
QAction *pauseAnimationsAction;
|
||||
QAction *animationStepAction;
|
||||
QAction *animationSetStepAction;
|
||||
|
||||
QAction *rotateAction;
|
||||
QActionGroup *orientation;
|
||||
QAction *showWarningsWindow;
|
||||
QAction *designModeBehaviorAction;
|
||||
QAction *appOnTopAction;
|
||||
|
||||
QString m_script;
|
||||
ScriptOptions m_scriptOptions;
|
||||
QDeclarativeTester *tester;
|
||||
|
||||
QNetworkReply *wgtreply;
|
||||
QString wgtdir;
|
||||
NetworkAccessManagerFactory *namFactory;
|
||||
|
||||
bool useQmlFileBrowser;
|
||||
|
||||
QTranslator *translator;
|
||||
void loadTranslationFile(const QString& directory);
|
||||
|
||||
void loadDummyDataFiles(const QString& directory);
|
||||
};
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QMLRUNTIME_H
|
||||
@@ -1,513 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RecordingOptions</class>
|
||||
<widget class="QDialog" name="RecordingOptions">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>316</width>
|
||||
<height>436</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Video options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="file"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pickfile">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="sizeOriginal">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="sizeVGA">
|
||||
<property name="text">
|
||||
<string>VGA</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="size720p">
|
||||
<property name="text">
|
||||
<string>720p</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QRadioButton" name="sizeQVGA">
|
||||
<property name="text">
|
||||
<string>QVGA</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="sizeCustom">
|
||||
<property name="text">
|
||||
<string>Width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sizeWidth">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Height:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sizeHeight">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="rateOptions">
|
||||
<property name="title">
|
||||
<string>Rate</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="hz60">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>60Hz</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="hz50">
|
||||
<property name="text">
|
||||
<string>50Hz</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QRadioButton" name="hz25">
|
||||
<property name="text">
|
||||
<string>25Hz</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="hzCustom">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="hz">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Hz</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QRadioButton" name="hz24">
|
||||
<property name="text">
|
||||
<string>24Hz</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="ffmpegOptions">
|
||||
<property name="title">
|
||||
<string>Profile</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QComboBox" name="profile"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="args"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="ffmpegHelp">
|
||||
<property name="text">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="warning">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>file</tabstop>
|
||||
<tabstop>pickfile</tabstop>
|
||||
<tabstop>sizeOriginal</tabstop>
|
||||
<tabstop>sizeVGA</tabstop>
|
||||
<tabstop>size720p</tabstop>
|
||||
<tabstop>sizeQVGA</tabstop>
|
||||
<tabstop>sizeCustom</tabstop>
|
||||
<tabstop>sizeWidth</tabstop>
|
||||
<tabstop>sizeHeight</tabstop>
|
||||
<tabstop>hz60</tabstop>
|
||||
<tabstop>hz25</tabstop>
|
||||
<tabstop>hz50</tabstop>
|
||||
<tabstop>hz24</tabstop>
|
||||
<tabstop>hzCustom</tabstop>
|
||||
<tabstop>hz</tabstop>
|
||||
<tabstop>profile</tabstop>
|
||||
<tabstop>args</tabstop>
|
||||
<tabstop>ffmpegHelp</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>hzCustom</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>hz</receiver>
|
||||
<slot>setFocus()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>43</x>
|
||||
<y>257</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>129</x>
|
||||
<y>262</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>hz</sender>
|
||||
<signal>textChanged(QString)</signal>
|
||||
<receiver>hzCustom</receiver>
|
||||
<slot>toggle()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>143</x>
|
||||
<y>262</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>43</x>
|
||||
<y>257</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>hz</sender>
|
||||
<signal>selectionChanged()</signal>
|
||||
<receiver>hzCustom</receiver>
|
||||
<slot>toggle()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>143</x>
|
||||
<y>262</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>43</x>
|
||||
<y>257</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>RecordingOptions</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>258</x>
|
||||
<y>424</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>60</x>
|
||||
<y>219</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>RecordingOptions</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>258</x>
|
||||
<y>424</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>92</x>
|
||||
<y>219</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>profile</sender>
|
||||
<signal>activated(int)</signal>
|
||||
<receiver>RecordingOptions</receiver>
|
||||
<slot>pickProfile(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>92</x>
|
||||
<y>329</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>48</x>
|
||||
<y>194</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>args</sender>
|
||||
<signal>textEdited(QString)</signal>
|
||||
<receiver>RecordingOptions</receiver>
|
||||
<slot>storeCustomArgs(QString)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>128</x>
|
||||
<y>357</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>102</x>
|
||||
<y>189</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>sizeWidth</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>sizeCustom</receiver>
|
||||
<slot>toggle()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>108</x>
|
||||
<y>133</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>48</x>
|
||||
<y>133</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>sizeHeight</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>sizeCustom</receiver>
|
||||
<slot>toggle()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>212</x>
|
||||
<y>133</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>64</x>
|
||||
<y>129</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<signal>filePicked(QString)</signal>
|
||||
<signal>argumentsPicked(QString)</signal>
|
||||
<slot>pickFile()</slot>
|
||||
<slot>pickProfile(int)</slot>
|
||||
<slot>storeCustomArgs(QString)</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
@@ -1,254 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RecordingOptions</class>
|
||||
<widget class="QDialog" name="RecordingOptions">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>469</width>
|
||||
<height>142</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Video options</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,2,0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="file"/>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>72</width>
|
||||
<height>56</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="sizeCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>VGA</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>QVGA</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>720p</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="rateLabel">
|
||||
<property name="text">
|
||||
<string>Rate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" rowspan="2">
|
||||
<widget class="QComboBox" name="rateCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>60 Hz</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>50 Hz</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>25 Hz</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>24 Hz</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>20 Hz</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>15 Hz</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>10 Hz</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="args"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="profile"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="profileLabel">
|
||||
<property name="text">
|
||||
<string>Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QLabel" name="warning">
|
||||
<property name="text">
|
||||
<string notr="true">warning</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2" rowspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pickfile">
|
||||
<property name="text">
|
||||
<string>File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="ffmpegHelp">
|
||||
<property name="text">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>RecordingOptions</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>258</x>
|
||||
<y>424</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>60</x>
|
||||
<y>219</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>RecordingOptions</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>258</x>
|
||||
<y>424</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>92</x>
|
||||
<y>219</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>profile</sender>
|
||||
<signal>activated(int)</signal>
|
||||
<receiver>RecordingOptions</receiver>
|
||||
<slot>pickProfile(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>92</x>
|
||||
<y>329</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>48</x>
|
||||
<y>194</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>args</sender>
|
||||
<signal>textEdited(QString)</signal>
|
||||
<receiver>RecordingOptions</receiver>
|
||||
<slot>storeCustomArgs(QString)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>128</x>
|
||||
<y>357</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>102</x>
|
||||
<y>189</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<signal>filePicked(QString)</signal>
|
||||
<signal>argumentsPicked(QString)</signal>
|
||||
<slot>pickFile()</slot>
|
||||
<slot>pickProfile(int)</slot>
|
||||
<slot>storeCustomArgs(QString)</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
@@ -1,167 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.1
|
||||
|
||||
Rectangle {
|
||||
id: myApp
|
||||
width: 411
|
||||
height: 411
|
||||
color: "transparent"
|
||||
property alias logoState : myApp.state
|
||||
signal animationFinished
|
||||
|
||||
Item {
|
||||
id: sketchBlueHolder
|
||||
width: sketchLogo.width
|
||||
height: sketchLogo.height
|
||||
Image {
|
||||
id: image1
|
||||
x: -44
|
||||
y: -45
|
||||
smooth: true
|
||||
source: "shadow.png"
|
||||
}
|
||||
Item {
|
||||
clip: true
|
||||
width: sketchLogo.width
|
||||
height: sketchLogo.height
|
||||
Image {
|
||||
id: sketchLogo
|
||||
smooth: true
|
||||
source: "qt-sketch.jpg"
|
||||
}
|
||||
Image {
|
||||
id: blueLogo
|
||||
y: -420
|
||||
smooth: true
|
||||
source: "qt-blue.jpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "showBlueprint"
|
||||
PropertyChanges {
|
||||
target: blueLogo
|
||||
y: 0
|
||||
}
|
||||
PropertyChanges {
|
||||
target: sketchLogo
|
||||
opacity: 0
|
||||
}
|
||||
},
|
||||
State {
|
||||
extend: "showBlueprint"
|
||||
name: "finale"
|
||||
PropertyChanges {
|
||||
target: fullLogo
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges {
|
||||
target: backLogo
|
||||
opacity: 1
|
||||
scale: 1
|
||||
}
|
||||
PropertyChanges {
|
||||
target: frontLogo
|
||||
opacity: 1
|
||||
scale: 1
|
||||
}
|
||||
PropertyChanges {
|
||||
target: qtText
|
||||
opacity: 1
|
||||
scale: 1
|
||||
}
|
||||
PropertyChanges {
|
||||
target: sketchBlueHolder
|
||||
opacity: 0
|
||||
scale: 1.4
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
to: "showBlueprint"
|
||||
SequentialAnimation {
|
||||
NumberAnimation { property: "y"; duration: 600; easing.type: "OutBounce" }
|
||||
PropertyAction { target: sketchLogo; property: "opacity" }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
to: "finale"
|
||||
PropertyAction { target: fullLogo; property: "opacity" }
|
||||
SequentialAnimation {
|
||||
NumberAnimation { target: backLogo; properties: "scale, opacity"; duration: 300 }
|
||||
NumberAnimation { target: frontLogo; properties: "scale, opacity"; duration: 300 }
|
||||
ParallelAnimation {
|
||||
NumberAnimation { target: qtText; properties: "opacity, scale"; duration: 400; easing.type: "OutQuad" }
|
||||
NumberAnimation { target: sketchBlueHolder; property: "opacity"; duration: 300; easing.type: "OutQuad" }
|
||||
NumberAnimation { target: sketchBlueHolder; property: "scale"; duration: 320; easing.type: "OutQuad" }
|
||||
}
|
||||
PauseAnimation { duration: 1000 }
|
||||
ScriptAction { script: myApp.animationFinished() }
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Item {
|
||||
id: fullLogo
|
||||
opacity: 0
|
||||
Image {
|
||||
id: backLogo
|
||||
x: -16
|
||||
y: -41
|
||||
opacity: 0
|
||||
scale: 0.7
|
||||
smooth: true
|
||||
source: "qt-back.png"
|
||||
}
|
||||
Image {
|
||||
id: frontLogo
|
||||
x: -17
|
||||
y: -41
|
||||
opacity: 0
|
||||
scale: 1.2
|
||||
smooth: true
|
||||
source: "qt-front.png"
|
||||
}
|
||||
Image {
|
||||
id: qtText
|
||||
x: -10
|
||||
y: -41
|
||||
opacity: 0
|
||||
scale: 1.2
|
||||
smooth: true
|
||||
source: "qt-text.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,161 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 1.0
|
||||
|
||||
Rectangle {
|
||||
id: treatsApp
|
||||
width: 800
|
||||
height: 480
|
||||
color: "darkgrey"
|
||||
Component.onCompleted: treatsApp.state = "part1"
|
||||
signal animationFinished
|
||||
|
||||
Item {
|
||||
width: 800
|
||||
height: 480
|
||||
anchors.centerIn: parent
|
||||
clip: true
|
||||
|
||||
Logo {
|
||||
id: logo
|
||||
x: 165
|
||||
y: 35
|
||||
rotation: -15
|
||||
scale: 0.6
|
||||
opacity: 0
|
||||
onAnimationFinished: treatsApp.animationFinished();
|
||||
}
|
||||
|
||||
Item {
|
||||
id: quickblur
|
||||
x: 800//325
|
||||
y: 344
|
||||
Image {
|
||||
id: blurText
|
||||
source: "quick-blur.png"
|
||||
}
|
||||
Image {
|
||||
id: quickregular
|
||||
x: -1
|
||||
y: 0
|
||||
opacity: 0
|
||||
source: "quick-regular.png"
|
||||
}
|
||||
Image {
|
||||
id: star
|
||||
x: -1
|
||||
y: 0
|
||||
opacity: 0
|
||||
source: "white-star.png"
|
||||
smooth: true
|
||||
NumberAnimation on rotation {
|
||||
from: 0
|
||||
to: 360
|
||||
loops: NumberAnimation.Infinite
|
||||
running: true
|
||||
duration: 2000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "part1"
|
||||
PropertyChanges {
|
||||
target: logo
|
||||
scale: 0.8
|
||||
opacity: 1
|
||||
rotation: 0
|
||||
}
|
||||
PropertyChanges {
|
||||
target: treatsApp
|
||||
color: "black"
|
||||
}
|
||||
PropertyChanges {
|
||||
target: logo
|
||||
y: 10
|
||||
}
|
||||
PropertyChanges {
|
||||
target: quickblur
|
||||
x: logo.x + 145
|
||||
}
|
||||
PropertyChanges {
|
||||
target: blurText
|
||||
opacity: 0
|
||||
}
|
||||
PropertyChanges {
|
||||
target: quickregular
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges {
|
||||
target: star
|
||||
x: -7
|
||||
y: -37
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
ParallelAnimation {
|
||||
NumberAnimation { target: logo; property: "opacity"; duration: 500 }
|
||||
NumberAnimation { target: logo; property: "scale"; duration: 4000; }
|
||||
NumberAnimation { target: logo; property: "rotation"; duration: 2000; easing.type: "OutBack"}
|
||||
ColorAnimation { duration: 3000}
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: 1000 }
|
||||
ScriptAction { script: logo.logoState = "showBlueprint" }
|
||||
PauseAnimation { duration: 800 }
|
||||
ScriptAction { script: logo.logoState = "finale" }
|
||||
PauseAnimation { duration: 800 }
|
||||
ParallelAnimation {
|
||||
NumberAnimation { target: quickblur; property: "x"; duration: 200;}
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: 200}
|
||||
ParallelAnimation {
|
||||
NumberAnimation { target: blurText; property: "opacity"; duration: 300;}
|
||||
NumberAnimation { target: quickregular; property: "opacity"; duration: 300;}
|
||||
}
|
||||
NumberAnimation { target: star; property: "opacity"; from: 0; to: 1; duration: 500 }
|
||||
PauseAnimation { duration: 200 }
|
||||
NumberAnimation { target: star; property: "opacity"; from: 1; to: 0; duration: 500 }
|
||||
}
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: 150}
|
||||
NumberAnimation { target: logo; property: "y"; duration: 300; easing.type: "OutBounce" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
} // treatsApp
|
||||
@@ -1,16 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/startup">
|
||||
<file>Logo.qml</file>
|
||||
<file>qt-back.png</file>
|
||||
<file>qt-blue.jpg</file>
|
||||
<file>qt-front.png</file>
|
||||
<file>qt-sketch.jpg</file>
|
||||
<file>qt-text.png</file>
|
||||
<file>quick-blur.png</file>
|
||||
<file>quick-regular.png</file>
|
||||
<file>shadow.png</file>
|
||||
<file>startup.qml</file>
|
||||
<file>startup.qrc</file>
|
||||
<file>white-star.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
@@ -1,101 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qplaintextedit.h>
|
||||
#include <qtextedit.h>
|
||||
#include <qabstractkineticscroller.h>
|
||||
#include <qscrollarea.h>
|
||||
#include <QDebug>
|
||||
|
||||
#ifndef TEXTEDITAUTORESIZER_H
|
||||
#define TEXTEDITAUTORESIZER_H
|
||||
|
||||
class TextEditAutoResizer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TextEditAutoResizer(QWidget *parent)
|
||||
: QObject(parent), plainTextEdit(qobject_cast<QPlainTextEdit *>(parent)),
|
||||
textEdit(qobject_cast<QTextEdit *>(parent)), edit(qobject_cast<QFrame *>(parent))
|
||||
{
|
||||
// parent must either inherit QPlainTextEdit or QTextEdit!
|
||||
Q_ASSERT(plainTextEdit || textEdit);
|
||||
|
||||
connect(parent, SIGNAL(textChanged()), this, SLOT(textEditChanged()));
|
||||
connect(parent, SIGNAL(cursorPositionChanged()), this, SLOT(textEditChanged()));
|
||||
|
||||
textEditChanged();
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
inline void textEditChanged();
|
||||
|
||||
private:
|
||||
QPlainTextEdit *plainTextEdit;
|
||||
QTextEdit *textEdit;
|
||||
QFrame *edit;
|
||||
};
|
||||
|
||||
void TextEditAutoResizer::textEditChanged()
|
||||
{
|
||||
QTextDocument *doc = textEdit ? textEdit->document() : plainTextEdit->document();
|
||||
QRect cursor = textEdit ? textEdit->cursorRect() : plainTextEdit->cursorRect();
|
||||
|
||||
QSize s = doc->size().toSize();
|
||||
if (plainTextEdit)
|
||||
s.setHeight((s.height() + 2) * edit->fontMetrics().lineSpacing());
|
||||
|
||||
const QRect fr = edit->frameRect();
|
||||
const QRect cr = edit->contentsRect();
|
||||
|
||||
edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height() - 1)));
|
||||
|
||||
// make sure the cursor is visible in case we have a QAbstractScrollArea parent
|
||||
QPoint pos = edit->pos();
|
||||
QWidget *pw = edit->parentWidget();
|
||||
while (pw) {
|
||||
if (qobject_cast<QScrollArea *>(pw))
|
||||
break;
|
||||
pw = pw->parentWidget();
|
||||
}
|
||||
|
||||
if (pw) {
|
||||
QScrollArea *area = static_cast<QScrollArea *>(pw);
|
||||
QPoint scrollto = area->widget()->mapFrom(edit, cursor.center());
|
||||
QPoint margin(10 + cursor.width(), 2 * cursor.height());
|
||||
|
||||
if (QAbstractKineticScroller *scroller = area->property("kineticScroller").value<QAbstractKineticScroller *>()) {
|
||||
scroller->ensureVisible(scrollto, margin.x(), margin.y());
|
||||
} else {
|
||||
area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -72,9 +72,6 @@ OTHER_FILES += $$FILES
|
||||
dumpinfo.input = qml/qmldump/Info.plist.in
|
||||
dumpinfo.output = $$IDE_DATA_PATH/qml/qmldump/Info.plist
|
||||
QMAKE_SUBSTITUTES += dumpinfo
|
||||
observerinfo.input = qml/qmlobserver/Info.plist.in
|
||||
observerinfo.output = $$IDE_DATA_PATH/qml/qmlobserver/Info.plist
|
||||
QMAKE_SUBSTITUTES += observerinfo
|
||||
puppetinfo.input = qml/qmlpuppet/qmlpuppet/Info.plist.in
|
||||
puppetinfo.output = $$IDE_DATA_PATH/qml/qmlpuppet/qmlpuppet/Info.plist
|
||||
QMAKE_SUBSTITUES += puppetinfo
|
||||
|
||||
@@ -1663,9 +1663,6 @@ void ProjectExplorerPlugin::showRunErrorMessage(const QString &errorMessage)
|
||||
if (errorMessage.isNull()) {
|
||||
// a error occured, but message was not set
|
||||
QMessageBox::critical(ICore::mainWindow(), tr("Unknown error"), errorMessage);
|
||||
} else if (errorMessage.isEmpty()) {
|
||||
// a error, but the message was set to empty
|
||||
// hack for qml observer warning, show nothing at all
|
||||
} else {
|
||||
QMessageBox::critical(ICore::mainWindow(), tr("Could Not Run"), errorMessage);
|
||||
}
|
||||
|
||||
@@ -366,8 +366,6 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) :
|
||||
connect(m_ui->propertyEdit, SIGNAL(propertiesChanged()), this, SLOT(changeProperties()));
|
||||
connect(m_ui->qmlDebuggingLibraryCheckBox, SIGNAL(toggled(bool)),
|
||||
this, SLOT(linkQmlDebuggingLibraryChecked(bool)));
|
||||
connect(m_ui->qmlDebuggingWarningText, SIGNAL(linkActivated(QString)),
|
||||
this, SLOT(buildQmlDebuggingHelper()));
|
||||
connect(QtSupport::QtVersionManager::instance(), SIGNAL(dumpUpdatedFor(Utils::FileName)),
|
||||
this, SLOT(updateQmlDebuggingOption()));
|
||||
updateState();
|
||||
@@ -531,12 +529,6 @@ void QbsBuildStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked)
|
||||
m_ignoreChange = false;
|
||||
}
|
||||
|
||||
void QbsBuildStepConfigWidget::buildQmlDebuggingHelper()
|
||||
{
|
||||
QtSupport::BaseQtVersion::buildDebuggingHelper(m_step->target()->kit(),
|
||||
static_cast<int>(QtSupport::DebuggingHelperBuildTask::QmlDebugging));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// QbsBuildStepFactory:
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -134,7 +134,6 @@ private slots:
|
||||
|
||||
// QML debugging:
|
||||
void linkQmlDebuggingLibraryChecked(bool checked);
|
||||
void buildQmlDebuggingHelper();
|
||||
|
||||
private:
|
||||
Ui::QbsBuildStepConfigWidget *m_ui;
|
||||
|
||||
@@ -193,25 +193,9 @@ QStringList QMakeStep::deducedArguments()
|
||||
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
|
||||
if (linkQmlDebuggingLibrary() && version) {
|
||||
if (!version->needsQmlDebuggingLibrary()) {
|
||||
// This Qt version has the QML debugging services built in, however
|
||||
// they still need to be enabled at compile time
|
||||
// TODO: For Qt5, we can pass both arguments as there can be Qt Quick 1/2 projects.
|
||||
// Currently there is no support for debugging multiple engines.
|
||||
arguments << QLatin1String(Constants::QMAKEVAR_QUICK1_DEBUG);
|
||||
if (version->qtVersion().majorVersion >= 5)
|
||||
arguments << QLatin1String(Constants::QMAKEVAR_QUICK2_DEBUG);
|
||||
} else {
|
||||
const QString qmlDebuggingHelperLibrary = version->qmlDebuggingHelperLibrary(true);
|
||||
if (!qmlDebuggingHelperLibrary.isEmpty()) {
|
||||
// Do not turn debugger path into native path separators: Qmake does not like that!
|
||||
const QString debuggingHelperPath
|
||||
= QFileInfo(qmlDebuggingHelperLibrary).dir().path();
|
||||
|
||||
arguments << QLatin1String(Constants::QMAKEVAR_QMLJSDEBUGGER_PATH)
|
||||
+ QLatin1Char('=') + debuggingHelperPath;
|
||||
}
|
||||
}
|
||||
arguments << QLatin1String(Constants::QMAKEVAR_QUICK1_DEBUG);
|
||||
if (version->qtVersion().majorVersion >= 5)
|
||||
arguments << QLatin1String(Constants::QMAKEVAR_QUICK2_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
@@ -478,8 +462,6 @@ QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step)
|
||||
this, SLOT(buildConfigurationSelected()));
|
||||
connect(m_ui->qmlDebuggingLibraryCheckBox, SIGNAL(toggled(bool)),
|
||||
this, SLOT(linkQmlDebuggingLibraryChecked(bool)));
|
||||
connect(m_ui->qmlDebuggingWarningText, SIGNAL(linkActivated(QString)),
|
||||
this, SLOT(buildQmlDebuggingHelper()));
|
||||
connect(step, SIGNAL(userArgumentsChanged()),
|
||||
this, SLOT(userArgumentsChanged()));
|
||||
connect(step, SIGNAL(linkQmlDebuggingLibraryChanged()),
|
||||
@@ -600,12 +582,6 @@ void QMakeStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked)
|
||||
question->show();
|
||||
}
|
||||
|
||||
void QMakeStepConfigWidget::buildQmlDebuggingHelper()
|
||||
{
|
||||
QtSupport::BaseQtVersion::buildDebuggingHelper(m_step->target()->kit(),
|
||||
static_cast<int>(QtSupport::DebuggingHelperBuildTask::QmlDebugging));
|
||||
}
|
||||
|
||||
void QMakeStepConfigWidget::updateSummaryLabel()
|
||||
{
|
||||
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(m_step->target()->kit());
|
||||
|
||||
@@ -157,9 +157,6 @@ private slots:
|
||||
void buildConfigurationSelected();
|
||||
void linkQmlDebuggingLibraryChecked(bool checked);
|
||||
|
||||
// other
|
||||
void buildQmlDebuggingHelper();
|
||||
|
||||
private slots:
|
||||
void recompileMessageBoxFinished(int button);
|
||||
|
||||
|
||||
@@ -14,7 +14,16 @@
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
@@ -27,7 +36,16 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="buildConfigurrationWidget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@@ -86,7 +104,16 @@
|
||||
<item row="2" column="1">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
||||
@@ -113,16 +113,6 @@ bool QmlProfilerRunControl::startEngine()
|
||||
|
||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStarting);
|
||||
|
||||
if (ProjectExplorer::LocalApplicationRunConfiguration *rc =
|
||||
qobject_cast<ProjectExplorer::LocalApplicationRunConfiguration *>(runConfiguration())) {
|
||||
if (rc->executable().isEmpty()) {
|
||||
showQmlObserverToolWarning();
|
||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
||||
AnalyzerManager::stopTool();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (startParameters().startMode == StartLocal) {
|
||||
d->m_noDebugOutputTimer.start();
|
||||
} else {
|
||||
@@ -317,28 +307,5 @@ void QmlProfilerRunControl::profilerStateChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerRunControl::showQmlObserverToolWarning()
|
||||
{
|
||||
QMessageBox dialog(QApplication::activeWindow());
|
||||
QPushButton *qtPref = dialog.addButton(tr("Open Qt Versions"),
|
||||
QMessageBox::ActionRole);
|
||||
dialog.addButton(QMessageBox::Cancel);
|
||||
dialog.setDefaultButton(qtPref);
|
||||
dialog.setWindowTitle(tr("QML Observer Missing"));
|
||||
dialog.setText(tr("QML Observer could not be found for this Qt version."));
|
||||
dialog.setInformativeText(tr(
|
||||
"QML Observer is used to offer debugging features for "
|
||||
"Qt Quick UI projects in the Qt 4.7 series.\n\n"
|
||||
"To compile QML Observer, go to the Qt Versions page, "
|
||||
"select the current Qt version, "
|
||||
"and click Build in the Helpers section."));
|
||||
dialog.exec();
|
||||
if (dialog.clickedButton() == qtPref) {
|
||||
Core::ICore::showOptionsDialog(
|
||||
ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY,
|
||||
QtSupport::Constants::QTVERSION_SETTINGS_PAGE_ID);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
|
||||
@@ -75,9 +75,6 @@ private slots:
|
||||
private slots:
|
||||
void profilerStateChanged();
|
||||
|
||||
private:
|
||||
void showQmlObserverToolWarning();
|
||||
|
||||
private:
|
||||
class QmlProfilerEnginePrivate;
|
||||
QmlProfilerEnginePrivate *d;
|
||||
|
||||
@@ -77,29 +77,6 @@ void QmlProjectPlugin::extensionsInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
void QmlProjectPlugin::showQmlObserverToolWarning()
|
||||
{
|
||||
QMessageBox dialog(QApplication::activeWindow());
|
||||
QPushButton *qtPref = dialog.addButton(tr("Open Qt Versions"),
|
||||
QMessageBox::ActionRole);
|
||||
dialog.addButton(QMessageBox::Cancel);
|
||||
dialog.setDefaultButton(qtPref);
|
||||
dialog.setWindowTitle(tr("QML Observer Missing"));
|
||||
dialog.setText(tr("QML Observer could not be found for this Qt version."));
|
||||
dialog.setInformativeText(tr(
|
||||
"QML Observer is used to offer debugging features for "
|
||||
"Qt Quick UI projects in the Qt 4.7 series.\n\n"
|
||||
"To compile QML Observer, go to the Qt Versions page, "
|
||||
"select the current Qt version, "
|
||||
"and click Build in the Helpers section."));
|
||||
dialog.exec();
|
||||
if (dialog.clickedButton() == qtPref) {
|
||||
Core::ICore::showOptionsDialog(
|
||||
ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY,
|
||||
QtSupport::Constants::QTVERSION_SETTINGS_PAGE_ID);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
Q_EXPORT_PLUGIN(QmlProjectManager::QmlProjectPlugin)
|
||||
|
||||
@@ -47,8 +47,6 @@ public:
|
||||
|
||||
virtual bool initialize(const QStringList &arguments, QString *errorString);
|
||||
virtual void extensionsInitialized();
|
||||
|
||||
static void showQmlObserverToolWarning();
|
||||
};
|
||||
|
||||
} // namespace QmlProject
|
||||
|
||||
@@ -110,10 +110,7 @@ QString QmlProjectRunConfiguration::executable() const
|
||||
|
||||
if (id() == Constants::QML_SCENE_RC_ID)
|
||||
return version->qmlsceneCommand();
|
||||
if (!version->needsQmlDebuggingLibrary())
|
||||
return version->qmlviewerCommand();
|
||||
return version->qmlObserverTool();
|
||||
|
||||
return version->qmlviewerCommand();
|
||||
}
|
||||
|
||||
ProjectExplorer::LocalApplicationRunConfiguration::RunMode QmlProjectRunConfiguration::runMode() const
|
||||
|
||||
@@ -29,9 +29,7 @@
|
||||
|
||||
#include "baseqtversion.h"
|
||||
#include "qtconfigwidget.h"
|
||||
#include "qmlobservertool.h"
|
||||
#include "qmldumptool.h"
|
||||
#include "qmldebugginglibrary.h"
|
||||
#include "qtkitinformation.h"
|
||||
|
||||
#include "qtversionmanager.h"
|
||||
@@ -141,8 +139,6 @@ BaseQtVersion::BaseQtVersion(const FileName &qmakeCommand, bool isAutodetected,
|
||||
m_isAutodetected(isAutodetected),
|
||||
m_hasDebuggingHelper(false),
|
||||
m_hasQmlDump(false),
|
||||
m_hasQmlDebuggingLibrary(false),
|
||||
m_hasQmlObserver(false),
|
||||
m_mkspecUpToDate(false),
|
||||
m_mkspecReadUpToDate(false),
|
||||
m_defaultConfigIsDebug(true),
|
||||
@@ -164,8 +160,6 @@ BaseQtVersion::BaseQtVersion()
|
||||
: m_id(-1), m_isAutodetected(false),
|
||||
m_hasDebuggingHelper(false),
|
||||
m_hasQmlDump(false),
|
||||
m_hasQmlDebuggingLibrary(false),
|
||||
m_hasQmlObserver(false),
|
||||
m_mkspecUpToDate(false),
|
||||
m_mkspecReadUpToDate(false),
|
||||
m_defaultConfigIsDebug(true),
|
||||
@@ -918,8 +912,6 @@ void BaseQtVersion::updateVersionInfo() const
|
||||
m_hasDocumentation = false;
|
||||
m_hasDebuggingHelper = false;
|
||||
m_hasQmlDump = false;
|
||||
m_hasQmlDebuggingLibrary = false;
|
||||
m_hasQmlObserver = false;
|
||||
|
||||
if (!queryQMakeVariables(qmakeCommand(), qmakeRunEnvironment(), &m_versionInfo)) {
|
||||
m_qmakeIsExecutable = false;
|
||||
@@ -938,10 +930,6 @@ void BaseQtVersion::updateVersionInfo() const
|
||||
m_hasQmlDump
|
||||
= !QmlDumpTool::toolForQtPaths(qtInstallData, qtInstallBins, qtHeaderData, false).isEmpty()
|
||||
|| !QmlDumpTool::toolForQtPaths(qtInstallData, qtInstallBins, qtHeaderData, true).isEmpty();
|
||||
m_hasQmlDebuggingLibrary
|
||||
= !QmlDebuggingLibrary::libraryByInstallData(qtInstallData, false).isEmpty()
|
||||
|| !QmlDebuggingLibrary::libraryByInstallData(qtInstallData, true).isEmpty();
|
||||
m_hasQmlObserver = !QmlObserverTool::toolByInstallData(qtInstallData).isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1107,23 +1095,6 @@ bool BaseQtVersion::needsQmlDump() const
|
||||
return qtVersion() < QtVersionNumber(4, 8, 0);
|
||||
}
|
||||
|
||||
bool BaseQtVersion::hasQmlDebuggingLibrary() const
|
||||
{
|
||||
updateVersionInfo();
|
||||
return m_hasQmlDebuggingLibrary;
|
||||
}
|
||||
|
||||
bool BaseQtVersion::needsQmlDebuggingLibrary() const
|
||||
{
|
||||
return qtVersion() < QtVersionNumber(4, 8, 0);
|
||||
}
|
||||
|
||||
bool BaseQtVersion::hasQmlObserver() const
|
||||
{
|
||||
updateVersionInfo();
|
||||
return m_hasQmlObserver;
|
||||
}
|
||||
|
||||
Environment BaseQtVersion::qmlToolsEnvironment() const
|
||||
{
|
||||
// FIXME: This seems broken!
|
||||
@@ -1160,22 +1131,6 @@ QString BaseQtVersion::qmlDumpTool(bool debugVersion) const
|
||||
return QmlDumpTool::toolForQtPaths(qtInstallData, qtInstallBins, qtHeaderData, debugVersion);
|
||||
}
|
||||
|
||||
QString BaseQtVersion::qmlDebuggingHelperLibrary(bool debugVersion) const
|
||||
{
|
||||
QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
|
||||
if (qtInstallData.isEmpty())
|
||||
return QString();
|
||||
return QmlDebuggingLibrary::libraryByInstallData(qtInstallData, debugVersion);
|
||||
}
|
||||
|
||||
QString BaseQtVersion::qmlObserverTool() const
|
||||
{
|
||||
QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
|
||||
if (qtInstallData.isEmpty())
|
||||
return QString();
|
||||
return QmlObserverTool::toolByInstallData(qtInstallData);
|
||||
}
|
||||
|
||||
QStringList BaseQtVersion::debuggingHelperLibraryLocations() const
|
||||
{
|
||||
QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
|
||||
@@ -1472,25 +1427,19 @@ bool BaseQtVersion::isQmlDebuggingSupported(Kit *k, QString *reason)
|
||||
|
||||
bool BaseQtVersion::isQmlDebuggingSupported(QString *reason) const
|
||||
{
|
||||
if (!needsQmlDebuggingLibrary() || hasQmlDebuggingLibrary())
|
||||
return true;
|
||||
|
||||
if (!isValid()) {
|
||||
if (reason)
|
||||
*reason = QCoreApplication::translate("BaseQtVersion", "Invalid Qt version.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (qtVersion() < QtVersionNumber(4, 7, 1)) {
|
||||
if (qtVersion() < QtVersionNumber(4, 8, 0)) {
|
||||
if (reason)
|
||||
*reason = QCoreApplication::translate("BaseQtVersion", "Requires Qt 4.7.1 or newer.");
|
||||
*reason = QCoreApplication::translate("BaseQtVersion", "Requires Qt 4.8.0 or newer.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reason)
|
||||
*reason = QCoreApplication::translate("BaseQtVersion", "Library not available. <a href='compile'>Compile...</a>");
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseQtVersion::buildDebuggingHelper(Kit *k, int tools)
|
||||
|
||||
@@ -193,18 +193,13 @@ public:
|
||||
|
||||
virtual bool supportsBinaryDebuggingHelper() const;
|
||||
virtual QString gdbDebuggingHelperLibrary() const;
|
||||
virtual QString qmlDebuggingHelperLibrary(bool debugVersion) const;
|
||||
virtual QString qmlDumpTool(bool debugVersion) const;
|
||||
virtual QString qmlObserverTool() const;
|
||||
virtual QStringList debuggingHelperLibraryLocations() const;
|
||||
|
||||
virtual bool hasGdbDebuggingHelper() const;
|
||||
virtual bool hasQmlDump() const;
|
||||
virtual bool hasQmlDumpWithRelocatableFlag() const;
|
||||
virtual bool needsQmlDump() const;
|
||||
virtual bool hasQmlDebuggingLibrary() const;
|
||||
virtual bool needsQmlDebuggingLibrary() const;
|
||||
virtual bool hasQmlObserver() const;
|
||||
Utils::Environment qmlToolsEnvironment() const;
|
||||
|
||||
virtual QtConfigWidget *createConfigurationWidget() const;
|
||||
@@ -270,8 +265,6 @@ private:
|
||||
bool m_isAutodetected;
|
||||
mutable bool m_hasDebuggingHelper; // controlled by m_versionInfoUpToDate
|
||||
mutable bool m_hasQmlDump; // controlled by m_versionInfoUpToDate
|
||||
mutable bool m_hasQmlDebuggingLibrary; // controlled by m_versionInfoUpdate
|
||||
mutable bool m_hasQmlObserver; // controlled by m_versionInfoUpToDate
|
||||
mutable bool m_mkspecUpToDate;
|
||||
mutable bool m_mkspecReadUpToDate;
|
||||
mutable bool m_defaultConfigIsDebug;
|
||||
|
||||
@@ -6,16 +6,32 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>404</width>
|
||||
<height>176</height>
|
||||
<width>330</width>
|
||||
<height>85</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="qmlDumpBuildButton">
|
||||
<property name="text">
|
||||
<string>Build</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="qmlDumpLabel">
|
||||
<property name="toolTip">
|
||||
@@ -26,6 +42,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="gdbHelperBuildButton">
|
||||
<property name="text">
|
||||
<string>Build</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="qmlDumpStatus">
|
||||
<property name="sizePolicy">
|
||||
@@ -39,50 +62,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="qmlObserverLabel">
|
||||
<property name="toolTip">
|
||||
<string>A modified version of qmlviewer with support for QML/JS debugging.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>QML Observer:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="qmlObserverStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="qmlDebuggingLibLabel">
|
||||
<property name="text">
|
||||
<string>QML Debugging Library:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="qmlDebuggingLibStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="gdbHelperLabel">
|
||||
<property name="toolTip">
|
||||
<string>Helps showing content of Qt types. Only used in older versions of GDB.</string>
|
||||
@@ -92,7 +72,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="gdbHelperStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
@@ -105,34 +85,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="qmlDumpBuildButton">
|
||||
<property name="text">
|
||||
<string>Build</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="qmlDebuggingLibBuildButton">
|
||||
<property name="text">
|
||||
<string>Build</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="qmlObserverBuildButton">
|
||||
<property name="text">
|
||||
<string>Build</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="gdbHelperBuildButton">
|
||||
<property name="text">
|
||||
<string>Build</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include "debugginghelperbuildtask.h"
|
||||
#include "debugginghelper.h"
|
||||
#include "qmldumptool.h"
|
||||
#include "qmlobservertool.h"
|
||||
#include "qmldebugginglibrary.h"
|
||||
#include "baseqtversion.h"
|
||||
#include "qtversionmanager.h"
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -128,11 +126,6 @@ DebuggingHelperBuildTask::Tools DebuggingHelperBuildTask::availableTools(const B
|
||||
}
|
||||
if (QmlDumpTool::canBuild(version))
|
||||
tools |= QmlDump;
|
||||
if (QmlDebuggingLibrary::canBuild(version)) {
|
||||
tools |= QmlDebugging;
|
||||
if (QmlObserverTool::canBuild(version))
|
||||
tools |= QmlObserver; // requires QML debugging.
|
||||
}
|
||||
return tools;
|
||||
}
|
||||
|
||||
@@ -143,7 +136,7 @@ void DebuggingHelperBuildTask::showOutputOnError(bool show)
|
||||
|
||||
void DebuggingHelperBuildTask::run(QFutureInterface<void> &future)
|
||||
{
|
||||
future.setProgressRange(0, 5);
|
||||
future.setProgressRange(0, 3);
|
||||
future.setProgressValue(1);
|
||||
|
||||
if (m_invalidQt || !buildDebuggingHelper(future)) {
|
||||
@@ -203,47 +196,6 @@ bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &futu
|
||||
return false;
|
||||
}
|
||||
future.setProgressValue(3);
|
||||
|
||||
QString qmlDebuggingDirectory;
|
||||
if (m_tools & QmlDebugging) {
|
||||
QString output, error;
|
||||
|
||||
qmlDebuggingDirectory = QmlDebuggingLibrary::copy(m_qtInstallData, &error);
|
||||
|
||||
bool success = true;
|
||||
arguments.directory = qmlDebuggingDirectory;
|
||||
if (arguments.directory.isEmpty()
|
||||
|| !QmlDebuggingLibrary::build(arguments, &output, &error)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
log(output, error);
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
future.setProgressValue(4);
|
||||
|
||||
if (m_tools & QmlObserver) {
|
||||
QString output, error;
|
||||
bool success = true;
|
||||
|
||||
arguments.directory = QmlObserverTool::copy(m_qtInstallData, &error);
|
||||
arguments.qmakeArguments << QLatin1String("INCLUDEPATH+=\"\\\"")
|
||||
+ qmlDebuggingDirectory
|
||||
+ QLatin1String("include\\\"\"");
|
||||
arguments.qmakeArguments << QLatin1String("LIBS+=-L\"\\\"")
|
||||
+ qmlDebuggingDirectory
|
||||
+ QLatin1String("\\\"\"");
|
||||
|
||||
if (arguments.directory.isEmpty()
|
||||
|| !QmlObserverTool::build(arguments, &output, &error)) {
|
||||
success = false;
|
||||
}
|
||||
log(output, error);
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
future.setProgressValue(5);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||