Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / tools / qmlviewer / qmlruntime.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
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.
16 **
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.
20 **
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.
28 **
29 ** Other Usage
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.
32 **
33 **
34 **
35 **
36 **
37 **
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     void initialSizeChanged(QSize size);
116     bool open(const QString&);
117     void openFile();
118     void openUrl();
119     void reload();
120     void takeSnapShot();
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 &);
130
131 protected:
132     virtual void keyPressEvent(QKeyEvent *);
133     virtual bool event(QEvent *);
134     void createMenu();
135
136 private slots:
137     void appAboutToQuit();
138
139     void autoStartRecording();
140     void autoStopRecording();
141     void recordFrame();
142     void chooseRecordingOptions();
143     void pickRecordingFile();
144     void toggleFullScreen();
145     void changeOrientation(QAction*);
146     void orientationChanged();
147
148     void showWarnings(bool show);
149     void warningsWidgetOpened();
150     void warningsWidgetClosed();
151
152 private:
153     void updateSizeHints(bool initial = false);
154
155     QString getVideoFileName();
156
157     LoggerWidget *loggerWindow;
158     QDeclarativeView *canvas;
159     QSize initialSize;
160     QString currentFileOrUrl;
161     QTimer recordTimer;
162     QString frame_fmt;
163     QImage frame;
164     QList<QImage*> frames;
165     QProcess* frame_stream;
166     QTimer autoStartTimer;
167     QTimer autoStopTimer;
168     QString record_dither;
169     QString record_file;
170     QSize record_outsize;
171     QStringList record_args;
172     int record_rate;
173     int record_autotime;
174     bool devicemode;
175     QAction *recordAction;
176     RecordingDialog *recdlg;
177
178     void senseImageMagick();
179     void senseFfmpeg();
180     QWidget *ffmpegHelpWindow;
181     bool ffmpegAvailable;
182     bool convertAvailable;
183
184     QAction *rotateAction;
185     QActionGroup *orientation;
186     QAction *showWarningsWindow;
187
188     QString m_script;
189     ScriptOptions m_scriptOptions;
190     QDeclarativeTester *tester;
191
192     NetworkAccessManagerFactory *namFactory;
193
194     bool useQmlFileBrowser;
195
196     QTranslator *translator;
197     void loadTranslationFile(const QString& directory);
198
199     void loadDummyDataFiles(const QString& directory);
200 };
201 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)
202
203 QT_END_NAMESPACE
204
205 #endif