Commit 46e9164c authored by jcfr's avatar jcfr

STYLE: Remove obsolete code supporting use of Qt WebKit module

Co-authored-by: Jean-Christophe Fillion-Robin's avatarJean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Co-authored-by: phcerdan's avatarPablo Hernandez-Cerdan <pablo.hernandez.cerdan@outlook.com>

From: Pablo Hernandez-Cerdan <pablo.hernandez.cerdan@outlook.com>

git-svn-id: http://svn.slicer.org/Slicer4/trunk@28006 3bd1e089-480b-0410-8dfb-8563597acbee
parent 0ac81858
......@@ -18,11 +18,7 @@
#include <QString>
#include <QTimer>
#include <QVBoxLayout>
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
#include <QWebView>
#else
#include <QWebEngineView>
#endif
// Slicer includes
#include "vtkSlicerConfigure.h"
......@@ -190,11 +186,7 @@ int qSlicerWidgetTest2(int argc, char * argv[] )
vbox.addWidget(vtkWidget);
vtkWidget->GetRenderWindow()->Render();
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
QWebView webView;
#else
QWebEngineView webView;
#endif
webView.setParent(&parentWidget);
webView.setUrl(QUrl("http://pyjs.org/examples"));
vbox.addWidget(&webView);
......
......@@ -21,11 +21,7 @@
// Qt includes
#include <QGridLayout>
#include <QtGlobal>
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
#include <QWebView>
#else
#include <QWebEngineView>
#endif
// SlicerQt includes
#include "qSlicerActionsDialog.h"
......@@ -44,11 +40,7 @@ public:
qSlicerActionsDialogPrivate(qSlicerActionsDialog& object);
void init();
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
QWebView* WebView;
#else
QWebEngineView* WebView;
#endif
};
......@@ -64,11 +56,7 @@ void qSlicerActionsDialogPrivate::init()
Q_Q(qSlicerActionsDialog);
this->setupUi(q);
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
this->WebView = new QWebView();
#else
this->WebView = new QWebEngineView();
#endif
this->WebView->setObjectName("WebView");
this->gridLayout->addWidget(this->WebView, 0, 0);
QString wikiVersion = "Nightly";
......
......@@ -22,12 +22,7 @@
#include <QDebug>
#include <QDesktopServices>
#include <QUrlQuery>
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
#include <QWebFrame>
#include <QWebView>
#else
#include <QWebEngineView>
#endif
// CTK includes
#include <ctkPimpl.h>
......@@ -146,39 +141,26 @@ void qSlicerExtensionsInstallWidgetPrivate::setFailurePage(const QStringList& er
// --------------------------------------------------------------------------
void qSlicerExtensionsInstallWidgetPrivate::initializeWebChannelTransport(QByteArray& webChannelScript)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
Q_UNUSED(webChannelScript);
#else
this->Superclass::initializeWebChannelTransport(webChannelScript);
webChannelScript.append(
" window.extensions_manager_model = channel.objects.extensions_manager_model;\n"
// See ExtensionInstallWidgetWebChannelProxy
" window.extensions_install_widget = channel.objects.extensions_install_widget;\n"
);
#endif
}
// --------------------------------------------------------------------------
void qSlicerExtensionsInstallWidgetPrivate::initializeWebChannel(QWebChannel* webChannel)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
Q_UNUSED(webChannel);
// This is done in qSlicerExtensionsInstallWidget::initJavascript()
#else
this->Superclass::initializeWebChannel(webChannel);
webChannel->registerObject(
"extensions_install_widget", this->InstallWidgetForWebChannel);
#endif
}
// --------------------------------------------------------------------------
void qSlicerExtensionsInstallWidgetPrivate::registerExtensionsManagerModel(
qSlicerExtensionsManagerModel* oldModel, qSlicerExtensionsManagerModel* newModel)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
Q_UNUSED(oldModel);
Q_UNUSED(newModel);
#else
Q_Q(qSlicerExtensionsInstallWidget);
QWebChannel* webChannel = q->webView()->page()->webChannel();
if (oldModel)
......@@ -189,7 +171,6 @@ void qSlicerExtensionsInstallWidgetPrivate::registerExtensionsManagerModel(
{
webChannel->registerObject("extensions_manager_model", newModel);
}
#endif
}
// --------------------------------------------------------------------------
......@@ -198,9 +179,6 @@ qSlicerExtensionsInstallWidget::qSlicerExtensionsInstallWidget(QWidget* _parent)
{
Q_D(qSlicerExtensionsInstallWidget);
d->init();
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
this->webView()->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
#endif
}
// --------------------------------------------------------------------------
......@@ -372,16 +350,8 @@ void qSlicerExtensionsInstallWidget::initJavascript()
{
Q_D(qSlicerExtensionsInstallWidget);
this->Superclass::initJavascript();
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
this->webView()->page()->mainFrame()->addToJavaScriptWindowObject(
"extensions_manager_model", d->ExtensionsManagerModel);
this->webView()->page()->mainFrame()->addToJavaScriptWindowObject(
"extensions_install_widget", this);
#else
// This is done in qSlicerExtensionsInstallWidgetPrivate::initializeWebChannel()
// and qSlicerExtensionsInstallWidgetPrivate::registerExtensionsManagerModel()
#endif
}
// --------------------------------------------------------------------------
......@@ -396,15 +366,6 @@ void qSlicerExtensionsInstallWidget::onLoadFinished(bool ok)
}
}
// --------------------------------------------------------------------------
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
void qSlicerExtensionsInstallWidget::onLinkClicked(const QUrl& url)
{
Q_D(qSlicerExtensionsInstallWidget);
d->InternalHosts = QStringList() << this->extensionsManagerModel()->serverUrl().host();
return Superclass::onLinkClicked(url);
}
#else
// --------------------------------------------------------------------------
bool qSlicerExtensionsInstallWidget::acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool isMainFrame)
{
......@@ -412,4 +373,3 @@ bool qSlicerExtensionsInstallWidget::acceptNavigationRequest(const QUrl & url, Q
d->InternalHosts = QStringList() << this->extensionsManagerModel()->serverUrl().host();
return Superclass::acceptNavigationRequest(url, type, isMainFrame);
}
#endif
......@@ -79,16 +79,11 @@ public slots:
void onMessageLogged(const QString& text, ctkErrorLogLevel::LogLevels level);
protected:
#ifndef Slicer_HAVE_WEBKIT_SUPPORT
virtual bool acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool isMainFrame);
#endif
protected slots:
virtual void initJavascript();
virtual void onLoadFinished(bool ok);
#ifdef Slicer_HAVE_WEBKIT_SUPPORT
virtual void onLinkClicked(const QUrl& url);
#endif
virtual void onLoadStarted();
private:
......
......@@ -24,11 +24,7 @@
// Qt includes
#include <QObject>
#include <QUrl>
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
class QWebChannel;
#else
#include <QWebChannel>
#endif
// Slicer includes
class qSlicerExtensionsInstallWidget;
......
......@@ -25,15 +25,9 @@
#include <QTimerEvent>
#include <QToolButton>
#include <QUrlQuery>
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
#include <QWebFrame>
#include <QWebHistory>
#include <QWebView>
#else
#include <QWebEngineHistory>
#include <QWebEnginePage>
#include <QWebEngineView>
#endif
// CTK includes
#include <ctkSearchBox.h>
......@@ -201,17 +195,10 @@ void qSlicerExtensionsManagerWidgetPrivate::init()
// Back and forward buttons
qSlicerExtensionsActionsWidget * actionsWidget = new qSlicerExtensionsActionsWidget;
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
actionsWidget->ManageBackButton->setDefaultAction(this->ExtensionsManageBrowser->webView()->pageAction(QWebPage::Back));
actionsWidget->ManageForwardButton->setDefaultAction(this->ExtensionsManageBrowser->webView()->pageAction(QWebPage::Forward));
actionsWidget->InstallBackButton->setDefaultAction(this->ExtensionsInstallWidget->webView()->pageAction(QWebPage::Back));
actionsWidget->InstallForwardButton->setDefaultAction(this->ExtensionsInstallWidget->webView()->pageAction(QWebPage::Forward));
#else
actionsWidget->ManageBackButton->setDefaultAction(this->ExtensionsManageBrowser->webView()->pageAction(QWebEnginePage::Back));
actionsWidget->ManageForwardButton->setDefaultAction(this->ExtensionsManageBrowser->webView()->pageAction(QWebEnginePage::Forward));
actionsWidget->InstallBackButton->setDefaultAction(this->ExtensionsInstallWidget->webView()->pageAction(QWebEnginePage::Back));
actionsWidget->InstallForwardButton->setDefaultAction(this->ExtensionsInstallWidget->webView()->pageAction(QWebEnginePage::Forward));
#endif
this->tabWidget->setCornerWidget(actionsWidget, Qt::TopLeftCorner);
......@@ -362,11 +349,7 @@ void qSlicerExtensionsManagerWidget::onCurrentTabChanged(int index)
Q_D(qSlicerExtensionsManagerWidget);
Q_UNUSED(index);
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
QWebHistory* history = d->ExtensionsManageBrowser->webView()->history();
#else
QWebEngineHistory* history = d->ExtensionsManageBrowser->webView()->history();
#endif
if (history->canGoBack())
{
history->goToItem(history->items().first());
......@@ -401,11 +384,7 @@ void qSlicerExtensionsManagerWidget::onInstallUrlChanged(const QUrl& newUrl)
// then we must not overwrite the search text.
if (!d->toolsWidget->InstallSearchBox->hasFocus())
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
QString lastSearchTextLoaded = newUrl.queryItemValue("search");
#else
QString lastSearchTextLoaded = QUrlQuery(newUrl).queryItemValue("search");
#endif
d->toolsWidget->InstallSearchBox->setText(lastSearchTextLoaded);
}
}
......@@ -439,15 +418,9 @@ void qSlicerExtensionsManagerWidget::timerEvent(QTimerEvent* e)
const QString& searchText = d->toolsWidget->InstallSearchBox->text();
if (searchText != d->lastSearchText)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
d->ExtensionsInstallWidget->webView()->page()->mainFrame()->evaluateJavaScript(
"midas.slicerappstore.search = " + jsQuote(searchText) + ";"
"midas.slicerappstore.applyFilter();");
#else
d->ExtensionsInstallWidget->webView()->page()->runJavaScript(
"midas.slicerappstore.search = " + jsQuote(searchText) + ";"
"midas.slicerappstore.applyFilter();");
#endif
d->lastSearchText = searchText;
}
this->killTimer(d->searchTimerId);
......
......@@ -27,10 +27,6 @@
#include <QTime>
#include <QUrl>
#include <QVBoxLayout>
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
#include <QWebFrame>
#include <QWebView>
#else
#include <QCoreApplication>
#include <QWebEngineView>
#include <QWebChannel>
......@@ -40,7 +36,6 @@
#include <QWebEngineProfile>
#include <QWebEngineScriptCollection>
#include <QFile>
#endif
// QtCore includes
#include <qSlicerPersistentCookieJar.h>
......@@ -54,7 +49,6 @@
#include "qSlicerWebPythonProxy.h"
// --------------------------------------------------------------------------
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
namespace
{
class qSlicerWebEngineView : public QWebEngineView
......@@ -81,7 +75,6 @@ qSlicerWebEnginePage::qSlicerWebEnginePage(QWebEngineProfile *profile, QObject *
qSlicerWebEnginePage::~qSlicerWebEnginePage()
{
}
#endif
// --------------------------------------------------------------------------
qSlicerWebWidgetPrivate::qSlicerWebWidgetPrivate(qSlicerWebWidget& object)
......@@ -99,11 +92,7 @@ qSlicerWebWidgetPrivate::~qSlicerWebWidgetPrivate()
// --------------------------------------------------------------------------
void qSlicerWebWidgetPrivate::initializeWebChannel(QWebChannel* webChannel)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
Q_UNUSED(webChannel);
#else
webChannel->registerObject("slicerPython", this->PythonProxy);
#endif
}
// --------------------------------------------------------------------------
......@@ -112,9 +101,6 @@ void qSlicerWebWidgetPrivate::init()
Q_Q(qSlicerWebWidget);
this->setupUi(q);
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
this->WebView = new QWebView();
#else
this->WebView = new qSlicerWebEngineView();
QSettings settings;
......@@ -147,7 +133,6 @@ void qSlicerWebWidgetPrivate::init()
// See https://bugreports.qt.io/browse/QTBUG-50160#comment-305211
QObject::connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()),
this, SLOT(onAppAboutToQuit()));
#endif
this->verticalLayout->insertWidget(0, this->WebView);
this->WebView->installEventFilter(q);
......@@ -165,58 +150,20 @@ void qSlicerWebWidgetPrivate::init()
this->ProgressBar, SLOT(setValue(int)));
this->ProgressBar->setVisible(false);
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
QNetworkAccessManager * networkAccessManager = this->WebView->page()->networkAccessManager();
Q_ASSERT(networkAccessManager);
networkAccessManager->setCookieJar(new qSlicerPersistentCookieJar());
QObject::connect(this->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
q, SLOT(initJavascript()));
this->WebView->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
this->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOn);
QObject::connect(this->WebView->page(), SIGNAL(linkClicked(QUrl)),
q, SLOT(onLinkClicked(QUrl)));
#endif
#ifdef Slicer_USE_PYTHONQT_WITH_OPENSSL
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
QObject::connect(networkAccessManager,
SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> & )),
q, SLOT(handleSslErrors(QNetworkReply*, const QList<QSslError> & )));
#else
// See qSlicerWebEnginePage::certificateError
#endif
#endif
}
// --------------------------------------------------------------------------
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
QWebFrame* qSlicerWebWidgetPrivate::mainFrame()
{
return this->WebView->page()->mainFrame();
}
#endif
// --------------------------------------------------------------------------
void qSlicerWebWidgetPrivate::onAppAboutToQuit()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
if (this->WebView)
{
this->WebView->setParent(0);
delete this->WebView;
this->WebView = 0;
}
#endif
}
// --------------------------------------------------------------------------
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
void qSlicerWebWidgetPrivate::updateWebChannelScript(QByteArray& webChannelScript)
{
webChannelScript.append(
......@@ -228,18 +175,14 @@ void qSlicerWebWidgetPrivate::updateWebChannelScript(QByteArray& webChannelScrip
"});\n"
);
}
#endif
// --------------------------------------------------------------------------
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
void qSlicerWebWidgetPrivate::initializeWebChannelTransport(QByteArray& webChannelScript)
{
webChannelScript.append(" window.slicerPython = channel.objects.slicerPython;\n");
}
#endif
// --------------------------------------------------------------------------
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
void qSlicerWebWidgetPrivate::initializeWebEngineProfile(QWebEngineProfile* profile)
{
if (!profile)
......@@ -278,7 +221,6 @@ void qSlicerWebWidgetPrivate::initializeWebEngineProfile(QWebEngineProfile* prof
this, SLOT(handleDownload(QWebEngineDownloadItem*)));
}
#endif
// --------------------------------------------------------------------------
void qSlicerWebWidgetPrivate::setDocumentWebkitHidden(bool value)
......@@ -288,7 +230,6 @@ void qSlicerWebWidgetPrivate::setDocumentWebkitHidden(bool value)
}
// --------------------------------------------------------------------------
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
void qSlicerWebWidgetPrivate::handleDownload(QWebEngineDownloadItem* download)
{
Q_Q(qSlicerWebWidget);
......@@ -298,7 +239,6 @@ void qSlicerWebWidgetPrivate::handleDownload(QWebEngineDownloadItem* download)
downloader->show();
downloader->handleDownload(download);
}
#endif
// --------------------------------------------------------------------------
qSlicerWebWidget::qSlicerWebWidget(QWidget* _parent)
......@@ -351,11 +291,7 @@ void qSlicerWebWidget::setInternalHosts(const QStringList& hosts)
}
// --------------------------------------------------------------------------
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
QWebView *
#else
QWebEngineView *
#endif
qSlicerWebWidget::webView()
{
Q_D(qSlicerWebWidget);
......@@ -367,9 +303,6 @@ QString qSlicerWebWidget::evalJS(const QString &js)
{
Q_D(qSlicerWebWidget);
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
return d->mainFrame()->evaluateJavaScript(js).toString();
#else
// NOTE: Beginning Qt5.7, the call to runJavaScript are asynchronous,
// and take a function (lambda) which is called once
// the script evaluation is completed.
......@@ -380,7 +313,6 @@ QString qSlicerWebWidget::evalJS(const QString &js)
emit evalResult(js, v.toString());
});
return QString();
#endif
}
......@@ -479,23 +411,6 @@ void qSlicerWebWidget::onLoadFinished(bool ok)
}
// --------------------------------------------------------------------------
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
void qSlicerWebWidget::onLinkClicked(const QUrl& url)
{
Q_D(qSlicerWebWidget);
if(d->InternalHosts.contains(url.host()) || !d->HandleExternalUrlWithDesktopService)
{
this->webView()->setUrl(url);
}
else
{
if(!QDesktopServices::openUrl(url))
{
qWarning() << "Failed to open url:" << url;
}
}
}
#else
bool qSlicerWebWidget::acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool isMainFrame)
{
Q_D(qSlicerWebWidget);
......@@ -514,24 +429,11 @@ bool qSlicerWebWidget::acceptNavigationRequest(const QUrl & url, QWebEnginePage:
}
return d->NavigationRequestAccepted;
}
#endif
// --------------------------------------------------------------------------
void qSlicerWebWidget::handleSslErrors(QNetworkReply* reply,
const QList<QSslError> &errors)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 3, 0))
#ifdef QT_NO_OPENSSL
Q_UNUSED(reply)
Q_UNUSED(errors)
#else
foreach (QSslError e, errors)
{
qDebug() << "[SSL] [" << qPrintable(reply->url().host().trimmed()) << "]"
<< qPrintable(e.errorString());
}
#endif
#else
#ifdef QT_NO_SSL
Q_UNUSED(reply)
Q_UNUSED(errors)
......@@ -542,7 +444,6 @@ void qSlicerWebWidget::handleSslErrors(QNetworkReply* reply,
<< qPrintable(e.errorString());
}
#endif
#endif
}
// --------------------------------------------------------------------------
......
......@@ -28,28 +28,18 @@
// QtGUI includes
#include "qSlicerBaseQTGUIExport.h"
#include "vtkSlicerConfigure.h" // For Slicer_USE_PYTHONQT_WITH_OPENSSL, Slicer_HAVE_WEBKIT_SUPPORT
#include "vtkSlicerConfigure.h" // For Slicer_USE_PYTHONQT_WITH_OPENSSL
class QNetworkReply;
class qSlicerWebWidgetPrivate;
class QUrl;
#ifdef Slicer_HAVE_WEBKIT_SUPPORT
class QWebView;
#else
class QWebChannel;
#include <QWebEnginePage>
class QWebEngineView;
#endif
#if (QT_VERSION < QT_VERSION_CHECK(5, 3, 0))
#ifdef QT_NO_OPENSSL
struct QSslError{};
#endif
#else
#ifdef QT_NO_SSL
struct QSslError{};
#endif
#endif
class Q_SLICER_BASE_QTGUI_EXPORT qSlicerWebWidget
: public QWidget
......@@ -90,11 +80,7 @@ public:
// void setProfile(QWebEngineProfile* profile);
/// Return a reference to the QWebView used internally.
#ifdef Slicer_HAVE_WEBKIT_SUPPORT
Q_INVOKABLE QWebView * webView();
#else
Q_INVOKABLE QWebEngineView * webView();
#endif
/// Convenient function to evaluate JS in main frame context
/// from C++ or Python code
......@@ -128,9 +114,6 @@ protected slots:
virtual void onLoadStarted();
virtual void onLoadProgress(int progress);
virtual void onLoadFinished(bool ok);
#ifdef Slicer_HAVE_WEBKIT_SUPPORT
virtual void onLinkClicked(const QUrl& url);
#endif
void handleSslErrors(QNetworkReply* reply, const QList<QSslError> &errors);
protected:
......@@ -141,9 +124,7 @@ protected:
/// "document.webkitHidden" property and trigger the associated event.
bool eventFilter(QObject *obj, QEvent *event);
#ifndef Slicer_HAVE_WEBKIT_SUPPORT
virtual bool acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool isMainFrame);
#endif
private:
Q_DECLARE_PRIVATE(qSlicerWebWidget);
......
......@@ -24,15 +24,10 @@
// Qt includes
#include <QtGlobal>
#include <QTime>
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
class QWebFrame;
class QWebView;
#else
#include <QWebEngineCertificateError>
#include <QWebEnginePage>
class QWebEngineProfile;
class QWebEngineDownloadItem;
#endif
// QtGUI includes
#include "qSlicerBaseQTGUIExport.h"
......@@ -41,8 +36,6 @@ class QWebEngineDownloadItem;
#include "ui_qSlicerWebWidget.h"
//-----------------------------------------------------------------------------
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
class Q_SLICER_BASE_QTGUI_EXPORT qSlicerWebEnginePage: public QWebEnginePage
{
friend class qSlicerWebWidget;
......@@ -80,8 +73,6 @@ private:
qSlicerWebWidget* WebWidget;
};
#endif
//-----------------------------------------------------------------------------
class Q_SLICER_BASE_QTGUI_EXPORT qSlicerWebWidgetPrivate: public QObject, Ui_qSlicerWebWidget
{
......@@ -96,10 +87,6 @@ public:
virtual void init();
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
/// Convenient function to return the mainframe
QWebFrame* mainFrame();
#else
/// \brief Update \c profile injecting a qtwebchannel script.
///
/// A QWebEngineScript named ``qwebchannel_appended.js`` is created by
......@@ -134,7 +121,6 @@ public:
protected slots:
virtual void handleDownload(QWebEngineDownloadItem *download);
#endif
public:
/// Convenient method to set "document.webkitHidden" property
......@@ -149,14 +135,10 @@ public:
bool HandleExternalUrlWithDesktopService;
bool NavigationRequestAccepted;
QStringList InternalHosts;
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
QWebView* WebView;
#else
qSlicerWebEnginePage* WebEnginePage;
QWebEngineView* WebView;
QWebChannel* WebChannel;
qSlicerWebPythonProxy* PythonProxy;
#endif
private:
Q_DISABLE_COPY(qSlicerWebWidgetPrivate);
......
......@@ -21,9 +21,6 @@
#include <QFileInfo>
#include <QHBoxLayout>
#include <QToolButton>
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
#include <QWebFrame>
#endif
// STD includes
#include <vector>
......@@ -109,11 +106,8 @@ void qMRMLChartViewPrivate::init()
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Expose the ChartView class to Javascript
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
q->page()->mainFrame()->addToJavaScriptWindowObject(QString("qtobject"), this);
#else
// q->page()->mainFrame()->addToJavaScriptWindowObject(QString("qtobject"), this);
// XXX Change to webchannel
#endif
this->PopupWidget = new ctkPopupWidget;
QHBoxLayout* popupLayout = new QHBoxLayout;
......@@ -353,11 +347,8 @@ void qMRMLChartViewPrivate::updateWidgetFromMRML()
// expose this object to the Javascript code so Javascript can call
// slots in this Qt object, e.g. onDataPointClicked()
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
q->page()->mainFrame()->addToJavaScriptWindowObject(QString("qtobject"), this);
#else
// q->page()->mainFrame()->addToJavaScriptWindowObject(QString("qtobject"), this);
// XXX Change to webchannel
#endif
}
......
......@@ -18,14 +18,8 @@
#ifndef __qMRMLChartView_h
#define __qMRMLChartView_h
#include "qMRMLWidgetsConfigure.h" // For MRML_WIDGETS_HAVE_WEBKIT_SUPPORT
// Qt includes
#ifdef MRML_WIDGETS_HAVE_WEBKIT_SUPPORT
#include <QWebView>
#else
#include <QWebEngineView>
#endif
#include "qMRMLWidgetsExport.h"
......@@ -44,20 +38,12 @@ class vtkMRMLScene;
/// subclass of QWidget and internally a variety of implementations
/// for charting may be provided.
class QMRML_WIDGETS_EXPORT qMRMLChartView :
#ifdef MRML_WIDGETS_HAVE_WEBKIT_SUPPORT
public QWebView
#else
public QWebEngineView
#endif
{
Q_OBJECT
public:
/// Superclass typedef
#ifdef MRML_WIDGETS_HAVE_WEBKIT_SUPPORT
typedef QWebView Superclass;
#else
typedef QWebEngineView Superclass;
#endif
/// Constructors
explicit qMRMLChartView(QWidget* parent = 0);
......
......@@ -91,14 +91,12 @@ void qMRMLChartWidgetPrivate::init()
QObject::connect(q, SIGNAL(mrmlSceneChanged(vtkMRMLScene*)),
this->ChartController, SLOT(setMRMLScene(vtkMRMLScene*)));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
// XXX Since relying on automatic deletion of QWebEngineView when the application
// exit causes the application to crash. This is a workaround for explicitly
// deleting the object before the application exit.
// See https://bugreports.qt.io/browse/QTBUG-50160#comment-305211
QObject::connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()),
q, SLOT(onAppAboutToQuit()));
#endif
}
// --------------------------------------------------------------------------
......@@ -177,10 +175,8 @@ vtkMRMLColorLogic* qMRMLChartWidget::colorLogic()const
//---------------------------------------------------------------------------
void qMRMLChartWidget::onAppAboutToQuit()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
Q_D(qMRMLChartWidget);
d->ChartView->setMRMLScene(0);
delete d->ChartView;
d->ChartView = 0;
#endif
}
......@@ -20,9 +20,6 @@
#include <QEvent>
#include <QFileInfo>
#include <QHBoxLayout>
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
#include <QWebFrame>
#endif
// CTK includes