Skip to content

Commit dd69a59

Browse files
committedMay 27, 2016
add sip bindings to webkit stubs
1 parent 4b5e5c0 commit dd69a59

File tree

6 files changed

+198
-14
lines changed

6 files changed

+198
-14
lines changed
 

‎python/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
134134
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} ARM)
135135
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
136136

137+
IF(NOT WITH_QTWEBKIT)
138+
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} WebKit)
139+
ENDIF(NOT WITH_QTWEBKIT)
140+
137141
IF(NOT WITH_TOUCH)
138142
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_TOUCH)
139143
ENDIF(NOT WITH_TOUCH)

‎python/core/core.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
keyword_arguments="Optional")
44

55
%Feature QT5_SUPPORT
6+
%Feature WebKit
67

78
%Import QtXml/QtXmlmod.sip
89
%Import QtNetwork/QtNetworkmod.sip
@@ -160,6 +161,9 @@
160161
%Include qgsvisibilitypresetcollection.sip
161162
%Include qgsxmlutils.sip
162163

164+
%Include qgswebview.sip
165+
%Include qgswebpage.sip
166+
163167
%Include auth/qgsauthcertutils.sip
164168
%Include auth/qgsauthconfig.sip
165169
// %Include auth/qgsauthcrypto.sip

‎python/core/qgswebpage.sip

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/***************************************************************************
2+
qgswebpage.sip - QgsWebPage
3+
---------------------
4+
begin : May 2016
5+
copyright : (C) 2016 by Jürgen Fischer
6+
email : jef at norbit dot de
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
%If (!WebKit)
17+
class QWebSettings : QObject
18+
{
19+
%TypeHeaderCode
20+
#include "qgswebpage.h"
21+
%End
22+
public:
23+
24+
enum WebAttribute
25+
{
26+
AutoLoadImages,
27+
JavascriptEnabled,
28+
JavaEnabled,
29+
PluginsEnabled,
30+
PrivateBrowsingEnabled,
31+
JavascriptCanOpenWindows,
32+
JavascriptCanAccessClipboard,
33+
DeveloperExtrasEnabled,
34+
LinksIncludedInFocusChain,
35+
ZoomTextOnly,
36+
PrintElementBackgrounds,
37+
OfflineStorageDatabaseEnabled,
38+
OfflineWebApplicationCacheEnabled,
39+
LocalStorageEnabled,
40+
LocalContentCanAccessRemoteUrls,
41+
DnsPrefetchEnabled,
42+
XSSAuditingEnabled,
43+
AcceleratedCompositingEnabled,
44+
SpatialNavigationEnabled,
45+
LocalContentCanAccessFileUrls,
46+
TiledBackingStoreEnabled,
47+
FrameFlatteningEnabled,
48+
SiteSpecificQuirksEnabled,
49+
JavascriptCanCloseWindows,
50+
WebGLEnabled,
51+
CSSRegionsEnabled,
52+
HyperlinkAuditingEnabled,
53+
CSSGridLayoutEnabled,
54+
ScrollAnimatorEnabled,
55+
CaretBrowsingEnabled,
56+
NotificationsEnabled
57+
};
58+
explicit QWebSettings( QObject* parent = 0 );
59+
60+
void setUserStyleSheetUrl( const QUrl& );
61+
62+
void setAttribute( WebAttribute, bool on );
63+
};
64+
65+
class QWebPage : QObject
66+
{
67+
%TypeHeaderCode
68+
#include "qgswebpage.h"
69+
%End
70+
public:
71+
72+
enum LinkDelegationPolicy
73+
{
74+
DontDelegateLinks,
75+
DelegateExternalLinks,
76+
DelegateAllLinks
77+
};
78+
79+
enum WebWindowType
80+
{
81+
WebBrowserWindow,
82+
WebModalDialog
83+
};
84+
85+
explicit QWebPage( QObject* parent = 0 );
86+
87+
~QWebPage();
88+
89+
QPalette palette() const;
90+
91+
void setPalette( const QPalette& palette );
92+
93+
void setViewportSize( const QSize & size ) const;
94+
95+
void setLinkDelegationPolicy( LinkDelegationPolicy linkDelegationPolicy );
96+
97+
void setNetworkAccessManager( QNetworkAccessManager* networkAccessManager );
98+
99+
// QWebFrame* mainFrame() const;
100+
101+
QWebSettings* settings() const;
102+
103+
QSize viewportSize() const;
104+
105+
QMenu *createStandardContextMenu() /Factory/;
106+
107+
protected:
108+
virtual void javaScriptConsoleMessage( const QString& , int, const QString& );
109+
};
110+
%End
111+
112+
class QgsWebPage : QWebPage
113+
{
114+
%TypeHeaderCode
115+
#include "qgswebpage.h"
116+
%End
117+
public:
118+
119+
/** Constructor for QgsWebPage.
120+
* @param parent parent object
121+
*/
122+
QgsWebPage( QObject* parent = 0 );
123+
124+
/** Sets an identifier for the QgsWebPage. The page's identifier is included in messages written to the
125+
* log, and should be set to a user-friendly string so that users can identify which QgsWebPage has
126+
* logged the message.
127+
* @param identifier identifier string
128+
* @see identifier()
129+
*/
130+
void setIdentifier( const QString& identifier );
131+
132+
/** Returns the QgsWebPage's identifier. The page's identifier is included in messages written to the
133+
* log so that users can identify which QgsWebPage has logged the message.
134+
* @see setIdentifier()
135+
*/
136+
QString identifier() const;
137+
138+
protected:
139+
virtual void javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& );
140+
};

