Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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{
43};
44#endif
45
46class Q_SLICER_BASE_QTGUI_EXPORT qSlicerWebWidget : public QWidget
47{
48 Q_OBJECT
50 Q_PROPERTY(QStringList internalHosts READ internalHosts WRITE setInternalHosts)
52 Q_PROPERTY(QString url READ url WRITE setUrl)
54
55public:
57 typedef QWidget Superclass;
58
60 explicit qSlicerWebWidget(QWidget* parent = nullptr);
61
63 ~qSlicerWebWidget() override;
64
75
79 QStringList internalHosts() const;
80 void setInternalHosts(const QStringList& hosts);
81
90
91 // QWebEngineProfile* profile() const;
92 // void setProfile(QWebEngineProfile* profile);
93
95 Q_INVOKABLE QWebEngineView* webView();
96
99 Q_INVOKABLE QString evalJS(const QString& js);
100
102 Q_INVOKABLE QString url();
103
105 Q_INVOKABLE void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
106
107public slots:
108
110 void setUrl(const QString& url);
111
112 void onDownloadStarted(QNetworkReply* reply);
113
114 void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
115
116 void onDownloadFinished(QNetworkReply* reply);
117
127 void printToPdf(const QString& filePath);
128 void printToPdf(const QString& filePath, const QPageLayout& pageLayout);
130
131signals:
133 void evalResult(QString js, QString result);
134
137 void loadProgress(int progress);
138 void loadFinished(bool ok);
139
141 void pdfPrintingFinished(const QString& filePath, bool success);
142
143protected slots:
144 virtual void initJavascript();
145 virtual void onLoadStarted();
146 virtual void onLoadProgress(int progress);
147 virtual void onLoadFinished(bool ok);
148 void handleSslErrors(QNetworkReply* reply, const QList<QSslError>& errors);
149
150protected:
151 qSlicerWebWidget(qSlicerWebWidgetPrivate* pimpl, QWidget* parent = nullptr);
152 QScopedPointer<qSlicerWebWidgetPrivate> d_ptr;
153
154 virtual bool acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool isMainFrame);
155
156private:
157 Q_DECLARE_PRIVATE(qSlicerWebWidget);
158 Q_DISABLE_COPY(qSlicerWebWidget);
159};
160
161#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