Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qSlicerWebWidget.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Kitware Inc.
6
7 See COPYRIGHT.txt
8 or http://www.slicer.org/copyright/copyright.txt for details.
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
17 and was partially funded by NIH grant 3P41RR013218-12S1
18
19==============================================================================*/
20
21#ifndef __qSlicerWebWidget_h
22#define __qSlicerWebWidget_h
23
24// Qt includes
25#include <QSslError>
26#include <QWidget>
27
28// QtGUI includes
29#include "qSlicerBaseQTGUIExport.h"
30
31#include "vtkSlicerConfigure.h" // For Slicer_USE_PYTHONQT_WITH_OPENSSL
32
33class QNetworkReply;
34class qSlicerWebWidgetPrivate;
35class QUrl;
36class QWebChannel;
37#include <QWebEnginePage>
38class QWebEngineView;
39
40#ifdef QT_NO_SSL
41struct QSslError{};
42#endif
43
44class Q_SLICER_BASE_QTGUI_EXPORT qSlicerWebWidget
45 : public QWidget
46{
47 Q_OBJECT
49 Q_PROPERTY(QStringList internalHosts READ internalHosts WRITE setInternalHosts)
51 Q_PROPERTY(QString url READ url WRITE setUrl)
53public:
55 typedef QWidget Superclass;
56
58 explicit qSlicerWebWidget(QWidget* parent = nullptr);
59
61 ~qSlicerWebWidget() override;
62
73
77 QStringList internalHosts() const;
78 void setInternalHosts(const QStringList& hosts);
79
88
89// QWebEngineProfile* profile()const;
90// void setProfile(QWebEngineProfile* profile);
91
93 Q_INVOKABLE QWebEngineView * webView();
94
97 Q_INVOKABLE QString evalJS(const QString &js);
98
100 Q_INVOKABLE QString url();
101
103 Q_INVOKABLE void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
104
105public slots:
106
108 void setUrl(const QString &url);
109
110 void onDownloadStarted(QNetworkReply* reply);
111
112 void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
113
114 void onDownloadFinished(QNetworkReply* reply);
115
125 void printToPdf(const QString& filePath);
126 void printToPdf(const QString& filePath, const QPageLayout& pageLayout);
128
129signals:
131 void evalResult(QString js, QString result);
132
135 void loadProgress(int progress);
136 void loadFinished(bool ok);
137
139 void pdfPrintingFinished(const QString &filePath, bool success);
140
141protected slots:
142 virtual void initJavascript();
143 virtual void onLoadStarted();
144 virtual void onLoadProgress(int progress);
145 virtual void onLoadFinished(bool ok);
146 void handleSslErrors(QNetworkReply* reply, const QList<QSslError> &errors);
147
148protected:
149 qSlicerWebWidget(qSlicerWebWidgetPrivate* pimpl, QWidget* parent = nullptr);
150 QScopedPointer<qSlicerWebWidgetPrivate> d_ptr;
151
152 virtual bool acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool isMainFrame);
153
154private:
155 Q_DECLARE_PRIVATE(qSlicerWebWidget);
156 Q_DISABLE_COPY(qSlicerWebWidget);
157};
158
159#endif
void setInternalHosts(const QStringList &hosts)
void setJavaScriptConsoleMessageLoggingEnabled(bool enable)
Q_INVOKABLE void setHtml(const QString &html, const QUrl &baseUrl=QUrl())
Convenience for setting the internal webView html from a QString.
bool javaScriptConsoleMessageLoggingEnabled
void pdfPrintingFinished(const QString &filePath, bool success)
signal passed through from QWebEnginePage
void handleSslErrors(QNetworkReply *reply, const QList< QSslError > &errors)
void onDownloadFinished(QNetworkReply *reply)
virtual void onLoadFinished(bool ok)
virtual void onLoadStarted()
QWidget Superclass
Superclass typedef.
void loadStarted()
signal passed through from QWebEngineView
friend class qSlicerWebEnginePage
void onDownloadStarted(QNetworkReply *reply)
void evalResult(QString js, QString result)
emitted with result of evalJS
Q_INVOKABLE QString evalJS(const QString &js)
virtual bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
bool handleExternalUrlWithDesktopService
void setHandleExternalUrlWithDesktopService(bool enable)
void loadFinished(bool ok)
void printToPdf(const QString &filePath)
void setUrl(const QString &url)
Convenience for setting the internal webView QUrl from a QString.
virtual void initJavascript()
void loadProgress(int progress)
void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)
qSlicerWebWidget(QWidget *parent=nullptr)
Constructor.
Q_INVOKABLE QWebEngineView * webView()
Return a reference to the QWebView used internally.
virtual void onLoadProgress(int progress)
QScopedPointer< qSlicerWebWidgetPrivate > d_ptr
QStringList internalHosts