1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
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.
|
---|
23 | **
|
---|
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.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QDECLARATIVEVIEWER_H
|
---|
43 | #define QDECLARATIVEVIEWER_H
|
---|
44 |
|
---|
45 | #include <QMainWindow>
|
---|
46 | #include <QTimer>
|
---|
47 | #include <QTime>
|
---|
48 | #include <QList>
|
---|
49 |
|
---|
50 | #include "loggerwidget.h"
|
---|
51 |
|
---|
52 | QT_BEGIN_NAMESPACE
|
---|
53 |
|
---|
54 | class QDeclarativeView;
|
---|
55 | class PreviewDeviceSkin;
|
---|
56 | class QDeclarativeTestEngine;
|
---|
57 | class QProcess;
|
---|
58 | class RecordingDialog;
|
---|
59 | class QDeclarativeTester;
|
---|
60 | class QNetworkReply;
|
---|
61 | class QNetworkCookieJar;
|
---|
62 | class NetworkAccessManagerFactory;
|
---|
63 | class QTranslator;
|
---|
64 | class QActionGroup;
|
---|
65 | class QMenuBar;
|
---|
66 |
|
---|
67 | class QDeclarativeViewer
|
---|
68 | : public QMainWindow
|
---|
69 | {
|
---|
70 | Q_OBJECT
|
---|
71 |
|
---|
72 | public:
|
---|
73 | QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
---|
74 | ~QDeclarativeViewer();
|
---|
75 |
|
---|
76 | static void registerTypes();
|
---|
77 |
|
---|
78 | enum ScriptOption {
|
---|
79 | Play = 0x00000001,
|
---|
80 | Record = 0x00000002,
|
---|
81 | TestImages = 0x00000004,
|
---|
82 | TestErrorProperty = 0x00000008,
|
---|
83 | SaveOnExit = 0x00000010,
|
---|
84 | ExitOnComplete = 0x00000020,
|
---|
85 | ExitOnFailure = 0x00000040,
|
---|
86 | Snapshot = 0x00000080,
|
---|
87 | TestSkipProperty = 0x00000100
|
---|
88 | };
|
---|
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);
|
---|
106 |
|
---|
107 | QDeclarativeView *view() const;
|
---|
108 | LoggerWidget *warningsWidget() const;
|
---|
109 | QString currentFile() const { return currentFileOrUrl; }
|
---|
110 |
|
---|
111 | void enableExperimentalGestures();
|
---|
112 |
|
---|
113 | public slots:
|
---|
114 | void sceneResized(QSize size);
|
---|
115 | bool open(const QString&);
|
---|
116 | void openFile();
|
---|
117 | void openUrl();
|
---|
118 | void reload();
|
---|
119 | void takeSnapShot();
|
---|
120 | void toggleRecording();
|
---|
121 | void toggleRecordingWithSelection();
|
---|
122 | void ffmpegFinished(int code);
|
---|
123 | void showProxySettings ();
|
---|
124 | void proxySettingsChanged ();
|
---|
125 | void rotateOrientation();
|
---|
126 | void statusChanged();
|
---|
127 | void setSlowMode(bool);
|
---|
128 | void launch(const QString &);
|
---|
129 |
|
---|
130 | protected:
|
---|
131 | virtual void keyPressEvent(QKeyEvent *);
|
---|
132 | virtual bool event(QEvent *);
|
---|
133 | void createMenu();
|
---|
134 |
|
---|
135 | private slots:
|
---|
136 | void appAboutToQuit();
|
---|
137 |
|
---|
138 | void autoStartRecording();
|
---|
139 | void autoStopRecording();
|
---|
140 | void recordFrame();
|
---|
141 | void chooseRecordingOptions();
|
---|
142 | void pickRecordingFile();
|
---|
143 | void toggleFullScreen();
|
---|
144 | void changeOrientation(QAction*);
|
---|
145 | void orientationChanged();
|
---|
146 |
|
---|
147 | void showWarnings(bool show);
|
---|
148 | void warningsWidgetOpened();
|
---|
149 | void warningsWidgetClosed();
|
---|
150 |
|
---|
151 | private:
|
---|
152 | void updateSizeHints(bool initial = false);
|
---|
153 |
|
---|
154 | QString getVideoFileName();
|
---|
155 |
|
---|
156 | LoggerWidget *loggerWindow;
|
---|
157 | QDeclarativeView *canvas;
|
---|
158 | QSize initialSize;
|
---|
159 | QString currentFileOrUrl;
|
---|
160 | QTimer recordTimer;
|
---|
161 | QString frame_fmt;
|
---|
162 | QImage frame;
|
---|
163 | QList<QImage*> frames;
|
---|
164 | QProcess* frame_stream;
|
---|
165 | QTimer autoStartTimer;
|
---|
166 | QTimer autoStopTimer;
|
---|
167 | QString record_dither;
|
---|
168 | QString record_file;
|
---|
169 | QSize record_outsize;
|
---|
170 | QStringList record_args;
|
---|
171 | int record_rate;
|
---|
172 | int record_autotime;
|
---|
173 | bool devicemode;
|
---|
174 | QAction *recordAction;
|
---|
175 | RecordingDialog *recdlg;
|
---|
176 |
|
---|
177 | void senseImageMagick();
|
---|
178 | void senseFfmpeg();
|
---|
179 | QWidget *ffmpegHelpWindow;
|
---|
180 | bool ffmpegAvailable;
|
---|
181 | bool convertAvailable;
|
---|
182 |
|
---|
183 | QAction *rotateAction;
|
---|
184 | QActionGroup *orientation;
|
---|
185 | QAction *showWarningsWindow;
|
---|
186 |
|
---|
187 | QString m_script;
|
---|
188 | ScriptOptions m_scriptOptions;
|
---|
189 | QDeclarativeTester *tester;
|
---|
190 |
|
---|
191 | NetworkAccessManagerFactory *namFactory;
|
---|
192 |
|
---|
193 | bool useQmlFileBrowser;
|
---|
194 |
|
---|
195 | QTranslator *translator;
|
---|
196 | void loadTranslationFile(const QString& directory);
|
---|
197 |
|
---|
198 | void loadDummyDataFiles(const QString& directory);
|
---|
199 | };
|
---|
200 | Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)
|
---|
201 |
|
---|
202 | QT_END_NAMESPACE
|
---|
203 |
|
---|
204 | #endif
|
---|