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 tools applications of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEVIEWER_H
43 #define QDECLARATIVEVIEWER_H
45 #include <QtGui/QMainWindow>
46 #include <QtCore/QTimer>
47 #include <QtCore/QTime>
48 #include <QtCore/QList>
50 #include "loggerwidget.h"
52 namespace QmlJSDebugger {
53 class QDeclarativeViewObserver;
58 class QDeclarativeView;
59 class PreviewDeviceSkin;
60 class QDeclarativeTestEngine;
62 class RecordingDialog;
63 class QDeclarativeTester;
65 class QNetworkCookieJar;
66 class NetworkAccessManagerFactory;
71 class QDeclarativeViewer
77 QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
78 ~QDeclarativeViewer();
80 static void registerTypes();
85 TestImages = 0x00000004,
86 TestErrorProperty = 0x00000008,
87 SaveOnExit = 0x00000010,
88 ExitOnComplete = 0x00000020,
89 ExitOnFailure = 0x00000040,
90 Snapshot = 0x00000080,
91 TestSkipProperty = 0x00000100
93 Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
94 void setScript(const QString &s) { m_script = s; }
95 void setScriptOptions(ScriptOptions opt) { m_scriptOptions = opt; }
96 void setRecordDither(const QString& s) { record_dither = s; }
97 void setRecordRate(int fps);
98 void setRecordFile(const QString&);
99 void setRecordArgs(const QStringList&);
100 void setRecording(bool on);
101 bool isRecording() const { return recordTimer.isActive(); }
102 void setAutoRecord(int from, int to);
103 void setDeviceKeys(bool);
104 void setNetworkCacheSize(int size);
105 void addLibraryPath(const QString& lib);
106 void addPluginPath(const QString& plugin);
107 void setUseGL(bool use);
108 void setUseNativeFileBrowser(bool);
109 void setSizeToView(bool sizeToView);
110 void setStayOnTop(bool stayOnTop);
112 QDeclarativeView *view() const;
113 LoggerWidget *warningsWidget() const;
114 QString currentFile() const { return currentFileOrUrl; }
116 void enableExperimentalGestures();
119 void setDesignModeBehavior(bool value);
120 void sceneResized(QSize size);
121 bool open(const QString&);
126 void toggleRecording();
127 void toggleRecordingWithSelection();
128 void ffmpegFinished(int code);
129 void showProxySettings ();
130 void proxySettingsChanged ();
131 void rotateOrientation();
132 void statusChanged();
133 void pauseAnimations();
134 void stepAnimations();
135 void setAnimationStep();
136 void changeAnimationSpeed();
137 void launch(const QString &);
140 virtual void keyPressEvent(QKeyEvent *);
141 virtual bool event(QEvent *);
145 void appAboutToQuit();
147 void autoStartRecording();
148 void autoStopRecording();
150 void chooseRecordingOptions();
151 void pickRecordingFile();
152 void toggleFullScreen();
153 void changeOrientation(QAction*);
154 void orientationChanged();
156 void animationSpeedChanged(qreal factor);
158 void showWarnings(bool show);
159 void warningsWidgetOpened();
160 void warningsWidgetClosed();
163 void updateSizeHints(bool initial = false);
165 QString getVideoFileName();
167 LoggerWidget *loggerWindow;
168 QDeclarativeView *canvas;
169 QmlJSDebugger::QDeclarativeViewObserver *observer;
171 QString currentFileOrUrl;
175 QList<QImage*> frames;
176 QProcess* frame_stream;
177 QTimer autoStartTimer;
178 QTimer autoStopTimer;
179 QString record_dither;
181 QSize record_outsize;
182 QStringList record_args;
186 QAction *recordAction;
187 RecordingDialog *recdlg;
189 void senseImageMagick();
191 QWidget *ffmpegHelpWindow;
192 bool ffmpegAvailable;
193 bool convertAvailable;
196 QActionGroup *playSpeedMenuActions;
197 QAction *pauseAnimationsAction;
198 QAction *animationStepAction;
199 QAction *animationSetStepAction;
201 QAction *rotateAction;
202 QActionGroup *orientation;
203 QAction *showWarningsWindow;
204 QAction *designModeBehaviorAction;
205 QAction *appOnTopAction;
208 ScriptOptions m_scriptOptions;
209 QDeclarativeTester *tester;
211 QNetworkReply *wgtreply;
213 NetworkAccessManagerFactory *namFactory;
215 bool useQmlFileBrowser;
217 QTranslator *translator;
218 void loadTranslationFile(const QString& directory);
220 void loadDummyDataFiles(const QString& directory);
222 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)