QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgswebpage.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 QGSWEBPAGE_H
17
#define QGSWEBPAGE_H
18
19
20
#include "qgis_core.h"
21
#include "
qgsmessagelog.h
"
22
#include "
qgswebframe.h
"
23
24
#include <QMenu>
25
#include <QNetworkAccessManager>
26
#include <QObject>
27
#include <QPalette>
28
#include <QTextBrowser>
29
30
#define SIP_NO_FILE
31
37
class
CORE_EXPORT
QWebSettings
:
public
QObject
38
{
40
Q_OBJECT
41
42
public
:
43
enum
WebAttribute
44
{
45
AutoLoadImages,
46
JavascriptEnabled,
47
JavaEnabled,
48
PluginsEnabled,
49
PrivateBrowsingEnabled,
50
JavascriptCanOpenWindows,
51
JavascriptCanAccessClipboard,
52
DeveloperExtrasEnabled,
53
LinksIncludedInFocusChain,
54
ZoomTextOnly,
55
PrintElementBackgrounds,
56
OfflineStorageDatabaseEnabled,
57
OfflineWebApplicationCacheEnabled,
58
LocalStorageEnabled,
59
LocalContentCanAccessRemoteUrls,
60
DnsPrefetchEnabled,
61
XSSAuditingEnabled,
62
AcceleratedCompositingEnabled,
63
SpatialNavigationEnabled,
64
LocalContentCanAccessFileUrls,
65
TiledBackingStoreEnabled,
66
FrameFlatteningEnabled,
67
SiteSpecificQuirksEnabled,
68
JavascriptCanCloseWindows,
69
WebGLEnabled,
70
CSSRegionsEnabled,
71
HyperlinkAuditingEnabled,
72
CSSGridLayoutEnabled,
73
ScrollAnimatorEnabled,
74
CaretBrowsingEnabled,
75
NotificationsEnabled
76
};
77
explicit
QWebSettings
( QObject *parent =
nullptr
)
78
: QObject( parent )
79
{}
80
81
void
setUserStyleSheetUrl(
const
QUrl & ) {}
82
83
void
setAttribute( WebAttribute,
bool
) {}
85
};
86
92
class
CORE_EXPORT
QWebPage
:
public
QObject
93
{
95
Q_OBJECT
96
97
public
:
98
enum
LinkDelegationPolicy
99
{
100
DontDelegateLinks,
101
DelegateExternalLinks,
102
DelegateAllLinks
103
};
104
105
enum
WebWindowType
106
{
107
WebBrowserWindow,
108
WebModalDialog
109
};
110
111
explicit
QWebPage
( QObject *parent =
nullptr
)
112
: QObject( parent )
113
, mSettings( std::make_unique<QWebSettings>() )
114
, mFrame( std::make_unique<QWebFrame>() )
115
{
116
connect( mFrame.get(), &QWebFrame::loadFinished,
this
, &QWebPage::loadFinished );
117
}
118
119
~QWebPage
()
override
{}
120
121
QPalette palette()
const
{
return
QPalette(); }
122
123
void
setPalette(
const
QPalette &palette ) { Q_UNUSED( palette ) }
124
125
void
setViewportSize(
const
QSize &size )
const
{ Q_UNUSED( size ) }
126
127
void
setLinkDelegationPolicy( LinkDelegationPolicy linkDelegationPolicy )
128
{
129
if
( !parent() )
130
return
;
131
132
QTextBrowser *tb = qobject_cast<QTextBrowser *>( parent() );
133
if
( !tb )
134
return
;
135
136
tb->setOpenExternalLinks( linkDelegationPolicy != DontDelegateLinks );
137
}
138
139
void
setNetworkAccessManager( QNetworkAccessManager *networkAccessManager ) { Q_UNUSED( networkAccessManager ) }
140
141
QWebFrame
*mainFrame()
const
{
return
mFrame.get(); }
142
143
QWebSettings
*settings()
const
{
return
mSettings.get(); }
144
145
QSize viewportSize()
const
{
return
QSize(); }
146
147
QMenu *createStandardContextMenu() {
return
new
QMenu(); }
148
149
signals:
150
151
void
loadFinished(
bool
ok );
152
153
void
downloadRequested(
const
QNetworkRequest &request );
154
155
void
unsupportedContent( QNetworkReply *reply );
156
157
public
slots:
158
159
protected
:
160
virtual
void
javaScriptConsoleMessage(
const
QString &,
int
,
const
QString & ) {}
161
162
private
:
163
std::unique_ptr<QWebSettings> mSettings;
164
std::unique_ptr<QWebFrame> mFrame;
166
};
167
174
class
CORE_EXPORT
QgsWebPage
:
public
QWebPage
175
{
176
Q_OBJECT
177
178
public
:
183
explicit
QgsWebPage
( QObject *parent =
nullptr
)
184
:
QWebPage
( parent )
185
{}
186
194
void
setIdentifier
(
const
QString &
identifier
) { mIdentifier =
identifier
; }
195
201
QString
identifier
()
const
{
return
mIdentifier; }
202
203
protected
:
204
void
javaScriptConsoleMessage
(
const
QString &message,
int
lineNumber,
const
QString & )
override
205
{
206
if
( mIdentifier.isEmpty() )
207
QgsMessageLog::logMessage
( tr(
"Line %1: %2"
).arg( lineNumber ).arg( message ), tr(
"JavaScript"
) );
208
else
209
QgsMessageLog::logMessage
( tr(
"%1 (line %2): %3"
).arg( mIdentifier ).arg( lineNumber ).arg( message ), tr(
"JavaScript"
) );
210
}
211
212
private
:
213
QString mIdentifier;
214
};
215
216
#endif
// QGSWEBPAGE_H
QWebFrame
A collection of stubs to mimic the API of a QWebFrame on systems where QtWebkit is not available.
Definition
qgswebframe.h:35
QWebPage
A collection of stubs to mimic the API of a QWebPage on systems where QtWebkit is not available.
Definition
qgswebpage.h:93
QWebSettings
A collection of stubs to mimic the API of a QWebSettings on systems where QtWebkit is not available.
Definition
qgswebpage.h:38
QgsMessageLog::logMessage
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
Adds a message to the log instance (and creates it if necessary).
Definition
qgsmessagelog.cpp:35
QgsWebPage::QgsWebPage
QgsWebPage(QObject *parent=nullptr)
Constructor for QgsWebPage.
Definition
qgswebpage.h:183
QgsWebPage::javaScriptConsoleMessage
void javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &) override
Definition
qgswebpage.h:204
QgsWebPage::setIdentifier
void setIdentifier(const QString &identifier)
Sets an identifier for the QgsWebPage.
Definition
qgswebpage.h:194
QgsWebPage::identifier
QString identifier() const
Returns the QgsWebPage's identifier.
Definition
qgswebpage.h:201
qgsmessagelog.h
qgswebframe.h
Generated on
for QGIS API Documentation by
1.17.0