QGIS API Documentation  2.14.0-Essen
qgswebview.h
Go to the documentation of this file.
1 /***************************************************************************
2 
3  ----------------------------------------------------
4  date : 19.5.2015
5  copyright : (C) 2015 by Matthias Kuhn
6  email : matthias (at) opengis.ch
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 #ifndef QGSWEBVIEW_H
17 #define QGSWEBVIEW_H
18 
19 
20 #include <QWidget>
21 #include <QPrinter>
22 
23 #ifdef WITH_QTWEBKIT
24 #include <QWebView>
25 #include <QDesktopWidget>
26 
27 class CORE_EXPORT QgsWebView : public QWebView
28 {
29  Q_OBJECT
30 
31  public:
32  explicit QgsWebView( QWidget* parent = nullptr )
33  : QWebView( parent )
34  {
35  QDesktopWidget desktop;
36  // Apply zoom factor for HiDPI screens
37  if ( desktop.physicalDpiX() > 96 )
38  {
39  setZoomFactor( desktop.physicalDpiX() / 96 );
40  }
41  }
42 };
43 #else
44 #include "qgswebpage.h"
45 
54 class CORE_EXPORT QgsWebView : public QWidget
55 {
56 
58  Q_OBJECT
59  public:
60  explicit QgsWebView( QWidget *parent = 0 )
61  : QWidget( parent )
62  , mSettings( new QWebSettings() )
63  , mPage( new QWebPage() )
64  {
65  }
66 
67  ~QgsWebView()
68  {
69  delete mSettings;
70  delete mPage;
71  }
72 
73  void setUrl( const QUrl& url )
74  {
75  Q_UNUSED( url );
76 
77  }
78 
79  void load( const QUrl& url )
80  {
81  Q_UNUSED( url );
82  }
83 
84  QWebPage* page() const
85  {
86  return mPage;
87  }
88 
89  QWebSettings* settings() const
90  {
91  return mSettings;
92  }
93 
94  void setHtml( const QString& html )
95  {
96  Q_UNUSED( html );
97  }
98 
99  virtual QgsWebView* createWindow( QWebPage::WebWindowType )
100  {
101  return new QgsWebView();
102  }
103 
104  void setContent( const QByteArray&, const QString&, const QUrl& )
105  {
106 
107  }
108 
109  void print( QPrinter* )
110  {
111 
112  }
113 
114  signals:
115 
116  public slots:
117 
118  private:
119  QWebSettings* mSettings;
120  QWebPage* mPage;
121 
123 };
124 #endif
125 
126 #endif // QGSWEBVIEW_H
int physicalDpiX() const
The QWebPage class is a collection of stubs to mimic the API of a QWebPage on systems where QtWebkit ...
Definition: qgswebpage.h:99
The QgsWebView class is a collection of stubs to mimic the API of QWebView on systems where the real ...
Definition: qgswebview.h:54
void setZoomFactor(qreal factor)
QWidget(QWidget *parent, QFlags< Qt::WindowType > f)
The QWebSettings class is a collection of stubs to mimic the API of a QWebSettings on systems where Q...
Definition: qgswebpage.h:36