Refactored QmlJS Live Preview into a library

QMLObserver links against the library dynamically. User's apps can also
link to it statically, so that the app can be deployed with debugging
features to a device, without having to worry about library deployment.
This commit is contained in:
Lasse Holmstedt
2010-07-29 12:15:55 +02:00
parent 36b638d985
commit 1972c2f897
81 changed files with 462 additions and 147 deletions
+1
View File
@@ -10,5 +10,6 @@ SUBDIRS = \
utils/process_stub.pro \
cplusplus \
qmljs \
qmljsdebugger \
symbianutils \
3rdparty
@@ -8,15 +8,13 @@ HEADERS += \
$$PWD/rubberbandselectionmanipulator.h \
$$PWD/selectionrectangle.h \
$$PWD/selectionindicator.h \
$$PWD/qmlviewerconstants.h \
$$PWD/boundingrecthighlighter.h \
$$PWD/subcomponenteditortool.h \
$$PWD/subcomponentmasklayeritem.h \
$$PWD/zoomtool.h \
$$PWD/colorpickertool.h \
$$PWD/qmltoolbar.h \
$$PWD/toolbarcolorbox.h \
$$PWD/crumblepath.h
$$PWD/toolbarcolorbox.h
SOURCES += \
$$PWD/abstractformeditortool.cpp \

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 160 B

After

Width:  |  Height:  |  Size: 160 B

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Before

Width:  |  Height:  |  Size: 160 B

After

Width:  |  Height:  |  Size: 160 B

