1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef ABSTRACTVIEWINSPECTOR_H
43 #define ABSTRACTVIEWINSPECTOR_H
45 #include <QtCore/QHash>
46 #include <QtCore/QObject>
47 #include <QtCore/QStringList>
48 #include <QtGui/QColor>
50 #include "qdeclarativeinspectorprotocol.h"
51 #include "qmlinspectorconstants.h"
54 class QDeclarativeEngine;
55 class QDeclarativeInspectorService;
61 namespace QmlJSDebugger {
66 * The common code between QQuickView and QDeclarativeView inspectors lives here,
68 class AbstractViewInspector : public QObject
73 explicit AbstractViewInspector(QObject *parent = 0);
75 void createQmlObject(const QString &qml, QObject *parent,
76 const QStringList &importList,
77 const QString &filename = QString());
78 void clearComponentCache();
80 bool showAppOnTop() const { return m_showAppOnTop; }
81 bool designModeBehavior() const { return m_designModeBehavior; }
83 bool animationPaused() const { return m_animationPaused; }
84 qreal slowDownFactor() const { return m_slowDownFactor; }
86 void sendCurrentObjects(const QList<QObject*> &);
87 void sendAnimationSpeed(qreal slowDownFactor);
88 void sendAnimationPaused(bool paused);
89 void sendCurrentTool(Constants::DesignTool toolId);
91 void sendShowAppOnTop(bool showAppOnTop);
93 QString idStringForObject(QObject *obj) const;
95 virtual void changeCurrentObjects(const QList<QObject*> &objects) = 0;
96 virtual void reloadView() = 0;
97 virtual void reparentQmlObject(QObject *object, QObject *newParent) = 0;
98 virtual void changeTool(InspectorProtocol::Tool tool) = 0;
99 virtual Qt::WindowFlags windowFlags() const = 0;
100 virtual void setWindowFlags(Qt::WindowFlags flags) = 0;
101 virtual QDeclarativeEngine *declarativeEngine() const = 0;
104 void designModeBehaviorChanged(bool inDesignMode);
105 void showAppOnTopChanged(bool showAppOnTop);
106 void reloadRequested();
107 void marqueeSelectToolActivated();
108 void selectToolActivated();
109 void zoomToolActivated();
110 void colorPickerActivated();
111 void selectedColorChanged(const QColor &color);
113 void animationSpeedChanged(qreal factor);
114 void animationPausedChanged(bool paused);
117 AbstractTool *currentTool() const { return m_currentTool; }
118 void setCurrentTool(AbstractTool *tool) { m_currentTool = tool; }
119 bool eventFilter(QObject *, QEvent *);
121 virtual bool leaveEvent(QEvent *);
122 virtual bool mousePressEvent(QMouseEvent *event);
123 virtual bool mouseMoveEvent(QMouseEvent *event);
124 virtual bool mouseReleaseEvent(QMouseEvent *event);
125 virtual bool keyPressEvent(QKeyEvent *event);
126 virtual bool keyReleaseEvent(QKeyEvent *keyEvent);
127 virtual bool mouseDoubleClickEvent(QMouseEvent *event);
128 virtual bool wheelEvent(QWheelEvent *event);
131 void handleMessage(const QByteArray &message);
132 void sendColorChanged(const QColor &color);
135 void sendDesignModeBehavior(bool inDesignMode);
137 void changeToColorPickerTool();
138 void changeToZoomTool();
139 void changeToSingleSelectTool();
140 void changeToMarqueeSelectTool();
142 virtual void setDesignModeBehavior(bool value);
144 void setShowAppOnTop(bool appOnTop);
146 void setAnimationSpeed(qreal factor);
147 void setAnimationPaused(bool paused);
149 void animationSpeedChangeRequested(qreal factor);
150 void animationPausedChangeRequested(bool paused);
152 AbstractTool *m_currentTool;
155 bool m_designModeBehavior;
157 bool m_animationPaused;
158 qreal m_slowDownFactor;
160 QHash<int, QString> m_stringIdForObjectId;
161 QDeclarativeInspectorService *m_debugService;
164 } // namespace QmlJSDebugger
166 #endif // ABSTRACTVIEWINSPECTOR_H