21 #ifndef __qSlicerWebWidget_h 22 #define __qSlicerWebWidget_h 29 #include "qSlicerBaseQTGUIExport.h" 31 #include "vtkSlicerConfigure.h" 34 class qSlicerWebWidgetPrivate;
37 #include <QWebEnginePage> 48 Q_PROPERTY(
bool handleExternalUrlWithDesktopService READ handleExternalUrlWithDesktopService WRITE setHandleExternalUrlWithDesktopService)
49 Q_PROPERTY(QStringList internalHosts READ internalHosts WRITE setInternalHosts)
50 Q_PROPERTY(
bool javaScriptConsoleMessageLoggingEnabled READ javaScriptConsoleMessageLoggingEnabled WRITE setJavaScriptConsoleMessageLoggingEnabled)
51 Q_PROPERTY(QString url READ url WRITE setUrl)
52 friend class qSlicerWebEnginePage;
71 bool handleExternalUrlWithDesktopService() const;
72 void setHandleExternalUrlWithDesktopService(
bool enable);
77 QStringList internalHosts() const;
78 void setInternalHosts(const QStringList& hosts);
86 bool javaScriptConsoleMessageLoggingEnabled() const;
87 void setJavaScriptConsoleMessageLoggingEnabled(
bool enable);
93 Q_INVOKABLE QWebEngineView * webView();
97 Q_INVOKABLE QString evalJS(const QString &js);
100 Q_INVOKABLE QString url();
103 Q_INVOKABLE
void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
108 void setUrl(const QString &url);
110 void onDownloadStarted(QNetworkReply* reply);
112 void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
114 void onDownloadFinished(QNetworkReply* reply);
125 void printToPdf(const QString& filePath);
126 void printToPdf(const QString& filePath, const QPageLayout& pageLayout);
131 void evalResult(QString js, QString result);
135 void loadProgress(
int progress);
136 void loadFinished(
bool ok);
139 void pdfPrintingFinished(const QString &filePath,
bool success);
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);
149 qSlicerWebWidget(qSlicerWebWidgetPrivate* pimpl, QWidget* parent =
nullptr);
150 QScopedPointer<qSlicerWebWidgetPrivate> d_ptr;
154 bool eventFilter(QObject *obj, QEvent *event) override;
156 virtual
bool acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type,
bool isMainFrame);