Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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, Slicer_HAVE_WEBKIT_SUPPORT
32 
33 class QNetworkReply;
34 class qSlicerWebWidgetPrivate;
35 class QUrl;
36 #ifdef Slicer_HAVE_WEBKIT_SUPPORT
37 class QWebView;
38 #else
39 class QWebEngineView;
40 #endif
41 
42 #if (QT_VERSION < QT_VERSION_CHECK(5, 3, 0))
43 #ifdef QT_NO_OPENSSL
44 struct QSslError{};
45 #endif
46 #else
47 #ifdef QT_NO_SSL
48 struct QSslError{};
49 #endif
50 #endif
51 
52 class Q_SLICER_BASE_QTGUI_EXPORT qSlicerWebWidget
53  : public QWidget
54 {
55  Q_OBJECT
56 public:
58  typedef QWidget Superclass;
59 
61  explicit qSlicerWebWidget(QWidget* parent = 0);
62 
64  virtual ~qSlicerWebWidget();
65 
67 #ifdef Slicer_HAVE_WEBKIT_SUPPORT
68  Q_INVOKABLE QWebView * webView();
69 #else
70  Q_INVOKABLE QWebEngineView * webView();
71 #endif
72 
74  QString evalJS(const QString &js);
75 
76 public slots:
77 
78  void onDownloadStarted(QNetworkReply* reply);
79 
80  void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
81 
82  void onDownloadFinished(QNetworkReply* reply);
83 
84 protected slots:
85  virtual void initJavascript();
86  virtual void onLoadStarted();
87  virtual void onLoadFinished(bool ok);
88  virtual void onLinkClicked(const QUrl& url);
89  void handleSslErrors(QNetworkReply* reply, const QList<QSslError> &errors);
90 
91 protected:
92  QScopedPointer<qSlicerWebWidgetPrivate> d_ptr;
93 
96  bool eventFilter(QObject *obj, QEvent *event);
97 
98 private:
99  Q_DECLARE_PRIVATE(qSlicerWebWidget);
100  Q_DISABLE_COPY(qSlicerWebWidget);
101 };
102 
103 #endif
QScopedPointer< qSlicerWebWidgetPrivate > d_ptr
QWidget Superclass
Superclass typedef.