‎python/core/qgswebview.sip

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/***************************************************************************
2+
qgswebview.sip - QgsWebView
3+
4+
---------------------
5+
begin : May 2016
6+
copyright : (C) 2016 by Jürgen Fischer
7+
email : jef at norbit dot de
8+
***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
17+
%If (WebKit)
18+
class QgsWebView : QWebView
19+
{
20+
%TypeHeaderCode
21+
#include "qgswebview.h"
22+
%End
23+
public:
24+
QgsWebView( QWidget* parent = 0 );
25+
};
26+
%End
27+
28+
%If (!WebKit)
29+
class QgsWebView : QWidget
30+
{
31+
%TypeHeaderCode
32+
#include "qgswebview.h"
33+
%End
34+
public:
35+
explicit QgsWebView( QWidget* parent = 0 );
36+
37+
void setUrl( const QUrl& url );
38+
void load( const QUrl& url );
39+
QWebPage* page() const;
40+
QWebSettings* settings() const;
41+
void setHtml( const QString& html );
42+
virtual QgsWebView* createWindow( QWebPage::WebWindowType );
43+
void setContent( const QByteArray&, const QString&, const QUrl& );
44+
void print( QPrinter* );
45+
};
46+
%End

‎src/core/qgswebpage.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class CORE_EXPORT QWebSettings : public QObject
7575
CaretBrowsingEnabled,
7676
NotificationsEnabled
7777
};
78-
explicit QWebSettings( QObject* parent = 0 )
78+
explicit QWebSettings( QObject* parent = nullptr )
7979
: QObject( parent )
8080
{
8181

@@ -117,7 +117,7 @@ class CORE_EXPORT QWebPage : public QObject
117117
WebModalDialog
118118
};
119119

120-
explicit QWebPage( QObject* parent = 0 )
120+
explicit QWebPage( QObject* parent = nullptr )
121121
: QObject( parent )
122122
, mSettings( new QWebSettings() )
123123
, mFrame( new QWebFrame() )
@@ -175,12 +175,7 @@ class CORE_EXPORT QWebPage : public QObject
175175
return new QMenu();
176176
}
177177

178-
signals:
179-
180-
public slots:
181-
182178
protected:
183-
184179
virtual void javaScriptConsoleMessage( const QString& , int, const QString& ) {}
185180

186181
private:
@@ -205,7 +200,7 @@ class CORE_EXPORT QgsWebPage : public QWebPage
205200
/** Constructor for QgsWebPage.
206201
* @param parent parent object
207202
*/
208-
explicit QgsWebPage( QObject* parent = 0 )
203+
explicit QgsWebPage( QObject* parent = nullptr )
209204
: QWebPage( parent )
210205
{}
211206

@@ -224,7 +219,6 @@ class CORE_EXPORT QgsWebPage : public QWebPage
224219
QString identifier() const { return mIdentifier; }
225220

226221
protected:
227-
228222
virtual void javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& ) override
229223
{
230224
if ( mIdentifier.isEmpty() )

‎src/core/qgswebview.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CORE_EXPORT QgsWebView : public QWidget
5757
/// @cond NOT_STABLE_API
5858
Q_OBJECT
5959
public:
60-
explicit QgsWebView( QWidget *parent = 0 )
60+
explicit QgsWebView( QWidget *parent = nullptr )
6161
: QWidget( parent )
6262
, mSettings( new QWebSettings() )
6363
, mPage( new QWebPage() )
@@ -111,10 +111,6 @@ class CORE_EXPORT QgsWebView : public QWidget
111111

112112
}
113113

114-
signals:
115-
116-
public slots:
117-
118114
private:
119115
QWebSettings* mSettings;
120116
QWebPage* mPage;

0 commit comments

Comments
 (0)
Please sign in to comment.