Fixed sometimes focus ring is hidden when context menu is shown by longTap
[framework/web/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 #include <QDebug>
47
48 #include <cstdio>
49 #include <qevent.h>
50 #include <qwebelement.h>
51 #include <qwebframe.h>
52 #include <qwebinspector.h>
53 #include <qwebsettings.h>
54
55 #include "mainwindow.h"
56 #include "urlloader.h"
57 #include "utils.h"
58 #include "webinspector.h"
59 #include "webpage.h"
60 #include "webview.h"
61
62 QT_BEGIN_NAMESPACE
63 class QPropertyAnimation;
64 class QLineEdit;
65 QT_END_NAMESPACE
66
67 class WindowOptions {
68 public:
69     WindowOptions()
70         : useGraphicsView(false)
71         , useDiskCache(false)
72         , useCompositing(true)
73         , useTiledBackingStore(false)
74         , useWebGL(false)
75         , useFrameFlattening(false)
76         , cacheWebView(false)
77         , showFrameRate(false)
78         , resizesToContents(false)
79         , viewportUpdateMode(QGraphicsView::MinimalViewportUpdate)
80         , useLocalStorage(false)
81         , useOfflineStorageDatabase(false)
82         , useOfflineWebApplicationCache(false)
83         , useDiskCookies(true)
84         , offlineStorageDefaultQuotaSize(0)
85 #ifndef QT_NO_OPENGL
86         , useQGLWidgetViewport(false)
87 #endif
88         , printLoadedUrls(false)
89         , startMaximized(false)
90     {
91     }
92
93     bool useGraphicsView;
94     bool useDiskCache;
95     bool useCompositing;
96     bool useTiledBackingStore;
97     bool useWebGL;
98     bool useFrameFlattening;
99     bool cacheWebView;
100     bool showFrameRate;
101     bool resizesToContents;
102     QGraphicsView::ViewportUpdateMode viewportUpdateMode;
103     bool useLocalStorage;
104     bool useOfflineStorageDatabase;
105     bool useOfflineWebApplicationCache;
106     bool useDiskCookies;
107     quint64 offlineStorageDefaultQuotaSize;
108 #ifndef QT_NO_OPENGL
109     bool useQGLWidgetViewport;
110 #endif
111     bool printLoadedUrls;
112     QUrl inspectorUrl;
113     quint16 remoteInspectorPort;
114     bool startMaximized;
115 };
116
117 class LauncherWindow : public MainWindow {
118     Q_OBJECT
119
120 public:
121     LauncherWindow(WindowOptions* data = 0, QGraphicsScene* sharedScene = 0);
122     virtual ~LauncherWindow();
123
124     void sendTouchEvent();
125
126     bool eventFilter(QObject* obj, QEvent* event);
127
128 protected slots:
129     void loadStarted();
130     void loadFinished();
131
132     void showLinkHover(const QString &link, const QString &toolTip);
133
134     void zoomIn();
135     void zoomOut();
136     void resetZoom();
137     void toggleZoomTextOnly(bool on);
138     void zoomAnimationFinished();
139
140     void print();
141     void screenshot();
142
143     void setEditable(bool on);
144
145     /* void dumpPlugins() */
146     void dumpHtml();
147
148     void loadURLListFromFile();
149
150     void setDiskCache(bool enable);
151     void setTouchMocking(bool on);
152     void toggleWebView(bool graphicsBased);
153     void toggleAcceleratedCompositing(bool toggle);
154     void toggleTiledBackingStore(bool toggle);
155     void toggleResizesToContents(bool toggle);
156     void toggleWebGL(bool toggle);
157     void toggleSpatialNavigation(bool b);
158     void toggleFullScreenMode(bool enable);
159     void toggleFrameFlattening(bool toggle);
160     void toggleInterruptingJavaScriptEnabled(bool enable);
161     void toggleJavascriptCanOpenWindows(bool enable);
162     void toggleAutoLoadImages(bool enable);
163     void setUseDiskCookies(bool enable);
164     void clearCookies();
165     void togglePlugins(bool enable);
166     void toggleLocalStorage(bool toggle);
167     void toggleOfflineStorageDatabase(bool toggle);
168     void toggleOfflineWebApplicationCache(bool toggle);
169     void setOfflineStorageDefaultQuota();
170 #ifndef QT_NO_LINEEDIT
171     void showFindBar();
172     void find(int mode);
173 #endif
174 #ifndef QT_NO_OPENGL
175     void toggleQGLWidgetViewport(bool enable);
176 #endif
177
178     void changeViewportUpdateMode(int mode);
179     void animatedFlip();
180     void animatedYFlip();
181     void selectElements();
182     void showFPS(bool enable);
183     void showUserAgentDialog();
184
185     void printURL(const QUrl&);
186 #if !defined(QT_NO_FILEDIALOG) && !defined(QT_NO_MESSAGEBOX)
187     void downloadRequest(const QNetworkRequest&);
188     void fileDownloadFinished();
189 #endif
190
191 public slots:
192     LauncherWindow* newWindow();
193     LauncherWindow* cloneWindow();
194     void updateFPS(int fps);
195
196 signals:
197     void enteredFullScreenMode(bool on);
198
199 private:
200     void init();
201     void initializeView();
202     void createChrome();
203     void applyPrefs();
204     void applyZoom();
205
206     bool isGraphicsBased() const;
207
208 private:
209     static QVector<int> m_zoomLevels;
210     int m_currentZoom;
211
212     UrlLoader* m_urlLoader;
213
214     QWidget* m_view;
215     WebInspector* m_inspector;
216
217     WindowOptions m_windowOptions;
218
219     QAction* m_formatMenuAction;
220
221     QPropertyAnimation* m_zoomAnimation;
222 #if !defined(QT_NO_FILEDIALOG) && !defined(QT_NO_MESSAGEBOX)
223     QNetworkReply* m_reply;
224 #endif
225     QList<QTouchEvent::TouchPoint> m_touchPoints;
226     bool m_touchMocking;
227
228     QString m_inputUrl;
229 #ifndef QT_NO_LINEEDIT
230     QToolBar* m_findBar;
231     QLineEdit* m_lineEdit;
232     int m_findFlag;
233     static const int s_findNormalFlag = 0;
234 #endif
235 };
236
237 #endif