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 ** 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 QDECLARATIVEVIEWER_H
43 #define QDECLARATIVEVIEWER_H
45 #include <QMainWindow>
50 #include "loggerwidget.h"
54 class QDeclarativeView;
55 class PreviewDeviceSkin;
56 class QDeclarativeTestEngine;
58 class RecordingDialog;
59 class QDeclarativeTester;
61 class QNetworkCookieJar;
62 class NetworkAccessManagerFactory;
67 class QDeclarativeViewer
73 QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
74 ~QDeclarativeViewer();
76 static void registerTypes();
81 TestImages = 0x00000004,
82 TestErrorProperty = 0x00000008,
83 SaveOnExit = 0x00000010,
84 ExitOnComplete = 0x00000020,
85 ExitOnFailure = 0x00000040,
86 Snapshot = 0x00000080,
87 TestSkipProperty = 0x00000100
89 Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
90 void setScript(const QString &s) { m_script = s; }
91 void setScriptOptions(ScriptOptions opt) { m_scriptOptions = opt; }
92 void setRecordDither(const QString& s) { record_dither = s; }
93 void setRecordRate(int fps);
94 void setRecordFile(const QString&);
95 void setRecordArgs(const QStringList&);
96 void setRecording(bool on);
97 bool isRecording() const { return recordTimer.isActive(); }
98 void setAutoRecord(int from, int to);
99 void setDeviceKeys(bool);
100 void setNetworkCacheSize(int size);
101 void addLibraryPath(const QString& lib);
102 void addPluginPath(const QString& plugin);
103 void setUseGL(bool use);
104 void setUseNativeFileBrowser(bool);
105 void setSizeToView(bool sizeToView);
107 QDeclarativeView *view() const;
108 LoggerWidget *warningsWidget() const;
109 QString currentFile() const { return currentFileOrUrl; }
111 void enableExperimentalGestures();
114 void sceneResized(QSize size);
115 void initialSizeChanged(QSize size);
116 bool open(const QString&);
121 void toggleRecording();
122 void toggleRecordingWithSelection();
123 void ffmpegFinished(int code);
124 void showProxySettings ();
125 void proxySettingsChanged ();
126 void rotateOrientation();
127 void statusChanged();
128 void setSlowMode(bool);
129 void launch(const QString &);
132 virtual void keyPressEvent(QKeyEvent *);
133 virtual bool event(QEvent *);
137 void appAboutToQuit();
139 void autoStartRecording();
140 void autoStopRecording();
142 void chooseRecordingOptions();
143 void pickRecordingFile();
144 void toggleFullScreen();
145 void changeOrientation(QAction*);
146 void orientationChanged();
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;
160 QString currentFileOrUrl;
164 QList<QImage*> frames;
165 QProcess* frame_stream;
166 QTimer autoStartTimer;
167 QTimer autoStopTimer;
168 QString record_dither;
170 QSize record_outsize;
171 QStringList record_args;
175 QAction *recordAction;
176 RecordingDialog *recdlg;
178 void senseImageMagick();
180 QWidget *ffmpegHelpWindow;
181 bool ffmpegAvailable;
182 bool convertAvailable;
184 QAction *rotateAction;
185 QActionGroup *orientation;
186 QAction *showWarningsWindow;
189 ScriptOptions m_scriptOptions;
190 QDeclarativeTester *tester;
192 NetworkAccessManagerFactory *namFactory;
194 bool useQmlFileBrowser;
196 QTranslator *translator;
197 void loadTranslationFile(const QString& directory);
199 void loadDummyDataFiles(const QString& directory);
201 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)