OSDN Git Service

efd4a3ef077cd2449c45d2a01c517a11604f04f4
[qt-creator-jp/qt-creator-jp.git] / share / qtcreator / qml / qmlobserver / qmlruntime.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the tools applications of the Qt Toolkit.
8 **
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
14 ** this package.
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 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QDECLARATIVEVIEWER_H
43 #define QDECLARATIVEVIEWER_H
44
45 #include <QtGui/QMainWindow>
46 #include <QtCore/QTimer>
47 #include <QtCore/QTime>
48 #include <QtCore/QList>
49
50 #include "loggerwidget.h"
51
52 namespace QmlJSDebugger {
53     class QDeclarativeViewObserver;
54 }
55
56 QT_BEGIN_NAMESPACE
57
58 class QDeclarativeView;
59 class PreviewDeviceSkin;
60 class QDeclarativeTestEngine;
61 class QProcess;
62 class RecordingDialog;
63 class QDeclarativeTester;
64 class QNetworkReply;
65 class QNetworkCookieJar;
66 class NetworkAccessManagerFactory;
67 class QTranslator;
68 class QActionGroup;
69 class QMenuBar;
70
71 class QDeclarativeViewer
72     : public QMainWindow
73 {
74     Q_OBJECT
75
76 public:
77     QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
78     ~QDeclarativeViewer();
79
80     static void registerTypes();
81
82     enum ScriptOption {
83         Play = 0x00000001,
84         Record = 0x00000002,
85         TestImages = 0x00000004,
86         TestErrorProperty = 0x00000008,
87         SaveOnExit = 0x00000010,
88         ExitOnComplete = 0x00000020,
89         ExitOnFailure = 0x00000040,
90         Snapshot = 0x00000080,
91         TestSkipProperty = 0x00000100
92     };
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);
111
112     QDeclarativeView *view() const;
113     LoggerWidget *warningsWidget() const;
114     QString currentFile() const { return currentFileOrUrl; }
115
116     void enableExperimentalGestures();
117
118 public slots:
119     void setDesignModeBehavior(bool value);
120     void sceneResized(QSize size);
121     bool open(const QString&);
122     void openFile();
123     void openUrl();
124     void reload();
125     void takeSnapShot();
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 &);
138
139 protected:
140     virtual void keyPressEvent(QKeyEvent *);
141     virtual bool event(QEvent *);
142     void createMenu();
143
144 private slots:
145     void appAboutToQuit();
146
147     void autoStartRecording();
148     void autoStopRecording();
149     void recordFrame();
150     void chooseRecordingOptions();
151     void pickRecordingFile();
152     void toggleFullScreen();
153     void changeOrientation(QAction*);
154     void orientationChanged();
155
156     void animationSpeedChanged(qreal factor);
157
158     void showWarnings(bool show);
159     void warningsWidgetOpened();
160     void warningsWidgetClosed();
161
162 private:
163     void updateSizeHints(bool initial = false);
164
165     QString getVideoFileName();
166
167     LoggerWidget *loggerWindow;
168     QDeclarativeView *canvas;
169     QmlJSDebugger::QDeclarativeViewObserver *observer;
170     QSize initialSize;
171     QString currentFileOrUrl;
172     QTimer recordTimer;
173     QString frame_fmt;
174     QImage frame;
175     QList<QImage*> frames;
176     QProcess* frame_stream;
177     QTimer autoStartTimer;
178     QTimer autoStopTimer;
179     QString record_dither;
180     QString record_file;
181     QSize record_outsize;
182     QStringList record_args;
183     int record_rate;
184     int record_autotime;
185     bool devicemode;
186     QAction *recordAction;
187     RecordingDialog *recdlg;
188
189     void senseImageMagick();
190     void senseFfmpeg();
191     QWidget *ffmpegHelpWindow;
192     bool ffmpegAvailable;
193     bool convertAvailable;
194
195     int m_stepSize;
196     QActionGroup *playSpeedMenuActions;
197     QAction *pauseAnimationsAction;
198     QAction *animationStepAction;
199     QAction *animationSetStepAction;
200
201     QAction *rotateAction;
202     QActionGroup *orientation;
203     QAction *showWarningsWindow;
204     QAction *designModeBehaviorAction;
205     QAction *appOnTopAction;
206
207     QString m_script;
208     ScriptOptions m_scriptOptions;
209     QDeclarativeTester *tester;
210
211     QNetworkReply *wgtreply;
212     QString wgtdir;
213     NetworkAccessManagerFactory *namFactory;
214
215     bool useQmlFileBrowser;
216
217     QTranslator *translator;
218     void loadTranslationFile(const QString& directory);
219
220     void loadDummyDataFiles(const QString& directory);
221 };
222 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)
223
224 QT_END_NAMESPACE
225
226 #endif