2
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
Boston, MA 02110-1301, USA.
20
#ifndef QGraphicsWebView_h
21
#define QGraphicsWebView_h
23
#include "qwebkitglobal.h"
25
#include <QtCore/qurl.h>
26
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
27
#include <QtWidgets/qgraphicswidget.h>
29
#include <QtGui/qgraphicswidget.h>
31
#include <QtGui/qevent.h>
32
#include <QtGui/qicon.h>
33
#include <QtGui/qpainter.h>
34
#include <QtNetwork/qnetworkaccessmanager.h>
36
#if !defined(QT_NO_GRAPHICSVIEW)
42
class QGraphicsWebViewPrivate;
44
class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget {
47
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
48
Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
49
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
51
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
53
Q_PROPERTY(bool modified READ isModified)
54
Q_PROPERTY(bool resizesToContents READ resizesToContents WRITE setResizesToContents)
55
Q_PROPERTY(bool tiledBackingStoreFrozen READ isTiledBackingStoreFrozen WRITE setTiledBackingStoreFrozen)
57
Q_PROPERTY(QPainter::RenderHints renderHints READ renderHints WRITE setRenderHints)
58
Q_FLAGS(QPainter::RenderHints)
61
explicit QGraphicsWebView(QGraphicsItem* parent = 0);
64
QWebPage* page() const;
65
void setPage(QWebPage*);
68
void setUrl(const QUrl&);
70
QString title() const;
73
qreal zoomFactor() const;
74
void setZoomFactor(qreal);
76
bool isModified() const;
78
void load(const QUrl& url);
79
void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray& body = QByteArray());
81
void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
82
// FIXME: Consider rename to setHtml?
83
void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl());
85
QWebHistory* history() const;
86
QWebSettings* settings() const;
88
QAction* pageAction(QWebPage::WebAction action) const;
89
void triggerPageAction(QWebPage::WebAction action, bool checked = false);
91
bool findText(const QString& subString, QWebPage::FindFlags options = 0);
93
bool resizesToContents() const;
94
void setResizesToContents(bool enabled);
96
bool isTiledBackingStoreFrozen() const;
97
void setTiledBackingStoreFrozen(bool frozen);
99
virtual void setGeometry(const QRectF& rect);
100
virtual void updateGeometry();
101
virtual void paint(QPainter*, const QStyleOptionGraphicsItem* options, QWidget* widget = 0);
102
virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
103
virtual bool event(QEvent*);
105
virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint) const;
107
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
109
QPainter::RenderHints renderHints() const;
110
void setRenderHints(QPainter::RenderHints);
111
void setRenderHint(QPainter::RenderHint, bool enabled = true);
121
void loadFinished(bool);
123
void loadProgress(int progress);
124
void urlChanged(const QUrl&);
125
void titleChanged(const QString&);
127
void statusBarMessage(const QString& message);
128
void linkClicked(const QUrl&);
131
virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
132
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
133
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
134
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
135
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*);
136
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
137
#ifndef QT_NO_WHEELEVENT
138
virtual void wheelEvent(QGraphicsSceneWheelEvent*);
140
virtual void keyPressEvent(QKeyEvent*);
141
virtual void keyReleaseEvent(QKeyEvent*);
142
#ifndef QT_NO_CONTEXTMENU
143
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
145
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent*);
146
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent*);
147
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent*);
148
virtual void dropEvent(QGraphicsSceneDragDropEvent*);
149
virtual void focusInEvent(QFocusEvent*);
150
virtual void focusOutEvent(QFocusEvent*);
151
virtual void inputMethodEvent(QInputMethodEvent*);
152
virtual bool focusNextPrevChild(bool next);
154
virtual bool sceneEvent(QEvent*);
157
Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success))
158
Q_PRIVATE_SLOT(d, void _q_pageDestroyed())
159
// we don't want to change the moc based on USE() macro, so this function is here
160
// but will be empty if ACCLERATED_COMPOSITING is disabled
161
Q_PRIVATE_SLOT(d, void syncLayers())
162
Q_PRIVATE_SLOT(d, void _q_contentsSizeChanged(const QSize&))
163
Q_PRIVATE_SLOT(d, void _q_scaleChanged())
165
QGraphicsWebViewPrivate* const d;
166
friend class QGraphicsWebViewPrivate;
169
#endif // QT_NO_GRAPHICSVIEW
171
#endif // QGraphicsWebView_h