~ubuntu-branches/ubuntu/saucy/plasma-mobile/saucy

« back to all changes in this revision

Viewing changes to applications/webbrowser/src/kdeclarativewebview.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-09-17 14:08:58 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20130917140858-wv7n3z6t95iy1fs9
Tags: 1:0.5-0ubuntu1
* New upstream release LP: #1227602
* Use epoch to sync with upstream version number
* Build-dep on libxcursor-dev
* Add kubuntu_no_contourd.diff to disable contourd from building,
  does not compile with 4.11 and not used by default
* Depend on renamed package ksplash-theme-active
* Add kubuntu_no_dirmodel.diff to prevert compile of dirmodel,
  included in kde-runtime 4.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <QtDeclarative/QDeclarativeItem>
27
27
#include <QtGui/QAction>
28
28
#include <QtNetwork/QNetworkAccessManager>
 
29
#include <QTime>
29
30
#include <kgraphicswebview.h>
30
31
#include <qwebpage.h>
31
32
 
33
34
 
34
35
#include "kwebpage.h"
35
36
#include "nepomukhelper.h"
 
37
#include "websslinfo.h"
36
38
 
37
39
QT_BEGIN_HEADER
38
40
 
39
41
class QWebHistory;
40
42
class QWebSettings;
 
43
class QPropertyAnimation;
41
44
 
42
45
QT_BEGIN_NAMESPACE
43
46
 
48
51
class KDeclarativeWebView;
49
52
class KDeclarativeWebViewPrivate;
50
53
 
 
54
//HACK: this is a private, but exported function from QWebframe
 
55
bool qtwebkit_webframe_scrollOverflow(QWebFrame* qFrame, int dx, int dy, const QPoint& pos);
 
56
 
51
57
class QDeclarativeWebPage : public KWebPage {
52
58
    Q_OBJECT
53
59
public:
59
65
    void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg);
60
66
    bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg);
61
67
    bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result);
 
68
    QString userAgentForUrl(const QUrl &url) const;
 
69
    bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
 
70
    void manageNetworkErrors(QNetworkReply *reply);
62
71
 
63
72
protected Q_SLOTS:
64
73
    void handleUnsupportedContent(QNetworkReply *);
71
80
    bool downloadResource(const KUrl& srcUrl, const QString& suggestedName = QString(),
72
81
                          QWidget* parent = 0, const KIO::MetaData& metaData = KIO::MetaData());
73
82
    QString errorPage(QNetworkReply *reply);
74
 
    KDeclarativeWebView *viewItem();
 
83
    KDeclarativeWebView *viewItem() const;
75
84
    NepomukHelper *m_nepomukHelper;
 
85
    WebSslInfo m_sslInfo;
76
86
};
77
87
 
78
88
class GraphicsWebView : public QGraphicsWebView {
79
89
    Q_OBJECT
 
90
 
 
91
    Q_PROPERTY(QPointF contentsPosition READ contentsPosition WRITE setContentsPosition NOTIFY contentsPositionChanged)
 
92
 
80
93
public:
81
94
    GraphicsWebView(KDeclarativeWebView* parent = 0);
82
95
 
83
96
public Q_SLOTS:
84
97
    void handleLinkClicked(const QUrl &link);
85
98
 
 
99
    QPointF contentsPosition();
 
100
    void setContentsPosition(QPointF contentsPosition);
 
101
 
86
102
protected:
87
103
    void mousePressEvent(QGraphicsSceneMouseEvent* event);
88
104
    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
100
116
    void linkPressed(const QUrl&, const QRect &linkRect);
101
117
    void linkPressAndHold(const QUrl&, const QRect &linkRect);
102
118
    void linkClicked(const QUrl&, const QRect &linkRect);
 
119
    void selectionPressAndHold(const QString &selection, const QPoint &pos);
 
120
    void contentsPositionChanged();
 
121
    void contentXChanged(int contentX);
 
122
    void contentYChanged(int contentY);
103
123
 
104
124
private:
105
 
