1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** 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 handleMessage(const QByteArray &message);
77 void createQmlObject(const QString &qml, QObject *parent,
78 const QStringList &importList,
79 const QString &filename = QString());
80 void clearComponentCache();
82 bool showAppOnTop() const { return m_showAppOnTop; }
83 bool designModeBehavior() const { return m_designModeBehavior; }
85 bool animationPaused() const { return m_animationPaused; }
86 qreal slowDownFactor() const { return m_slowDownFactor; }
88 void sendCurrentObjects(const QList<QObject*> &);
89 void sendAnimationSpeed(qreal slowDownFactor);
90 void sendAnimationPaused(bool paused);
91 void sendCurrentTool(Constants::DesignTool toolId);
93 void sendShowAppOnTop(bool showAppOnTop);
95 QString idStringForObject(QObject *obj) const;
97 virtual void changeCurrentObjects(const QList<QObject*> &objects) = 0;
98 virtual void reloadView() = 0;
99 virtual void reparentQmlObject(QObject *object, QObject *newParent) = 0;
100 virtual void changeTool(InspectorProtocol::Tool tool) = 0;
101 virtual Qt::WindowFlags windowFlags() const = 0;
102 virtual void setWindowFlags(Qt::WindowFlags flags) = 0;
103 virtual QDeclarativeEngine *declarativeEngine() const = 0;
106 void designModeBehaviorChanged(bool inDesignMode);
107 void showAppOnTopChanged(bool showAppOnTop);
108 void reloadRequested();
109 void marqueeSelectToolActivated();
110 void selectToolActivated();
111 void zoomToolActivated();
112 void colorPickerActivated();
113 void selectedColorChanged(const QColor &color);
115 void animationSpeedChanged(qreal factor);
116 void animationPausedChanged(bool paused);
119 AbstractTool *currentTool() const { return m_currentTool; }
120 void setCurrentTool(AbstractTool *tool) { m_currentTool = tool; }
121 bool eventFilter(QObject *, QEvent *);
123 virtual bool leaveEvent(QEvent *);
124 virtual bool mousePressEvent(QMouseEvent *event);
125 virtual bool mouseMoveEvent(QMouseEvent *event);
126 virtual bool mouseReleaseEvent(QMouseEvent *event);
127 virtual bool keyPressEvent(QKeyEvent *event);
128 virtual bool keyReleaseEvent(QKeyEvent *keyEvent);
129 virtual bool mouseDoubleClickEvent(QMouseEvent *event);
130 virtual bool wheelEvent(QWheelEvent *event);
133 void sendColorChanged(const QColor &color);
136 void sendDesignModeBehavior(bool inDesignMode);
138 void changeToColorPickerTool();
139 void changeToZoomTool();
140 void changeToSingleSelectTool();
141 void changeToMarqueeSelectTool();
143 virtual void setDesignModeBehavior(bool value);
145 void setShowAppOnTop(bool appOnTop);
147 void setAnimationSpeed(qreal factor);
148 void setAnimationPaused(bool paused);
150 void animationSpeedChangeRequested(qreal factor);
151 void animationPausedChangeRequested(bool paused);
153 AbstractTool *m_currentTool;
156 bool m_designModeBehavior;
158 bool m_animationPaused;
159 qreal m_slowDownFactor;
161 QHash<int, QString> m_stringIdForObjectId;
162 QDeclarativeInspectorService *m_debugService;
165 } // namespace QmlJSDebugger
167 #endif // ABSTRACTVIEWINSPECTOR_H