tizen beta release
[profile/ivi/webkit-efl.git] / Tools / QtTestBrowser / launcherwindow.h
1 /*
2  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
3  * Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
4  * Copyright (C) 2006 George Staikos <staikos@kde.org>
5  * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
6  * Copyright (C) 2006 Zack Rusin <zack@kde.org>
7  * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
8  *
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
21  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef launcherwindow_h
34 #define launcherwindow_h
35
36 #include <QtNetwork/QNetworkRequest>
37
38 #ifndef QT_NO_OPENGL
39 #include <QtOpenGL/QGLWidget>
40 #endif
41
42 #if !defined(QT_NO_PRINTER)
43 #include <QPrintPreviewDialog>
44 #endif
45
46 #ifndef QT_NO_UITOOLS
47 #include <QtUiTools/QUiLoader>
48 #endif
49
50 #include <QDebug>
51
52 #include <cstdio>
53 #include <qevent.h>
54 #include <qwebelement.h>
55 #include <qwebframe.h>
56 #include <qwebinspector.h>
57 #include <qwebsettings.h>
58
59 #include "DumpRenderTreeSupportQt.h"
60 #include "mainwindow.h"
61 #include "urlloader.h"
62 #include "utils.h"
63 #include "webinspector.h"
64 #include "webpage.h"
65 #include "webview.h"
66
67 class QPropertyAnimation;
68
69 class WindowOptions {
70 public:
71     WindowOptions()
72         : useGraphicsView(false)
73         , useDiskCache(false)
74         , useCompositing(true)
75         , useTiledBackingStore(false)
76         , useWebGL(false)
77         , useFrameFlattening(false)
78         , cacheWebView(false)
79         , showFrameRate(false)
80         , resizesToContents(false)
81         , viewportUpdateMode(QGraphicsView::MinimalViewportUpdate)
82         , useLocalStorage(false)
83         , useOfflineStorageDatabase(false)
84         , useOfflineWebApplicationCache(false)
85         , useDiskCookies(true)
86         , offlineStorageDefaultQuotaSize(0)
87 #ifndef QT_NO_OPENGL
88         , useQGLWidgetViewport(false)
89 #endif
90 #if defined(Q_WS_X11)
91         , useTestFonts(false)
92 #endif
93         , printLoadedUrls(false)
94         , startMaximized(false)
95     {
96     }
97
98     bool useGraphicsView;
99     bool useDiskCache;
100     bool useCompositing;
101     bool useTiledBackingStore;
102     bool useWebGL;
103     bool useFrameFlattening;
104     bool cacheWebView;
105     bool showFrameRate;
106     bool resizesToContents;
107     QGraphicsView::ViewportUpdateMode viewportUpdateMode;
108     bool useLocalStorage;
109     bool useOfflineStorageDatabase;
110     bool useOfflineWebApplicationCache;
111     bool useDiskCookies;
112     quint64 offlineStorageDefaultQuotaSize;
113 #ifndef QT_NO_OPENGL
114     bool useQGLWidgetViewport;
115 #endif
116 #if defined(Q_WS_X11)
117     bool useTestFonts;
118 #endif
119     bool printLoadedUrls;
120     QUrl inspectorUrl;
121     quint16 remoteInspectorPort;
122     bool startMaximized;
123 };
124
125 class LauncherWindow : public MainWindow {
126     Q_OBJECT
127
128 public:
129     LauncherWindow(WindowOptions* data = 0, QGraphicsScene* sharedScene = 0);
130     virtual ~LauncherWindow();
131
132     void sendTouchEvent();
133
134     bool eventFilter(QObject* obj, QEvent* event);
135
136 protected slots:
137     void loadStarted();
138     void loadFinished();
139
140     void showLinkHover(const QString &link, const QString &toolTip);
141
142     void zoomIn();
143     void zoomOut();
144     void resetZoom();
145     void toggleZoomTextOnly(bool on);
146     void zoomAnimationFinished();
147
148     void print();
149     void screenshot();
150
151     void setEditable(bool on);
152
153     /* void dumpPlugins() */
154     void dumpHtml();
155
156     void loadURLListFromFile();
157
158     void setDiskCache(bool enable);
159     void setTouchMocking(bool on);
160     void toggleWebView(bool graphicsBased);
161     void toggleAcceleratedCompositing(bool toggle);
162     void toggleTiledBackingStore(bool toggle);
163     void toggleResizesToContents(bool toggle);
164     void toggleWebGL(bool toggle);
165     void toggleSpatialNavigation(bool b);
166     void toggleFullScreenMode(bool enable);
167     void toggleFrameFlattening(bool toggle);
168     void toggleInterruptingJavaScriptEnabled(bool enable);
169     void toggleJavascriptCanOpenWindows(bool enable);
170     void toggleAutoLoadImages(bool enable);
171     void setUseDiskCookies(bool enable);
172     void clearCookies();
173     void togglePlugins(bool enable);
174     void toggleLocalStorage(bool toggle);
175     void toggleOfflineStorageDatabase(bool toggle);
176     void toggleOfflineWebApplicationCache(bool toggle);
177     void setOfflineStorageDefaultQuota();
178 #ifndef QT_NO_LINEEDIT
179     void showFindBar();
180     void find(int mode);
181 #endif
182 #ifndef QT_NO_OPENGL
183     void toggleQGLWidgetViewport(bool enable);
184 #endif
185
186     void changeViewportUpdateMode(int mode);
187     void animatedFlip();
188     void animatedYFlip();
189     void selectElements();
190     void showFPS(bool enable);
191     void showUserAgentDialog();
192
193     void printURL(const QUrl&);
194 #if !defined(QT_NO_FILEDIALOG) && !defined(QT_NO_MESSAGEBOX)
195     void downloadRequest(const QNetworkRequest&);
196     void fileDownloadFinished();
197 #endif
198
199 public slots:
200     LauncherWindow* newWindow();
201     LauncherWindow* cloneWindow();
202     void updateFPS(int fps);
203
204 signals:
205     void enteredFullScreenMode(bool on);
206
207 private:
208     void init();
209     void initializeView();
210     void createChrome();
211     void applyPrefs();
212     void applyZoom();
213
214     bool isGraphicsBased() const;
215
216 private:
217     static QVector<int> m_zoomLevels;
218     int m_currentZoom;
219
220     UrlLoader* m_urlLoader;
221
222     QWidget* m_view;
223     WebInspector* m_inspector;
224
225     WindowOptions m_windowOptions;
226
227     QAction* m_formatMenuAction;
228
229     QPropertyAnimation* m_zoomAnimation;
230 #if !defined(QT_NO_FILEDIALOG) && !defined(QT_NO_MESSAGEBOX)
231     QNetworkReply* m_reply;
232 #endif
233     QList<QTouchEvent::TouchPoint> m_touchPoints;
234     bool m_touchMocking;
235
236     QString m_inputUrl;
237 #ifndef QT_NO_LINEEDIT
238     QToolBar* m_findBar;
239     QLineEdit* m_lineEdit;
240     int m_findFlag;
241     static const int s_findNormalFlag = 0;
242 #endif
243 };
244
245 #endif