Skip to content

Commit

Permalink
Allow compiling QGIS without QtWebkit
Browse files Browse the repository at this point in the history
This allows to compile QGIS without webkit.

1. Webkit is soon-to-be deprecated
2. Webkit is not supported on Android
3. Who needs it anyway
4. The developer map on the about page is gone with webkit disabled
5. So is the information about plugins
  • Loading branch information
m-kuhn committed May 21, 2015
1 parent 8abe726 commit f5054ce
Show file tree
Hide file tree
Showing 22 changed files with 590 additions and 56 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Expand Up @@ -229,6 +229,10 @@ SET (HAVE_SPATIALITE TRUE)
# following variable is used in qgsconfig.h
SET (HAVE_MSSQL TRUE)

SET (WITH_QTWEBKIT TRUE CACHE INTERNAL "Enable QtWebkit support")
IF (WITH_QTWEBKIT)
ADD_DEFINITIONS(-DWITH_QTWEBKIT)
ENDIF(WITH_QTWEBKIT)
#############################################################
# search for Qt4
SET(QT_MIN_VERSION 4.7.0)
Expand All @@ -243,8 +247,10 @@ IF (ENABLE_QT5)
FIND_PACKAGE(Qt5Concurrent REQUIRED)
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
FIND_PACKAGE(Qt5Positioning)
FIND_PACKAGE(Qt5WebKit REQUIRED)
FIND_PACKAGE(Qt5WebKitWidgets REQUIRED)
IF (WITH_QTWEBKIT)
FIND_PACKAGE(Qt5WebKit REQUIRED)
FIND_PACKAGE(Qt5WebKitWidgets REQUIRED)
ENDIF(WITH_QTWEBKIT)
FIND_PACKAGE(Qt5Test REQUIRED)
FIND_PACKAGE(Qt5UiTools REQUIRED)
FIND_PACKAGE(Qt5Script REQUIRED)
Expand Down
1 change: 0 additions & 1 deletion src/app/pluginmanager/qgspluginmanager.cpp
Expand Up @@ -30,7 +30,6 @@
#include <QActionGroup>
#include <QTextStream>
#include <QTimer>
#include <QWebPage>
#include <QDesktopServices>

#include "qgis.h"
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -33,6 +33,8 @@
#include "qgsproject.h"
#include "qgsrasterlayer.h"
#include "qgsvectorlayer.h"
#include "qgswebview.h"
#include "qgswebframe.h"

#include <QCloseEvent>
#include <QLabel>
Expand All @@ -45,13 +47,11 @@
#include <QDockWidget>
#include <QMenuBar>
#include <QPushButton>
#include <QWebView>
#include <QPrinter>
#include <QPrintDialog>
#include <QDesktopServices>
#include <QMessageBox>
#include <QComboBox>
#include <QWebFrame>

//graph
#include <qwt_plot.h>
Expand All @@ -61,7 +61,7 @@
#include "qgsvectorcolorrampv2.h" // for random colors


QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QWebView( parent )
QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QgsWebView( parent )
{
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
Expand All @@ -80,7 +80,7 @@ void QgsIdentifyResultsWebView::print( void )
QPrintDialog *dialog = new QPrintDialog( &printer );
if ( dialog->exec() == QDialog::Accepted )
{
QWebView::print( &printer );
QgsWebView::print( &printer );
}
}

Expand All @@ -97,12 +97,12 @@ void QgsIdentifyResultsWebView::contextMenuEvent( QContextMenuEvent *e )
delete menu;
}

QWebView *QgsIdentifyResultsWebView::createWindow( QWebPage::WebWindowType type )
QgsWebView *QgsIdentifyResultsWebView::createWindow( QWebPage::WebWindowType type )
{
QDialog *d = new QDialog( this );
QLayout *l = new QVBoxLayout( d );

QWebView *wv = new QWebView( d );
QgsWebView *wv = new QgsWebView( d );
l->addWidget( wv );

wv->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsidentifyresultsdialog.h
Expand Up @@ -27,10 +27,10 @@
#include "qgsmaptoolidentify.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsmaplayeractionregistry.h"
#include "qgswebview.h"

#include <QWidget>
#include <QList>
#include <QWebView>

class QCloseEvent;
class QTreeWidgetItem;
Expand All @@ -49,7 +49,7 @@ class QwtPlotCurve;
*@author Gary E.Sherman
*/

class APP_EXPORT QgsIdentifyResultsWebView : public QWebView
class APP_EXPORT QgsIdentifyResultsWebView : public QgsWebView
{
Q_OBJECT
public:
Expand All @@ -59,7 +59,7 @@ class APP_EXPORT QgsIdentifyResultsWebView : public QWebView
void print( void );
protected:
void contextMenuEvent( QContextMenuEvent* ) override;
QWebView *createWindow( QWebPage::WebWindowType type ) override;
QgsWebView *createWindow( QWebPage::WebWindowType type ) override;
};

class APP_EXPORT QgsIdentifyResultsFeatureItem: public QTreeWidgetItem
Expand Down
21 changes: 19 additions & 2 deletions src/core/CMakeLists.txt
Expand Up @@ -291,6 +291,13 @@ SET(QGIS_CORE_SRCS
raster/qgshuesaturationfilter.cpp
)

IF (NOT WITH_QTWEBKIT)
SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
qgswebpage.cpp
qgswebframe.cpp
)
ENDIF(NOT WITH_QTWEBKIT)

