1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
9 ** 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 file.
14 ** Please review the following information to ensure the GNU Lesser General
15 ** 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.
24 ** Alternatively, this file may be used in accordance with the terms and
25 ** conditions contained in a signed written agreement between you and Nokia.
27 ** If you have questions regarding the use of this file, please contact
28 ** Nokia at qt-info@nokia.com.
30 **************************************************************************/
32 #ifndef QDECLARATIVEVIEWER_H
33 #define QDECLARATIVEVIEWER_H
35 #include <QtGui/QMainWindow>
36 #include <QtCore/QTimer>
37 #include <QtCore/QTime>
38 #include <QtCore/QList>
40 #include "loggerwidget.h"
42 namespace QmlJSDebugger {
43 class QDeclarativeViewObserver;
48 class QDeclarativeView;
49 class PreviewDeviceSkin;
50 class QDeclarativeTestEngine;
52 class RecordingDialog;
53 class QDeclarativeTester;
55 class QNetworkCookieJar;
56 class NetworkAccessManagerFactory;
61 class QDeclarativeViewer
67 QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
68 ~QDeclarativeViewer();
70 static void registerTypes();
75 TestImages = 0x00000004,
76 TestErrorProperty = 0x00000008,
77 SaveOnExit = 0x00000010,
78 ExitOnComplete = 0x00000020,
79 ExitOnFailure = 0x00000040,
80 Snapshot = 0x00000080,
81 TestSkipProperty = 0x00000100
83 Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
84 void setScript(const QString &s) { m_script = s; }
85 void setScriptOptions(ScriptOptions opt) { m_scriptOptions = opt; }
86 void setRecordDither(const QString& s) { record_dither = s; }
87 void setRecordRate(int fps);
88 void setRecordFile(const QString&);
89 void setRecordArgs(const QStringList&);
90 void setRecording(bool on);
91 bool isRecording() const { return recordTimer.isActive(); }
92 void setAutoRecord(int from, int to);
93 void setDeviceKeys(bool);
94 void setNetworkCacheSize(int size);
95 void addLibraryPath(const QString& lib);
96 void addPluginPath(const QString& plugin);
97 void setUseGL(bool use);
98 void setUseNativeFileBrowser(bool);
99 void setSizeToView(bool sizeToView);
100 void setStayOnTop(bool stayOnTop);
102 QDeclarativeView *view() const;
103 LoggerWidget *warningsWidget() const;
104 QString currentFile() const { return currentFileOrUrl; }
106 void enableExperimentalGestures();
109 void setDesignModeBehavior(bool value);
110 void sceneResized(QSize size);
111 bool open(const QString&);
116 void toggleRecording();
117 void toggleRecordingWithSelection();
118 void ffmpegFinished(int code);
119 void showProxySettings ();
120 void proxySettingsChanged ();
121 void rotateOrientation();
122 void statusChanged();
123 void pauseAnimations();
124 void stepAnimations();
125 void setAnimationStep();
126 void changeAnimationSpeed();
127 void launch(const QString &);
130 virtual void keyPressEvent(QKeyEvent *);
131 virtual bool event(QEvent *);
135 void appAboutToQuit();
137 void autoStartRecording();
138 void autoStopRecording();
140 void chooseRecordingOptions();
141 void pickRecordingFile();
142 void toggleFullScreen();
143 void changeOrientation(QAction*);
144 void orientationChanged();
146 void animationSpeedChanged(qreal factor);
148 void showWarnings(bool show);
149 void warningsWidgetOpened();
150 void warningsWidgetClosed();
153 void updateSizeHints(bool initial = false);
155 QString getVideoFileName();
157 LoggerWidget *loggerWindow;
158 QDeclarativeView *canvas;
159 QmlJSDebugger::QDeclarativeViewObserver *observer;
161 QString currentFileOrUrl;
165 QList<QImage*> frames;
166 QProcess* frame_stream;
167 QTimer autoStartTimer;
168 QTimer autoStopTimer;
169 QString record_dither;
171 QSize record_outsize;
172 QStringList record_args;
176 QAction *recordAction;
177 RecordingDialog *recdlg;
179 void senseImageMagick();
181 QWidget *ffmpegHelpWindow;
182 bool ffmpegAvailable;
183 bool convertAvailable;
186 QActionGroup *playSpeedMenuActions;
187 QAction *pauseAnimationsAction;
188 QAction *animationStepAction;
189 QAction *animationSetStepAction;
191 QAction *rotateAction;
192 QActionGroup *orientation;
193 QAction *showWarningsWindow;
194 QAction *designModeBehaviorAction;
195 QAction *appOnTopAction;
198 ScriptOptions m_scriptOptions;
199 QDeclarativeTester *tester;
201 QNetworkReply *wgtreply;
203 NetworkAccessManagerFactory *namFactory;
205 bool useQmlFileBrowser;
207 QTranslator *translator;
208 void loadTranslationFile(const QString& directory);
210 void loadDummyDataFiles(const QString& directory);
212 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)