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 <QtGui> |
|
37 #include <QtNetwork/QNetworkRequest> |
|
38 |
|
39 #if defined(QT_CONFIGURED_WITH_OPENGL) |
|
40 #include <QtOpenGL/QGLWidget> |
|
41 #endif |
|
42 |
|
43 #if !defined(QT_NO_PRINTER) |
|
44 #include <QPrintPreviewDialog> |
|
45 #endif |
|
46 |
|
47 #ifndef QT_NO_UITOOLS |
|
48 #include <QtUiTools/QUiLoader> |
|
49 #endif |
|
50 |
|
51 #include <QDebug> |
|
52 |
|
53 #include <cstdio> |
|
54 #include <qevent.h> |
|
55 #include <qwebelement.h> |
|
56 #include <qwebframe.h> |
|
57 #include <qwebinspector.h> |
|
58 #include <qwebsettings.h> |
|
59 |
|
60 #ifdef Q_WS_MAEMO_5 |
|
61 #include <qx11info_x11.h> |
|
62 #endif |
|
63 |
|
64 #include "mainwindow.h" |
|
65 #include "urlloader.h" |
|
66 #include "utils.h" |
|
67 #include "webinspector.h" |
|
68 #include "webpage.h" |
|
69 #include "webview.h" |
|
70 #include "../../WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h" |
|
71 |
|
72 #ifdef Q_WS_MAEMO_5 |
|
73 #include <X11/Xatom.h> |
|
74 #include <X11/Xlib.h> |
|
75 #undef KeyPress |
|
76 #endif |
|
77 |
|
78 class WindowOptions { |
|
79 public: |
|
80 WindowOptions() |
|
81 : useGraphicsView(false) |
|
82 , useCompositing(true) |
|
83 , useTiledBackingStore(false) |
|
84 , useWebGL(false) |
|
85 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_S60) |
|
86 , useFrameFlattening(true) |
|
87 #else |
|
88 , useFrameFlattening(false) |
|
89 #endif |
|
90 , cacheWebView(false) |
|
91 , showFrameRate(false) |
|
92 , resizesToContents(false) |
|
93 , viewportUpdateMode(QGraphicsView::MinimalViewportUpdate) |
|
94 #if defined(QT_CONFIGURED_WITH_OPENGL) |
|
95 , useQGLWidgetViewport(false) |
|
96 #endif |
|
97 { |
|
98 } |
|
99 |
|
100 bool useGraphicsView; |
|
101 bool useCompositing; |
|
102 bool useTiledBackingStore; |
|
103 bool useWebGL; |
|
104 bool useFrameFlattening; |
|
105 bool cacheWebView; |
|
106 bool showFrameRate; |
|
107 bool resizesToContents; |
|
108 QGraphicsView::ViewportUpdateMode viewportUpdateMode; |
|
109 #if defined(QT_CONFIGURED_WITH_OPENGL) |
|
110 bool useQGLWidgetViewport; |
|
111 #endif |
|
112 QUrl inspectorUrl; |
|
113 }; |
|
114 |
|
115 class LauncherWindow : public MainWindow { |
|
116 Q_OBJECT |
|
117 |
|
118 public: |
|
119 LauncherWindow(WindowOptions* data = 0, QGraphicsScene* sharedScene = 0); |
|
120 virtual ~LauncherWindow(); |
|
121 |
|
122 virtual void keyPressEvent(QKeyEvent* event); |
|
123 void grabZoomKeys(bool grab); |
|
124 |
|
125 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) |
|
126 void sendTouchEvent(); |
|
127 #endif |
|
128 |
|
129 bool eventFilter(QObject* obj, QEvent* event); |
|
130 |
|
131 protected slots: |
|
132 void loadStarted(); |
|
133 void loadFinished(); |
|
134 |
|
135 void showLinkHover(const QString &link, const QString &toolTip); |
|
136 |
|
137 void zoomIn(); |
|
138 void zoomOut(); |
|
139 void resetZoom(); |
|
140 void toggleZoomTextOnly(bool on); |
|
141 void zoomAnimationFinished(); |
|
142 |
|
143 void print(); |
|
144 void screenshot(); |
|
145 |
|
146 void setEditable(bool on); |
|
147 |
|
148 /* void dumpPlugins() */ |
|
149 void dumpHtml(); |
|
150 |
|
151 void initializeView(); |
|
152 |
|
153 void setTouchMocking(bool on); |
|
154 void toggleAcceleratedCompositing(bool toggle); |
|
155 void toggleTiledBackingStore(bool toggle); |
|
156 void toggleResizesToContents(bool toggle); |
|
157 void toggleWebGL(bool toggle); |
|
158 void toggleSpatialNavigation(bool b); |
|
159 void toggleFullScreenMode(bool enable); |
|
160 void toggleFrameFlattening(bool toggle); |
|
161 void toggleInterruptingJavaScriptEnabled(bool enable); |
|
162 void toggleJavascriptCanOpenWindows(bool enable); |
|
163 |
|
164 #if defined(QT_CONFIGURED_WITH_OPENGL) |
|
165 void toggleQGLWidgetViewport(bool enable); |
|
166 #endif |
|
167 |
|
168 void changeViewportUpdateMode(int mode); |
|
169 void selectElements(); |
|
170 void showFPS(bool enable); |
|
171 void showUserAgentDialog(); |
|
172 |
|
173 public slots: |
|
174 LauncherWindow* newWindow(); |
|
175 LauncherWindow* cloneWindow(); |
|
176 void updateFPS(int fps); |
|
177 |
|
178 signals: |
|
179 void enteredFullScreenMode(bool on); |
|
180 |
|
181 private: |
|
182 void init(); |
|
183 bool isGraphicsBased() const; |
|
184 void createChrome(); |
|
185 void applyPrefs(); |
|
186 void applyZoom(); |
|
187 |
|
188 private: |
|
189 static QVector<int> m_zoomLevels; |
|
190 int m_currentZoom; |
|
191 |
|
192 QWidget* m_view; |
|
193 WebInspector* m_inspector; |
|
194 |
|
195 WindowOptions m_windowOptions; |
|
196 |
|
197 QAction* m_formatMenuAction; |
|
198 |
|
199 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) |
|
200 QPropertyAnimation* m_zoomAnimation; |
|
201 QList<QTouchEvent::TouchPoint> m_touchPoints; |
|
202 bool m_touchMocking; |
|
203 #endif |
|
204 }; |
|
205 |
|
206 #endif |
|