Skip to content
Permalink
Browse files

add sip bindings to webkit stubs

  • Loading branch information
jef-n committed May 27, 2016
1 parent 4b5e5c0 commit dd69a5965589c8a27f2388e6ecad02b223392704
Showing with 198 additions and 14 deletions.
  1. +4 −0 python/CMakeLists.txt
  2. +4 −0 python/core/core.sip
  3. +140 −0 python/core/qgswebpage.sip
  4. +46 −0 python/core/qgswebview.sip
  5. +3 −9 src/core/qgswebpage.h
  6. +1 −5 src/core/qgswebview.h
@@ -134,6 +134,10 @@ ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} ARM)
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")

IF(NOT WITH_QTWEBKIT)
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} WebKit)
ENDIF(NOT WITH_QTWEBKIT)

IF(NOT WITH_TOUCH)
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_TOUCH)
ENDIF(NOT WITH_TOUCH)
@@ -3,6 +3,7 @@
keyword_arguments="Optional")

%Feature QT5_SUPPORT
%Feature WebKit

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

%Include qgswebview.sip
%Include qgswebpage.sip

%Include auth/qgsauthcertutils.sip
%Include auth/qgsauthconfig.sip
// %Include auth/qgsauthcrypto.sip
@@ -0,0 +1,140 @@
/***************************************************************************
qgswebpage.sip - QgsWebPage
---------------------
begin : May 2016
copyright : (C) 2016 by Jürgen Fischer
email : jef at norbit dot de
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

%If (!WebKit)
class QWebSettings : QObject
{
%TypeHeaderCode
#include "qgswebpage.h"
%End
public:

enum WebAttribute
{
AutoLoadImages,
JavascriptEnabled,
JavaEnabled,
PluginsEnabled,
PrivateBrowsingEnabled,
JavascriptCanOpenWindows,
JavascriptCanAccessClipboard,
DeveloperExtrasEnabled,
LinksIncludedInFocusChain,
ZoomTextOnly,
PrintElementBackgrounds,
OfflineStorageDatabaseEnabled,
OfflineWebApplicationCacheEnabled,
LocalStorageEnabled,
LocalContentCanAccessRemoteUrls,
DnsPrefetchEnabled,
XSSAuditingEnabled,
AcceleratedCompositingEnabled,
SpatialNavigationEnabled,
LocalContentCanAccessFileUrls,
TiledBackingStoreEnabled,
FrameFlatteningEnabled,
SiteSpecificQuirksEnabled,
JavascriptCanCloseWindows,
WebGLEnabled,
CSSRegionsEnabled,
HyperlinkAuditingEnabled,
CSSGridLayoutEnabled,
ScrollAnimatorEnabled,
CaretBrowsingEnabled,
NotificationsEnabled
};
explicit QWebSettings( QObject* parent = 0 );

void setUserStyleSheetUrl( const QUrl& );

void setAttribute( WebAttribute, bool on );
};

class QWebPage : QObject
{
%TypeHeaderCode
#include "qgswebpage.h"
%End
public:

enum LinkDelegationPolicy
{
DontDelegateLinks,
DelegateExternalLinks,
DelegateAllLinks
};

enum WebWindowType
{
WebBrowserWindow,
WebModalDialog
};

explicit QWebPage( QObject* parent = 0 );

~QWebPage();

QPalette palette() const;

void setPalette( const QPalette& palette );

void setViewportSize( const QSize & size ) const;

void setLinkDelegationPolicy( LinkDelegationPolicy linkDelegationPolicy );

void setNetworkAccessManager( QNetworkAccessManager* networkAccessManager );

// QWebFrame* mainFrame() const;

QWebSettings* settings() const;

QSize viewportSize() const;

QMenu *createStandardContextMenu() /Factory/;

protected:
virtual void javaScriptConsoleMessage( const QString& , int, const QString& );
};
%End

class QgsWebPage : QWebPage
{
%TypeHeaderCode
#include "qgswebpage.h"
%End
public:

/** Constructor for QgsWebPage.
* @param parent parent object
*/
QgsWebPage( QObject* parent = 0 );

/** Sets an identifier for the QgsWebPage. The page's identifier is included in messages written to the
* log, and should be set to a user-friendly string so that users can identify which QgsWebPage has
* logged the message.
* @param identifier identifier string
* @see identifier()
*/
void setIdentifier( const QString& identifier );

/** Returns the QgsWebPage's identifier. The page's identifier is included in messages written to the
* log so that users can identify which QgsWebPage has logged the message.
* @see setIdentifier()
*/
QString identifier() const;

protected:
virtual void javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& );
};
@@ -0,0 +1,46 @@
/***************************************************************************
qgswebview.sip - QgsWebView

---------------------
begin : May 2016
copyright : (C) 2016 by Jürgen Fischer
email : jef at norbit dot de
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

%If (WebKit)
class QgsWebView : QWebView
{
%TypeHeaderCode
#include "qgswebview.h"
%End
public:
QgsWebView( QWidget* parent = 0 );
};
%End

%If (!WebKit)
class QgsWebView : QWidget
{
%TypeHeaderCode
#include "qgswebview.h"
%End
public:
explicit QgsWebView( QWidget* parent = 0 );

void setUrl( const QUrl& url );
void load( const QUrl& url );
QWebPage* page() const;
QWebSettings* settings() const;
void setHtml( const QString& html );
virtual QgsWebView* createWindow( QWebPage::WebWindowType );
void setContent( const QByteArray&, const QString&, const QUrl& );
void print( QPrinter* );
};
%End
@@ -75,7 +75,7 @@ class CORE_EXPORT QWebSettings : public QObject
CaretBrowsingEnabled,
NotificationsEnabled
};
explicit QWebSettings( QObject* parent = 0 )
explicit QWebSettings( QObject* parent = nullptr )
: QObject( parent )
{

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

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

signals:

public slots:

protected:

virtual void javaScriptConsoleMessage( const QString& , int, const QString& ) {}

private:
@@ -205,7 +200,7 @@ class CORE_EXPORT QgsWebPage : public QWebPage
/** Constructor for QgsWebPage.
* @param parent parent object
*/
explicit QgsWebPage( QObject* parent = 0 )
explicit QgsWebPage( QObject* parent = nullptr )
: QWebPage( parent )
{}

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

protected:

virtual void javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& ) override
{
if ( mIdentifier.isEmpty() )
@@ -57,7 +57,7 @@ class CORE_EXPORT QgsWebView : public QWidget
/// @cond NOT_STABLE_API
Q_OBJECT
public:
explicit QgsWebView( QWidget *parent = 0 )
explicit QgsWebView( QWidget *parent = nullptr )
: QWidget( parent )
, mSettings( new QWebSettings() )
, mPage( new QWebPage() )
@@ -111,10 +111,6 @@ class CORE_EXPORT QgsWebView : public QWidget

}

signals:

public slots:

private:
QWebSettings* mSettings;
QWebPage* mPage;

0 comments on commit dd69a59

Please sign in to comment.
You can’t perform that action at this time.