IF(ENABLE_MODELTEST)
SET(MODELTEST_SRCS
../../tests/qt_modeltest/modeltest.cpp
Expand Down Expand Up @@ -322,7 +329,6 @@ IF (WITH_INTERNAL_QEXTSERIALPORT)
gps/qextserialport/qextserialport.cpp
gps/qextserialport/qextserialenumerator.cpp
)

IF(WIN32)
SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
gps/qextserialport/win_qextserialport.cpp
Expand Down Expand Up @@ -388,6 +394,7 @@ SET(QGIS_CORE_MOC_HDRS
qgsvectorlayercache.h
qgsvectorlayerjoinbuffer.h
qgsgeometryvalidator.h
qgswebview.h

composer/qgsaddremoveitemcommand.h
composer/qgscomposerlegend.h
Expand Down Expand Up @@ -438,6 +445,13 @@ SET(QGIS_CORE_MOC_HDRS
layertree/qgslayertreeregistrybridge.h
)

IF (NOT WITH_QTWEBKIT)
SET(QGIS_CORE_MOC_HDRS ${QGIS_CORE_MOC_HDRS}
qgswebpage.h
qgswebframe.h
)
ENDIF(NOT WITH_QTWEBKIT)

IF (NOT QT5_BUILD)
SET(QGIS_CORE_MOC_HDRS ${QGIS_CORE_MOC_HDRS}
qgshttptransaction.h
Expand Down Expand Up @@ -572,12 +586,15 @@ SET(QGIS_CORE_HDRS
qgsvectorlayerundocommand.h
qgsvectorsimplifymethod.h
qgsxmlutils.h
qgswebpage.h
qgswebframe.h
qgswebview.h

diagram/qgsdiagram.h
diagram/qgspiediagram.h
diagram/qgstextdiagram.h
diagram/qgshistogramdiagram.h

effects/qgsimageoperation.h
effects/qgspainteffect.h
effects/qgseffectstack.h
Expand Down
5 changes: 3 additions & 2 deletions src/core/composer/qgscomposerhtml.cpp
Expand Up @@ -26,10 +26,11 @@
#include "qgsproject.h"
#include "qgsdistancearea.h"

#include "qgswebpage.h"
#include "qgswebframe.h"

#include <QCoreApplication>
#include <QPainter>
#include <QWebFrame>
#include <QWebPage>
#include <QImage>
#include <QNetworkReply>

Expand Down
6 changes: 4 additions & 2 deletions src/core/composer/qgscomposerlabel.cpp
Expand Up @@ -25,14 +25,16 @@
#include "qgsproject.h"
#include "qgsdistancearea.h"

#include "qgswebview.h"
#include "qgswebframe.h"
#include "qgswebpage.h"

#include <QCoreApplication>
#include <QDate>
#include <QDomElement>
#include <QPainter>
#include <QSettings>
#include <QTimer>
#include <QWebFrame>
#include <QWebPage>
#include <QEventLoop>

QgsComposerLabel::QgsComposerLabel( QgsComposition *composition )
Expand Down
52 changes: 52 additions & 0 deletions src/core/qgswebframe.cpp
@@ -0,0 +1,52 @@
/***************************************************************************
----------------------------------------------------
date : 19.5.2015
copyright : (C) 2015 by Matthias Kuhn
email : matthias (at) opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#include "qgswebframe.h"

QWebFrame::QWebFrame()
{

}

void QWebFrame::setZoomFactor(qreal factor)
{

}

void QWebFrame::setScrollBarPolicy(Qt::Orientation, Qt::ScrollBarPolicy)
{

}

void QWebFrame::setHtml(const QString&, const QUrl)
{

}

QSize QWebFrame::contentsSize() const
{

}

void QWebFrame::render( QPainter*, const QRegion )
{

}

void QWebFrame::addToJavaScriptWindowObject(const QString&, QObject*)
{

}

74 changes: 74 additions & 0 deletions src/core/qgswebframe.h
@@ -0,0 +1,74 @@
/***************************************************************************
----------------------------------------------------
date : 19.5.2015
copyright : (C) 2015 by Matthias Kuhn
email : matthias (at) opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#ifndef QGSWEBFRAME_H
#define QGSWEBFRAME_H

#ifdef WITH_QTWEBKIT
#include <QtWebKit/QWebFrame>
#else

#include <QObject>
#include <QPainter>
#include <QUrl>

class QWebFrame : public QObject
{
Q_OBJECT

public:
QWebFrame( QObject* parent = 0 )
:QObject( parent )
{

}

void setZoomFactor( qreal factor )
{
Q_UNUSED( factor );
}

void setScrollBarPolicy( Qt::Orientation orientation, Qt::ScrollBarPolicy scrollbarpolicy )
{
Q_UNUSED( orientation );
Q_UNUSED( scrollbarpolicy );
}

void setHtml( const QString& html, const QUrl& url = QUrl() )
{
Q_UNUSED( html );
Q_UNUSED( url );
}

QSize contentsSize() const
{
return QSize();
}

void render( QPainter*, const QRegion = QRegion() )
{

}

void addToJavaScriptWindowObject( const QString&, QObject* )
{

}

signals:
void javaScriptWindowObjectCleared();
};
#endif
#endif // QGSWEBFRAME_H

0 comments on commit f5054ce

Please sign in to comment.