@@ -34,7 +34,7 @@
namespace QmlViewer {
RubberBandSelectionManipulator::RubberBandSelectionManipulator(LayerItem *layerItem, QDeclarativeDesignView *editorView)
RubberBandSelectionManipulator::RubberBandSelectionManipulator(QGraphicsObject *layerItem, QDeclarativeDesignView *editorView)
: m_selectionRectangleElement(layerItem),
m_editorView(editorView),
m_beginFormEditorItem(0),
@@ -47,7 +47,7 @@ public:
};
RubberBandSelectionManipulator(LayerItem *layerItem, QDeclarativeDesignView *editorView);
RubberBandSelectionManipulator(QGraphicsObject *layerItem, QDeclarativeDesignView *editorView);
void setItems(const QList<QGraphicsItem*> &itemList);
@@ -37,7 +37,7 @@
namespace QmlViewer {
SelectionIndicator::SelectionIndicator(QDeclarativeDesignView *editorView, LayerItem *layerItem)
SelectionIndicator::SelectionIndicator(QDeclarativeDesignView *editorView, QGraphicsObject *layerItem)
: m_layerItem(layerItem), m_view(editorView)
{
}
@@ -32,7 +32,7 @@
#include <QWeakPointer>
#include <QGraphicsPolygonItem>
#include "layeritem.h"
#include <QGraphicsObject>
namespace QmlViewer {
@@ -41,7 +41,7 @@ class QDeclarativeDesignView;
class SelectionIndicator
{
public:
SelectionIndicator(QDeclarativeDesignView* editorView, LayerItem *layerItem);
SelectionIndicator(QDeclarativeDesignView* editorView, QGraphicsObject *layerItem);
~SelectionIndicator();
void show();
@@ -57,7 +57,7 @@ private:
private:
QHash<QGraphicsItem*, QGraphicsPolygonItem *> m_indicatorShapeHash;
QWeakPointer<LayerItem> m_layerItem;
QWeakPointer<QGraphicsObject> m_layerItem;
QDeclarativeDesignView *m_view;
};
@@ -45,7 +45,7 @@ public:
int type() const { return Constants::EditorItemType; }
};
SelectionRectangle::SelectionRectangle(LayerItem *layerItem)
SelectionRectangle::SelectionRectangle(QGraphicsObject *layerItem)
: m_controlShape(new SelectionRectShape(layerItem)),
m_layerItem(layerItem)
{
@@ -32,14 +32,14 @@
#include <QWeakPointer>
#include <QGraphicsRectItem>
#include "layeritem.h"
#include <QGraphicsObject>
namespace QmlViewer {
class SelectionRectangle
{
public:
SelectionRectangle(LayerItem *layerItem);
SelectionRectangle(QGraphicsObject *layerItem);
~SelectionRectangle();
void show();
@@ -54,7 +54,7 @@ public:
private:
QGraphicsRectItem *m_controlShape;
QWeakPointer<LayerItem> m_layerItem;
QWeakPointer<QGraphicsObject> m_layerItem;
};
}
@@ -32,6 +32,7 @@
#include <QWidget>
#include <QList>
#include "qmljsdebugger_global.h"
QT_FORWARD_DECLARE_CLASS(QResizeEvent);
@@ -39,7 +40,7 @@ namespace QmlViewer {
class CrumblePathButton;
class CrumblePath : public QWidget
class QMLJSDEBUGGER_EXPORT CrumblePath : public QWidget
{
Q_OBJECT
public:
@@ -60,13 +60,14 @@
#include <private/qdeclarativedebugservice_p.h>
#include <QtCore/QStringList>
#include "qmljsdebugger_global.h"
QT_BEGIN_NAMESPACE
class JSAgentWatchData;
class QScriptContext;
class JSDebuggerAgent : public QDeclarativeDebugService , public QScriptEngineAgent
class QMLJSDEBUGGER_EXPORT JSDebuggerAgent : public QDeclarativeDebugService , public QScriptEngineAgent
{ Q_OBJECT
public:
JSDebuggerAgent(QScriptEngine *engine);
@@ -44,6 +44,7 @@
#include <private/qdeclarativedebugservice_p.h>
#include "qmlviewerconstants.h"
#include "qmljsdebugger_global.h"
#include <QHash>
@@ -55,7 +56,7 @@ class QDeclarativeContext;
class QDeclarativeWatcher;
class QDataStream;
class QDeclarativeDesignDebugServer : public QDeclarativeDebugService
class QMLJSDEBUGGER_EXPORT QDeclarativeDesignDebugServer : public QDeclarativeDebugService
{
Q_OBJECT
public:
@@ -0,0 +1,141 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef QDECLARATIVEDESIGNVIEW_H
#define QDECLARATIVEDESIGNVIEW_H
#include "qmljsdebugger_global.h"
#include "qmlviewerconstants.h"
#include <qdeclarativeview.h>
#include <QWeakPointer>
QT_FORWARD_DECLARE_CLASS(QDeclarativeItem);
QT_FORWARD_DECLARE_CLASS(QMouseEvent);
QT_FORWARD_DECLARE_CLASS(QToolBar);
namespace QmlViewer {
class CrumblePath;
class QDeclarativeDesignViewPrivate;
class QMLJSDEBUGGER_EXPORT QDeclarativeDesignView : public QDeclarativeView
{
Q_OBJECT
public:
enum ContextFlags {
IgnoreContext,
ContextSensitive
};
explicit QDeclarativeDesignView(QWidget *parent = 0);
~QDeclarativeDesignView();
void setSelectedItems(QList<QGraphicsItem *> items);
QList<QGraphicsItem *> selectedItems();
QGraphicsObject *manipulatorLayer() const;
void changeTool(Constants::DesignTool tool,
Constants::ToolFlags flags = Constants::NoToolFlags);
void clearHighlight();
void highlight(QList<QGraphicsItem *> item, ContextFlags flags = ContextSensitive);
void highlight(QGraphicsItem *item, ContextFlags flags = ContextSensitive);
bool mouseInsideContextItem() const;
bool isEditorItem(QGraphicsItem *item) 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;
QGraphicsItem *currentRootItem() const;
CrumblePath *crumblePathWidget() const;
QToolBar *toolbar() const;
static QString idStringForObject(QObject *obj);
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
public Q_SLOTS:
void setDesignModeBehavior(bool value);
bool designModeBehavior() const;
void changeToSingleSelectTool();
void changeToMarqueeSelectTool();
void changeToZoomTool();
void changeToColorPickerTool();
void changeAnimationSpeed(qreal slowdownFactor);
void continueExecution(qreal slowdownFactor = 1.0f);
void pauseExecution();
Q_SIGNALS:
void designModeBehaviorChanged(bool inDesignMode);
void reloadRequested();
void marqueeSelectToolActivated();
void selectToolActivated();
void zoomToolActivated();
void colorPickerActivated();
void selectedColorChanged(const QColor &color);
void executionStarted(qreal slowdownFactor);
void executionPaused();
protected:
void leaveEvent(QEvent *);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *keyEvent);
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
private Q_SLOTS:
void reloadView();
void onStatusChanged(QDeclarativeView::Status status);
void onCurrentObjectsChanged(QList<QObject*> objects);
void applyChangesFromClient();
void createQmlObject(const QString &qml, QObject *parent,
const QStringList &imports, const QString &filename = QString());
private:
void clearEditorItems();
void createToolbar();
void changeToSelectTool();
QList<QGraphicsItem*> filterForCurrentContext(QList<QGraphicsItem*> &itemlist) const;
QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const;
QDeclarativeDesignViewPrivate *data;
private:
Q_DISABLE_COPY(QDeclarativeDesignView)
};
} //namespace QmlViewer
#endif // QDECLARATIVEDESIGNVIEW_H
@@ -0,0 +1,43 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef QMLJSDEBUGGER_GLOBAL_H
#define QMLJSDEBUGGER_GLOBAL_H
#include <QtCore/qglobal.h>
# if defined(BUILD_QMLJSDEBUGGER_LIB)
# define QMLJSDEBUGGER_EXPORT Q_DECL_EXPORT
# elif defined(BUILD_QMLJSDEBUGGER_STATIC_LIB)
# define QMLJSDEBUGGER_EXPORT
# else
# define QMLJSDEBUGGER_EXPORT Q_DECL_IMPORT
#endif
#endif // QMLJSDEBUGGER_GLOBAL_H
@@ -1,4 +1,5 @@
#include "qdeclarativedesignview.h"
#include "qdeclarativedesignview_p.h"
#include "qdeclarativedesigndebugserver.h"
#include "selectiontool.h"
#include "zoomtool.h"
@@ -25,23 +26,34 @@ namespace QmlViewer {
Q_GLOBAL_STATIC(QDeclarativeDesignDebugServer, qmlDesignDebugServer)
QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
QDeclarativeView(parent),
m_designModeBehavior(false),
m_executionPaused(false),
m_slowdownFactor(1.0f),
m_toolbar(0)
QDeclarativeDesignViewPrivate::QDeclarativeDesignViewPrivate() :
designModeBehavior(false),
executionPaused(false),
slowdownFactor(1.0f),
toolbar(0)
{
m_crumblePath = new CrumblePath(0);
m_manipulatorLayer = new LayerItem(scene());
m_selectionTool = new SelectionTool(this);
m_zoomTool = new ZoomTool(this);
m_colorPickerTool = new ColorPickerTool(this);
m_boundingRectHighlighter = new BoundingRectHighlighter(this);
m_subcomponentEditorTool = new SubcomponentEditorTool(this);
m_subcomponentEditorTool->setCrumblePathWidget(m_crumblePath);
m_currentTool = m_selectionTool;
}
QDeclarativeDesignViewPrivate::~QDeclarativeDesignViewPrivate()
{
}
QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
QDeclarativeView(parent)
{
data = new QDeclarativeDesignViewPrivate;
data->crumblePath = new CrumblePath(0);
data->manipulatorLayer = new LayerItem(scene());
data->selectionTool = new SelectionTool(this);
data->zoomTool = new ZoomTool(this);
data->colorPickerTool = new ColorPickerTool(this);
data->boundingRectHighlighter = new BoundingRectHighlighter(this);
data->subcomponentEditorTool = new SubcomponentEditorTool(this);
data->subcomponentEditorTool->setCrumblePathWidget(data->crumblePath);
data->currentTool = data->selectionTool;
setMouseTracking(true);
@@ -61,8 +73,8 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
connect(this, SIGNAL(statusChanged(QDeclarativeView::Status)), SLOT(onStatusChanged(QDeclarativeView::Status)));
connect(m_colorPickerTool, SIGNAL(selectedColorChanged(QColor)), SIGNAL(selectedColorChanged(QColor)));
connect(m_colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), SIGNAL(selectedColorChanged(QColor)));
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
qmlDesignDebugServer(), SLOT(selectedColorChanged(QColor)));
createToolbar();
@@ -74,7 +86,7 @@ QDeclarativeDesignView::~QDeclarativeDesignView()
void QDeclarativeDesignView::reloadView()
{
m_subcomponentEditorTool->clear();
data->subcomponentEditorTool->clear();
clearHighlight();
emit reloadRequested();
}
@@ -100,8 +112,8 @@ void QDeclarativeDesignView::mousePressEvent(QMouseEvent *event)
QDeclarativeView::mousePressEvent(event);
return;
}
m_cursorPos = event->pos();
m_currentTool->mousePressEvent(event);
data->cursorPos = event->pos();
data->currentTool->mousePressEvent(event);
}
void QDeclarativeDesignView::mouseMoveEvent(QMouseEvent *event)
@@ -111,7 +123,7 @@ void QDeclarativeDesignView::mouseMoveEvent(QMouseEvent *event)
QDeclarativeView::mouseMoveEvent(event);
return;
}
m_cursorPos = event->pos();
data->cursorPos = event->pos();
QList<QGraphicsItem*> selItems = selectableItems(event->pos());
if (!selItems.isEmpty()) {
@@ -120,11 +132,11 @@ void QDeclarativeDesignView::mouseMoveEvent(QMouseEvent *event)
setToolTip(QString());
}
if (event->buttons()) {
m_subcomponentEditorTool->mouseMoveEvent(event);
m_currentTool->mouseMoveEvent(event);
data->subcomponentEditorTool->mouseMoveEvent(event);
data->currentTool->mouseMoveEvent(event);
} else {
m_subcomponentEditorTool->hoverMoveEvent(event);
m_currentTool->hoverMoveEvent(event);
data->subcomponentEditorTool->hoverMoveEvent(event);
data->currentTool->hoverMoveEvent(event);
}
}
@@ -134,12 +146,12 @@ void QDeclarativeDesignView::mouseReleaseEvent(QMouseEvent *event)
QDeclarativeView::mouseReleaseEvent(event);
return;
}
m_subcomponentEditorTool->mouseReleaseEvent(event);
data->subcomponentEditorTool->mouseReleaseEvent(event);
m_cursorPos = event->pos();
m_currentTool->mouseReleaseEvent(event);
data->cursorPos = event->pos();
data->currentTool->mouseReleaseEvent(event);
qmlDesignDebugServer()->setCurrentObjects(AbstractFormEditorTool::toObjectList(selectedItems()));
//qmlDesignDebugServer()->setCurrentObjects(AbstractFormEditorTool::toObjectList(selectedItems()));
}
void QDeclarativeDesignView::keyPressEvent(QKeyEvent *event)
@@ -148,7 +160,7 @@ void QDeclarativeDesignView::keyPressEvent(QKeyEvent *event)
QDeclarativeView::keyPressEvent(event);
return;
}
m_currentTool->keyPressEvent(event);
data->currentTool->keyPressEvent(event);
}
void QDeclarativeDesignView::keyReleaseEvent(QKeyEvent *event)
@@ -174,11 +186,11 @@ void QDeclarativeDesignView::keyReleaseEvent(QKeyEvent *event)
case Qt::Key_Enter:
case Qt::Key_Return:
if (!selectedItems().isEmpty())
m_subcomponentEditorTool->setCurrentItem(selectedItems().first());
data->subcomponentEditorTool->setCurrentItem(selectedItems().first());
break;
case Qt::Key_Space:
if (m_executionPaused) {
continueExecution(m_slowdownFactor);
if (data->executionPaused) {
continueExecution(data->slowdownFactor);
} else {
pauseExecution();
}
@@ -187,7 +199,7 @@ void QDeclarativeDesignView::keyReleaseEvent(QKeyEvent *event)
break;
}
m_currentTool->keyReleaseEvent(event);
data->currentTool->keyReleaseEvent(event);
}
void QDeclarativeDesignView::createQmlObject(const QString &qml, QObject *parent, const QStringList &importList, const QString &filename)
@@ -218,7 +230,7 @@ void QDeclarativeDesignView::createQmlObject(const QString &qml, QObject *parent
QGraphicsItem *QDeclarativeDesignView::currentRootItem() const
{
return m_subcomponentEditorTool->currentRootItem();
return data->subcomponentEditorTool->currentRootItem();
}
void QDeclarativeDesignView::mouseDoubleClickEvent(QMouseEvent *event)
@@ -238,10 +250,10 @@ void QDeclarativeDesignView::mouseDoubleClickEvent(QMouseEvent *event)
}
if (itemToEnter)
itemToEnter = m_subcomponentEditorTool->firstChildOfContext(itemToEnter);
itemToEnter = data->subcomponentEditorTool->firstChildOfContext(itemToEnter);
m_subcomponentEditorTool->setCurrentItem(itemToEnter);
m_subcomponentEditorTool->mouseDoubleClickEvent(event);
data->subcomponentEditorTool->setCurrentItem(itemToEnter);
data->subcomponentEditorTool->mouseDoubleClickEvent(event);
if ((event->buttons() & Qt::LeftButton) && itemToEnter) {
QGraphicsObject *objectToEnter = itemToEnter->toGraphicsObject();
@@ -252,37 +264,37 @@ void QDeclarativeDesignView::mouseDoubleClickEvent(QMouseEvent *event)
}
void QDeclarativeDesignView::wheelEvent(QWheelEvent *event)
{
if (!m_designModeBehavior) {
if (!data->designModeBehavior) {
QDeclarativeView::wheelEvent(event);
return;
}
m_currentTool->wheelEvent(event);
data->currentTool->wheelEvent(event);
}
void QDeclarativeDesignView::setDesignModeBehavior(bool value)
{
emit designModeBehaviorChanged(value);
m_toolbar->setDesignModeBehavior(value);
data->toolbar->setDesignModeBehavior(value);
qmlDesignDebugServer()->setDesignModeBehavior(value);
m_designModeBehavior = value;
if (m_subcomponentEditorTool) {
m_subcomponentEditorTool->clear();
data->designModeBehavior = value;
if (data->subcomponentEditorTool) {
data->subcomponentEditorTool->clear();
clearHighlight();
setSelectedItems(QList<QGraphicsItem*>());
if (rootObject())
m_subcomponentEditorTool->pushContext(rootObject());
data->subcomponentEditorTool->pushContext(rootObject());
}
if (!m_designModeBehavior)
if (!data->designModeBehavior)
clearEditorItems();
}
bool QDeclarativeDesignView::designModeBehavior() const
{
return m_designModeBehavior;
return data->designModeBehavior;
}
void QDeclarativeDesignView::changeTool(Constants::DesignTool tool, Constants::ToolFlags /*flags*/)
@@ -293,30 +305,30 @@ void QDeclarativeDesignView::changeTool(Constants::DesignTool tool, Constants::T
break;
case Constants::NoTool:
default:
m_currentTool = 0;
data->currentTool = 0;
break;
}
}
void QDeclarativeDesignView::setSelectedItems(QList<QGraphicsItem *> items)
{
m_currentSelection.clear();
data->currentSelection.clear();
foreach(QGraphicsItem *item, items) {
if (item) {
QGraphicsObject *obj = item->toGraphicsObject();
if (obj)
m_currentSelection << obj;
data->currentSelection << obj;
}
}
m_currentTool->updateSelectedItems();
data->currentTool->updateSelectedItems();
}
QList<QGraphicsItem *> QDeclarativeDesignView::selectedItems()
{
QList<QGraphicsItem *> selection;
foreach(const QWeakPointer<QGraphicsObject> &selectedObject, m_currentSelection) {
foreach(const QWeakPointer<QGraphicsObject> &selectedObject, data->currentSelection) {
if (selectedObject.isNull()) {
m_currentSelection.removeOne(selectedObject);
data->currentSelection.removeOne(selectedObject);
} else {
selection << selectedObject.data();
}
@@ -325,14 +337,9 @@ QList<QGraphicsItem *> QDeclarativeDesignView::selectedItems()
return selection;
}
AbstractFormEditorTool *QDeclarativeDesignView::currentTool() const
{
return m_currentTool;
}
void QDeclarativeDesignView::clearHighlight()
{
m_boundingRectHighlighter->clear();
data->boundingRectHighlighter->clear();
}
void QDeclarativeDesignView::highlight(QGraphicsItem * item, ContextFlags flags)
@@ -349,7 +356,7 @@ void QDeclarativeDesignView::highlight(QList<QGraphicsItem *> items, ContextFlag
foreach(QGraphicsItem *item, items) {
QGraphicsItem *child = item;
if (flags & ContextSensitive)
child = m_subcomponentEditorTool->firstChildOfContext(item);
child = data->subcomponentEditorTool->firstChildOfContext(item);
if (child) {
QGraphicsObject *childObject = child->toGraphicsObject();
@@ -358,12 +365,12 @@ void QDeclarativeDesignView::highlight(QList<QGraphicsItem *> items, ContextFlag
}
}
m_boundingRectHighlighter->highlight(objectList);
data->boundingRectHighlighter->highlight(objectList);
}
bool QDeclarativeDesignView::mouseInsideContextItem() const
{
return m_subcomponentEditorTool->containsCursor(m_cursorPos.toPoint());
return data->subcomponentEditorTool->containsCursor(data->cursorPos.toPoint());
}
QList<QGraphicsItem*> QDeclarativeDesignView::selectableItems(const QPointF &scenePos) const
@@ -387,8 +394,8 @@ QList<QGraphicsItem*> QDeclarativeDesignView::selectableItems(const QRectF &scen
void QDeclarativeDesignView::changeToSingleSelectTool()
{
m_currentToolMode = Constants::SelectionToolMode;
m_selectionTool->setRubberbandSelectionMode(false);
data->currentToolMode = Constants::SelectionToolMode;
data->selectionTool->setRubberbandSelectionMode(false);
changeToSelectTool();
@@ -398,20 +405,20 @@ void QDeclarativeDesignView::changeToSingleSelectTool()
void QDeclarativeDesignView::changeToSelectTool()
{
if (m_currentTool == m_selectionTool)
if (data->currentTool == data->selectionTool)
return;
m_currentTool->clear();
m_currentTool = m_selectionTool;
m_currentTool->clear();
m_currentTool->updateSelectedItems();
data->currentTool->clear();
data->currentTool = data->selectionTool;
data->currentTool->clear();
data->currentTool->updateSelectedItems();
}
void QDeclarativeDesignView::changeToMarqueeSelectTool()
{
changeToSelectTool();
m_currentToolMode = Constants::MarqueeSelectionToolMode;
m_selectionTool->setRubberbandSelectionMode(true);
data->currentToolMode = Constants::MarqueeSelectionToolMode;
data->selectionTool->setRubberbandSelectionMode(true);
emit marqueeSelectToolActivated();
qmlDesignDebugServer()->setCurrentTool(Constants::MarqueeSelectionToolMode);
@@ -419,10 +426,10 @@ void QDeclarativeDesignView::changeToMarqueeSelectTool()
void QDeclarativeDesignView::changeToZoomTool()
{
m_currentToolMode = Constants::ZoomMode;
m_currentTool->clear();
m_currentTool = m_zoomTool;
m_currentTool->clear();
data->currentToolMode = Constants::ZoomMode;
data->currentTool->clear();
data->currentTool = data->zoomTool;
data->currentTool->clear();
emit zoomToolActivated();
qmlDesignDebugServer()->setCurrentTool(Constants::ZoomMode);
@@ -430,13 +437,13 @@ void QDeclarativeDesignView::changeToZoomTool()
void QDeclarativeDesignView::changeToColorPickerTool()
{
if (m_currentTool == m_colorPickerTool)
if (data->currentTool == data->colorPickerTool)
return;
m_currentToolMode = Constants::ColorPickerMode;
m_currentTool->clear();
m_currentTool = m_colorPickerTool;
m_currentTool->clear();
data->currentToolMode = Constants::ColorPickerMode;
data->currentTool->clear();
data->currentTool = data->colorPickerTool;
data->currentTool->clear();
emit colorPickerActivated();
qmlDesignDebugServer()->setCurrentTool(Constants::ColorPickerMode);
@@ -444,10 +451,10 @@ void QDeclarativeDesignView::changeToColorPickerTool()
void QDeclarativeDesignView::changeAnimationSpeed(qreal slowdownFactor)
{
m_slowdownFactor = slowdownFactor;
data->slowdownFactor = slowdownFactor;
if (m_slowdownFactor != 0) {
continueExecution(m_slowdownFactor);
if (data->slowdownFactor != 0) {
continueExecution(data->slowdownFactor);
} else {
pauseExecution();
}
@@ -457,17 +464,17 @@ void QDeclarativeDesignView::continueExecution(qreal slowdownFactor)
{
Q_ASSERT(slowdownFactor > 0);
m_slowdownFactor = slowdownFactor;
data->slowdownFactor = slowdownFactor;
static const qreal animSpeedSnapDelta = 0.01f;
bool useStandardSpeed = (qAbs(1.0f - m_slowdownFactor) < animSpeedSnapDelta);
bool useStandardSpeed = (qAbs(1.0f - data->slowdownFactor) < animSpeedSnapDelta);
QUnifiedTimer *timer = QUnifiedTimer::instance();
timer->setSlowdownFactor(m_slowdownFactor);
timer->setSlowdownFactor(data->slowdownFactor);
timer->setSlowModeEnabled(!useStandardSpeed);
m_executionPaused = false;
data->executionPaused = false;
emit executionStarted(m_slowdownFactor);
qmlDesignDebugServer()->setAnimationSpeed(m_slowdownFactor);
emit executionStarted(data->slowdownFactor);
qmlDesignDebugServer()->setAnimationSpeed(data->slowdownFactor);
}
void QDeclarativeDesignView::pauseExecution()
@@ -475,7 +482,7 @@ void QDeclarativeDesignView::pauseExecution()
QUnifiedTimer *timer = QUnifiedTimer::instance();
timer->setSlowdownFactor(0);
timer->setSlowModeEnabled(true);
m_executionPaused = true;
data->executionPaused = true;
emit executionPaused();
qmlDesignDebugServer()->setAnimationSpeed(0);
@@ -486,15 +493,15 @@ void QDeclarativeDesignView::applyChangesFromClient()
}
LayerItem *QDeclarativeDesignView::manipulatorLayer() const
QGraphicsObject *QDeclarativeDesignView::manipulatorLayer() const
{
return m_manipulatorLayer;
return data->manipulatorLayer;
}
QList<QGraphicsItem*> QDeclarativeDesignView::filterForSelection(QList<QGraphicsItem*> &itemlist) const
{
foreach(QGraphicsItem *item, itemlist) {
if (isEditorItem(item) || !m_subcomponentEditorTool->isChildOfContext(item))
if (isEditorItem(item) || !data->subcomponentEditorTool->isChildOfContext(item))
itemlist.removeOne(item);
}
@@ -505,10 +512,10 @@ QList<QGraphicsItem*> QDeclarativeDesignView::filterForCurrentContext(QList<QGra
{
foreach(QGraphicsItem *item, itemlist) {
if (isEditorItem(item) || !m_subcomponentEditorTool->isDirectChildOfContext(item)) {
if (isEditorItem(item) || !data->subcomponentEditorTool->isDirectChildOfContext(item)) {
// if we're a child, but not directly, replace with the parent that is directly in context.
if (QGraphicsItem *contextParent = m_subcomponentEditorTool->firstChildOfContext(item)) {
if (QGraphicsItem *contextParent = data->subcomponentEditorTool->firstChildOfContext(item)) {
if (contextParent != item) {
if (itemlist.contains(contextParent)) {
itemlist.removeOne(item);
@@ -536,7 +543,7 @@ void QDeclarativeDesignView::onStatusChanged(QDeclarativeView::Status status)
{
if (status == QDeclarativeView::Ready) {
if (rootObject()) {
m_subcomponentEditorTool->pushContext(rootObject());
data->subcomponentEditorTool->pushContext(rootObject());
emit executionStarted(1.0f);
}
qmlDesignDebugServer()->reloaded();
@@ -588,44 +595,44 @@ QRectF QDeclarativeDesignView::adjustToScreenBoundaries(const QRectF &boundingRe
CrumblePath *QDeclarativeDesignView::crumblePathWidget() const
{
return m_crumblePath;
return data->crumblePath;
}
QToolBar *QDeclarativeDesignView::toolbar() const
{
return m_toolbar;
return data->toolbar;
}
void QDeclarativeDesignView::createToolbar()
{
m_toolbar = new QmlToolbar(this);
connect(this, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setColorBoxColor(QColor)));
data->toolbar = new QmlToolbar(this);
connect(this, SIGNAL(selectedColorChanged(QColor)), data->toolbar, SLOT(setColorBoxColor(QColor)));
connect(this, SIGNAL(designModeBehaviorChanged(bool)), m_toolbar, SLOT(setDesignModeBehavior(bool)));
connect(this, SIGNAL(designModeBehaviorChanged(bool)), data->toolbar, SLOT(setDesignModeBehavior(bool)));
connect(m_toolbar, SIGNAL(designModeBehaviorChanged(bool)), this, SLOT(setDesignModeBehavior(bool)));
connect(m_toolbar, SIGNAL(executionStarted()), this, SLOT(continueExecution()));
connect(m_toolbar, SIGNAL(executionPaused()), this, SLOT(pauseExecution()));
connect(m_toolbar, SIGNAL(colorPickerSelected()), this, SLOT(changeToColorPickerTool()));
connect(m_toolbar, SIGNAL(zoomToolSelected()), this, SLOT(changeToZoomTool()));
connect(m_toolbar, SIGNAL(selectToolSelected()), this, SLOT(changeToSingleSelectTool()));
connect(m_toolbar, SIGNAL(marqueeSelectToolSelected()), this, SLOT(changeToMarqueeSelectTool()));
connect(data->toolbar, SIGNAL(designModeBehaviorChanged(bool)), this, SLOT(setDesignModeBehavior(bool)));
connect(data->toolbar, SIGNAL(executionStarted()), this, SLOT(continueExecution()));
connect(data->toolbar, SIGNAL(executionPaused()), this, SLOT(pauseExecution()));
connect(data->toolbar, SIGNAL(colorPickerSelected()), this, SLOT(changeToColorPickerTool()));
connect(data->toolbar, SIGNAL(zoomToolSelected()), this, SLOT(changeToZoomTool()));
connect(data->toolbar, SIGNAL(selectToolSelected()), this, SLOT(changeToSingleSelectTool()));
connect(data->toolbar, SIGNAL(marqueeSelectToolSelected()), this, SLOT(changeToMarqueeSelectTool()));
connect(m_toolbar, SIGNAL(applyChangesFromQmlFileSelected()), SLOT(applyChangesFromClient()));
connect(data->toolbar, SIGNAL(applyChangesFromQmlFileSelected()), SLOT(applyChangesFromClient()));
connect(this, SIGNAL(executionStarted(qreal)), m_toolbar, SLOT(startExecution()));
connect(this, SIGNAL(executionPaused()), m_toolbar, SLOT(pauseExecution()));
connect(this, SIGNAL(executionStarted(qreal)), data->toolbar, SLOT(startExecution()));
connect(this, SIGNAL(executionPaused()), data->toolbar, SLOT(pauseExecution()));
connect(this, SIGNAL(selectToolActivated()), m_toolbar, SLOT(activateSelectTool()));
connect(this, SIGNAL(selectToolActivated()), data->toolbar, SLOT(activateSelectTool()));
// disabled features
//connect(m_toolbar, SIGNAL(applyChangesToQmlFileSelected()), SLOT(applyChangesToClient()));
//connect(this, SIGNAL(resizeToolActivated()), m_toolbar, SLOT(activateSelectTool()));
//connect(this, SIGNAL(moveToolActivated()), m_toolbar, SLOT(activateSelectTool()));
//connect(d->m_toolbar, SIGNAL(applyChangesToQmlFileSelected()), SLOT(applyChangesToClient()));
//connect(this, SIGNAL(resizeToolActivated()), d->m_toolbar, SLOT(activateSelectTool()));
//connect(this, SIGNAL(moveToolActivated()), d->m_toolbar, SLOT(activateSelectTool()));
connect(this, SIGNAL(colorPickerActivated()), m_toolbar, SLOT(activateColorPicker()));
connect(this, SIGNAL(zoomToolActivated()), m_toolbar, SLOT(activateZoom()));
connect(this, SIGNAL(marqueeSelectToolActivated()), m_toolbar, SLOT(activateMarqueeSelectTool()));
connect(this, SIGNAL(colorPickerActivated()), data->toolbar, SLOT(activateColorPicker()));
connect(this, SIGNAL(zoomToolActivated()), data->toolbar, SLOT(activateZoom()));
connect(this, SIGNAL(marqueeSelectToolActivated()), data->toolbar, SLOT(activateMarqueeSelectTool()));
}
} //namespace QmlViewer
@@ -0,0 +1,82 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef QDECLARATIVEDESIGNVIEW_P_H
#define QDECLARATIVEDESIGNVIEW_P_H
#include <QWeakPointer>
#include <QPointF>
namespace QmlViewer {
class QDeclarativeDesignView;
class SelectionTool;
class ZoomTool;
class ColorPickerTool;
class LayerItem;
class BoundingRectHighlighter;
class SubcomponentEditorTool;
class QmlToolbar;
class CrumblePath;
class AbstractFormEditorTool;
class QDeclarativeDesignViewPrivate
{
public:
QDeclarativeDesignViewPrivate();
~QDeclarativeDesignViewPrivate();
QPointF cursorPos;
QList<QWeakPointer<QGraphicsObject> > currentSelection;
Constants::DesignTool currentToolMode;
AbstractFormEditorTool *currentTool;
SelectionTool *selectionTool;
ZoomTool *zoomTool;
ColorPickerTool *colorPickerTool;
SubcomponentEditorTool *subcomponentEditorTool;
LayerItem *manipulatorLayer;
BoundingRectHighlighter *boundingRectHighlighter;
bool designModeBehavior;
bool executionPaused;
qreal slowdownFactor;
QmlToolbar *toolbar;
CrumblePath *crumblePath;
};
} // namespace QmlViewer
#endif // QDECLARATIVEDESIGNVIEW_P_H
@@ -0,0 +1,32 @@
QT += declarative
INCLUDEPATH += $$PWD $$PWD/include editor
DEPENDPATH += $$PWD $$PWD/include editor
contains(CONFIG, dll) {
DEFINES += BUILD_QMLJSDEBUGGER_LIB
} else {
DEFINES += BUILD_QMLJSDEBUGGER_STATIC_LIB
}
## Once is not enough
include($$PWD/../../private_headers.pri)
include($$PWD/../../private_headers.pri)
include($$PWD/editor/editor.pri)
## Input
HEADERS += \
include/jsdebuggeragent.h \
include/qdeclarativedesignview.h \
include/qdeclarativedesigndebugserver.h \
include/crumblepath.h \
include/qmlviewerconstants.h \
include/qmljsdebugger_global.h \
qdeclarativedesignview_p.h
SOURCES += \
jsdebuggeragent.cpp \
qdeclarativedesignview.cpp \
qdeclarativedesigndebugserver.cpp
OTHER_FILES += qmljsdebugger.pri
+5
View File
@@ -0,0 +1,5 @@
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD $$PWD/include $$PWD/editor
QT += declarative
LIBS *= -l$$qtLibraryTarget(QmlJSDebugger)
+8
View File
@@ -0,0 +1,8 @@
TEMPLATE = lib
CONFIG+=dll
TARGET = QmlJSDebugger
unix:QMAKE_CXXFLAGS_DEBUG += -O3
include(../../qtcreatorlibrary.pri)
include(qmljsdebugger-lib.pri)
+4 -11
View File
@@ -1,33 +1,26 @@
QT += declarative script network sql
contains(QT_CONFIG, opengl) {
QT += opengl
DEFINES += GL_SUPPORTED
}
include($$PWD/editor/editor.pri)
INCLUDEPATH += $$PWD
HEADERS += $$PWD/qmlruntime.h \
$$PWD/proxysettings.h \
$$PWD/qdeclarativetester.h \
$$PWD/deviceorientation.h \
$$PWD/loggerwidget.h \
$$PWD/qdeclarativedesigndebugserver.h \
$$PWD/qdeclarativedesignview.h \
$$PWD/jsdebuggeragent.h
$$PWD/loggerwidget.h
SOURCES += $$PWD/qmlruntime.cpp \
$$PWD/proxysettings.cpp \
$$PWD/qdeclarativetester.cpp \
$$PWD/loggerwidget.cpp \
$$PWD/qdeclarativedesigndebugserver.cpp \
$$PWD/qdeclarativedesignview.cpp \
$$PWD/jsdebuggeragent.cpp
$$PWD/loggerwidget.cpp
RESOURCES += $$PWD/qmlruntime.qrc
maemo5 {
QT += dbus
HEADERS += $$PWD/texteditautoresizer_maemo5.h
@@ -5,6 +5,7 @@ include(qml.pri)
SOURCES += main.cpp
include(../../../libs/qmljsdebugger/qmljsdebugger.pri)
include(../../../../qtcreator.pri)
include(../../../private_headers.pri)
DESTDIR = $$IDE_BIN_PATH
+3 -2
View File
@@ -54,8 +54,9 @@
# include "ui_recopts.h"
#endif
#include "qdeclarativedesignview.h"
#include "crumblepath.h"
#include <qdeclarativedesignview.h>
#include <crumblepath.h>
#include "qmlruntime.h"
#include <qdeclarativecontext.h>
#include <qdeclarativeengine.h>