OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / share / qtcreator / qml / qmlobserver / qmlruntime.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 ** GNU Lesser General Public License Usage
10 **
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.
17 **
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.
21 **
22 ** Other Usage
23 **
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.
26 **
27 ** If you have questions regarding the use of this file, please contact
28 ** Nokia at qt-info@nokia.com.
29 **
30 **************************************************************************/
31
32 #ifndef QDECLARATIVEVIEWER_H
33 #define QDECLARATIVEVIEWER_H
34
35 #include <QtGui/QMainWindow>
36 #include <QtCore/QTimer>
37 #include <QtCore/QTime>
38 #include <QtCore/QList>
39
40 #include "loggerwidget.h"
41
42 namespace QmlJSDebugger {
43     class QDeclarativeViewObserver;
44 }
45
46 QT_BEGIN_NAMESPACE
47
48 class QDeclarativeView;
49 class PreviewDeviceSkin;
50 class QDeclarativeTestEngine;
51 class QProcess;
52 class RecordingDialog;
53 class QDeclarativeTester;
54 class QNetworkReply;
55 class QNetworkCookieJar;
56 class NetworkAccessManagerFactory;
57 class QTranslator;
58 class QActionGroup;
59 class QMenuBar;
60
61 class QDeclarativeViewer
62     : public QMainWindow
63 {
64     Q_OBJECT
65
66 public:
67     QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
68     ~QDeclarativeViewer();
69
70     static void registerTypes();
71
72     enum ScriptOption {
73         Play = 0x00000001,
74         Record = 0x00000002,
75         TestImages = 0x00000004,
76         TestErrorProperty = 0x00000008,
77         SaveOnExit = 0x00000010,
78         ExitOnComplete = 0x00000020,
79         ExitOnFailure = 0x00000040,
80         Snapshot = 0x00000080,
81         TestSkipProperty = 0x00000100
82     };
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);
101
102     QDeclarativeView *view() const;
103     LoggerWidget *warningsWidget() const;
104     QString currentFile() const { return currentFileOrUrl; }
105
106     void enableExperimentalGestures();
107
108 public slots:
109     void setDesignModeBehavior(bool value);
110     void sceneResized(QSize size);
111     bool open(const QString&);
112     void openFile();
113     void openUrl();
114     void reload();
115     void takeSnapShot();
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 &);
128
129 protected:
130     virtual void keyPressEvent(QKeyEvent *);
131     virtual bool event(QEvent *);
132     void createMenu();
133
134 private slots:
135     void appAboutToQuit();
136
137     void autoStartRecording();
138     void autoStopRecording();
139     void recordFrame();
140     void chooseRecordingOptions();
141     void pickRecordingFile();
142     void toggleFullScreen();
143     void changeOrientation(QAction*);
144     void orientationChanged();
145
146     void animationSpeedChanged(qreal factor);
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     QmlJSDebugger::QDeclarativeViewObserver *observer;
160     QSize initialSize;
161     QString currentFileOrUrl;
162     QTimer recordTimer;
163     QString frame_fmt;
164     QImage frame;
165     QList<QImage*> frames;
166     QProcess* frame_stream;
167     QTimer autoStartTimer;
168     QTimer autoStopTimer;
169     QString record_dither;
170     QString record_file;
171     QSize record_outsize;
172     QStringList record_args;
173     int record_rate;
174     int record_autotime;
175     bool devicemode;
176     QAction *recordAction;
177     RecordingDialog *recdlg;
178
179     void senseImageMagick();
180     void senseFfmpeg();
181     QWidget *ffmpegHelpWindow;
182     bool ffmpegAvailable;
183     bool convertAvailable;
184
185     int m_stepSize;
186     QActionGroup *playSpeedMenuActions;
187     QAction *pauseAnimationsAction;
188     QAction *animationStepAction;
189     QAction *animationSetStepAction;
190
191     QAction *rotateAction;
192     QActionGroup *orientation;
193     QAction *showWarningsWindow;
194     QAction *designModeBehaviorAction;
195     QAction *appOnTopAction;
196
197     QString m_script;
198     ScriptOptions m_scriptOptions;
199     QDeclarativeTester *tester;
200
201     QNetworkReply *wgtreply;
202     QString wgtdir;
203     NetworkAccessManagerFactory *namFactory;
204
205     bool useQmlFileBrowser;
206
207     QTranslator *translator;
208     void loadTranslationFile(const QString& directory);
209
210     void loadDummyDataFiles(const QString& directory);
211 };
212 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)
213
214 QT_END_NAMESPACE
215
216 #endif