• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef qgraphicswkview_h
2 #define qgraphicswkview_h
3 
4 #include "qwebkitglobal.h"
5 
6 #include <WebKit2/WKBase.h>
7 #include <QGraphicsWidget>
8 #include "qwkpage.h"
9 
10 QT_BEGIN_NAMESPACE
11 class QCursor;
12 QT_END_NAMESPACE
13 
14 class QWKContext;
15 class QGraphicsWKViewPrivate;
16 
17 WKStringRef WKStringCreateWithQString(const QString& qString);
18 QString WKStringCopyQString(WKStringRef stringRef);
19 
20 class QWEBKIT_EXPORT QGraphicsWKView : public QGraphicsWidget {
21     Q_OBJECT
22     Q_PROPERTY(QString title READ title)
23     Q_PROPERTY(QUrl url READ url WRITE setUrl)
24 
25 public:
26     enum BackingStoreType { Simple, Tiled };
27     QGraphicsWKView(QWKContext* context, BackingStoreType backingStoreType = Simple, QGraphicsItem* parent = 0);
28 
29     virtual ~QGraphicsWKView();
30 
31     QWKPage* page() const;
32 
33     virtual void setGeometry(const QRectF&);
34 
35     void load(const QUrl&);
36     void setUrl(const QUrl&);
37     QUrl url() const;
38 
39     QString title() const;
40 
41     void triggerPageAction(QWKPage::WebAction action, bool checked = false);
42 
43     virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
44     virtual QVariant itemChange(GraphicsItemChange, const QVariant&);
45     virtual bool event(QEvent*);
46     virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF&) const;
47     virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
48 
49     void takeSnapshot(const QSize& size, const QRect& documentRect);
50 
51     // FIXME: should not be public
52     virtual QRectF visibleRect() const;
53 
54     void prepareScaleChange();
55     void commitScaleChange();
56 
57 public:
58     Q_SIGNAL void titleChanged(const QString& title);
59     Q_SIGNAL void loadStarted();
60     Q_SIGNAL void loadFinished(bool ok);
61     Q_SIGNAL void loadProgress(int progress);
62     Q_SIGNAL void initialLayoutCompleted();
63     Q_SIGNAL void urlChanged(const QUrl&);
64     Q_SIGNAL void snapshotTaken(const QImage&);
65 
66 public Q_SLOTS:
67     void back();
68     void forward();
69     void reload();
70     void stop();
71     void showContextMenu(QSharedPointer<QMenu>);
72 
73 protected:
74     virtual void keyPressEvent(QKeyEvent*);
75     virtual void keyReleaseEvent(QKeyEvent*);
76     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
77     virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
78     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
79     virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
80     virtual void wheelEvent(QGraphicsSceneWheelEvent*);
81     virtual void touchEvent(QTouchEvent*);
82 
83     virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*);
84 
85     Q_SLOT void updateCursor(const QCursor&);
86     Q_SLOT void focusNextPrevChildCallback(bool next);
87 
88     virtual bool focusNextPrevChild(bool next);
89     virtual void focusInEvent(QFocusEvent*);
90     virtual void focusOutEvent(QFocusEvent*);
91 
92 private:
93     Q_PRIVATE_SLOT(d, void onScaleChanged())
94     Q_PRIVATE_SLOT(d, void onToolTipChanged(const QString&))
95 
96     QGraphicsWKViewPrivate* d;
97     friend class QGraphicsWKViewPrivate;
98     friend class TiledDrawingAreaProxy;
99 };
100 
101 #endif /* qgraphicswkview_h */
102