    KDeclarativeWebView *parent;
 
125
    KDeclarativeWebView *m_parent;
 
126
    QPropertyAnimation *m_posAnim;
106
127
    QPointF pressPoint;
107
128
    QBasicTimer pressTimer;
108
129
    int pressTime; // milliseconds before the touch event becomes a "tap and hold"
109
130
    bool flicking;
110
131
    friend class KDeclarativeWebView;
 
132
 
 
133
    //speed sampling and scroll animation
 
134
    QTime m_sampleTime;
 
135
    QPoint m_draggedDistance;
 
136
    QPropertyAnimation *m_contentsPosAnimation;
111
137
};
112
138
 
113
139
class KDeclarativeWebViewAttached;
151
177
 
152
178
    Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged)
153
179
 
 
180
    Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged)
 
181
 
154
182
    Q_PROPERTY(QSize contentsSize READ contentsSize NOTIFY contentsSizeChanged)
155
183
    Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged)
156
184
 
 
185
    Q_PROPERTY(QPointF contentsPosition READ contentsPosition WRITE setContentsPosition NOTIFY contentsPositionChanged)
 
186
 
 
187
    Q_PROPERTY(int contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
 
188
    Q_PROPERTY(int contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
 
189
 
 
190
    Q_PROPERTY(int overShootX READ overShootX NOTIFY overShootXChanged)
 
191
    Q_PROPERTY(int overShootY READ overShootY NOTIFY overShootYChanged)
 
192
 
157
193
public:
158
194
    KDeclarativeWebView(QDeclarativeItem *parent = 0);
159
195
    ~KDeclarativeWebView();
181
217
    int preferredHeight() const;
182
218
    void setPreferredHeight(int);
183
219
 
 
220
    /**
 
221
     * Scrollsby dx and dy whatever scrollable element is in the page at pos.
 
222
     * if no scrollable elements are found, the main frame is scrolled
 
223
     * @returns true if any scrolling has been performed
 
224
     */
 
225
    Q_INVOKABLE bool scrollBy(int dx, int dy, const QPointF& pos);
 
226
 
184
227
    enum Status { Null, Ready, Loading, Error };
185
228
    Status status() const;
186
229
    qreal progress() const;
212
255
    bool renderingEnabled() const;
213
256
    void setRenderingEnabled(bool);
214
257
 
 
258
    QString selectedText() const;
 
259
 
215
260
    QDeclarativeListProperty<QObject> javaScriptWindowObjects();
216
261
 
217
262
    static KDeclarativeWebViewAttached* qmlAttachedProperties(QObject*);
228
273
    void setContentsScale(qreal scale);
229
274
    qreal contentsScale() const;
230
275
 
 
276
    QPointF contentsPosition();
 
277
    void setContentsPosition(QPointF contentsPosition);
 
278
 
 
279
    int contentX() const;
 
280
    void setContentX(int contentX);
 
281
 
 
282
    int contentY() const;
 
283
    void setContentY(int contentY);
 
284
 
 
285
    int overShootX() const;
 
286
    int overShootY() const;
 
287
 
 
288
    bool preferMobile() const;
 
289
 
231
290
Q_SIGNALS:
232
291
    void preferredWidthChanged();
233
292
    void preferredHeightChanged();
246
305
    void renderingEnabledChanged();
247
306
    void contentsSizeChanged(const QSize&);
248
307
    void contentsScaleChanged();
 
308
    void contentsPositionChanged();
 
309
    void contentXChanged(int contentX);
 
310
    void contentYChanged(int contentY);
 
311
    void overShootXChanged();
 
312
    void overShootYChanged();
 
313
    void selectedTextChanged();
249
314
 
250
315
    void loadStarted();
251
316
    void loadFinished();
256
321
    void linkPressed(const QUrl &linkUrl, const QRect &linkRect);
257
322
    void linkPressAndHold(const QUrl &linkUrl, const QRect &linkRect);
258
323
    void linkClicked(const QUrl &linkUrl, const QRect &linkRect);
 
324
    void selectionPressAndHold(const QString &selection, const QPoint &pos);
259
325
 
260
326
    void zoomTo(qreal zoom, int centerX, int centerY);
261
327
 
290
356
    QMouseEvent* sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent*);
291
357
    QMouseEvent* sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent*);
292
358
    friend class QDeclarativeWebPage;
 
359
    bool m_preferMobile;
293
360
};
294
361
 
295
362
class KDeclarativeWebViewAttached : public QObject {