diff --git a/src/Mod/Web/App/Server.cpp b/src/Mod/Web/App/Server.cpp index 01624a8b6c..84b0fa11d6 100644 --- a/src/Mod/Web/App/Server.cpp +++ b/src/Mod/Web/App/Server.cpp @@ -114,11 +114,7 @@ AppServer::AppServer(QObject* parent) { } -#if QT_VERSION >=0x050000 void AppServer::incomingConnection(qintptr socket) -#else -void AppServer::incomingConnection(int socket) -#endif { QTcpSocket* s = new QTcpSocket(this); connect(s, SIGNAL(readyRead()), this, SLOT(readClient())); diff --git a/src/Mod/Web/App/Server.h b/src/Mod/Web/App/Server.h index 674d402279..e03002051c 100644 --- a/src/Mod/Web/App/Server.h +++ b/src/Mod/Web/App/Server.h @@ -85,11 +85,7 @@ public: AppServer(QObject* parent = 0); static std::string runPython(const QByteArray&); -#if QT_VERSION >=0x050000 void incomingConnection(qintptr socket); -#else - void incomingConnection(int socket); -#endif protected: void customEvent(QEvent* e); diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp index 775a83afd9..244285e99a 100644 --- a/src/Mod/Web/Gui/BrowserView.cpp +++ b/src/Mod/Web/Gui/BrowserView.cpp @@ -52,7 +52,7 @@ #endif -#if QT_VERSION >= 0x050700 && defined(QTWEBENGINE) +#if defined(QTWEBENGINE) # include # include # include @@ -60,20 +60,16 @@ # include # include # include -# define QWEBVIEW QWebEngineView -# define QWEBPAGE QWebEnginePage -#elif QT_VERSION >= 0x040400 && defined(QTWEBKIT) +#elif defined(QTWEBKIT) # include # include # include # include -# define QWEBVIEW QWebView -# define QWEBPAGE QWebPage +using QWebEngineView = QWebView; +using QWebEnginePage = QWebPage; #endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -# include -#endif +#include #include #include @@ -237,14 +233,10 @@ Py::Object BrowserViewPy::setHtml(const Py::Tuple& args) */ WebView::WebView(QWidget *parent) - : QWEBVIEW(parent) + : QWebEngineView(parent) { // Increase html font size for high DPI displays -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QRect mainScreenSize = QApplication::primaryScreen()->geometry(); -#else - QRect mainScreenSize = QApplication::desktop()->screenGeometry(); -#endif if (mainScreenSize.width() > 1920){ setTextSizeMultiplier (mainScreenSize.width()/1920.0); } @@ -270,23 +262,19 @@ void WebView::mousePressEvent(QMouseEvent *event) return; } } - QWEBVIEW::mousePressEvent(event); + QWebEngineView::mousePressEvent(event); } #endif void WebView::wheelEvent(QWheelEvent *event) { if (QApplication::keyboardModifiers() & Qt::ControlModifier) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) qreal factor = zoomFactor() + (-event->angleDelta().y() / 800.0); -#else - qreal factor = zoomFactor() + (-event->delta() / 800.0); -#endif setZoomFactor(factor); event->accept(); return; } - QWEBVIEW::wheelEvent(event); + QWebEngineView::wheelEvent(event); } void WebView::contextMenuEvent(QContextMenuEvent *event) @@ -313,12 +301,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) connect (newAction, SIGNAL(triggered()), signalMapper, SLOT(map())); signalMapper->setMapping(newAction, WebAction::OpenLinkInNewWindow); - menu.addAction(pageAction(QWEBPAGE::DownloadLinkToDisk)); - menu.addAction(pageAction(QWEBPAGE::CopyLinkToClipboard)); + menu.addAction(pageAction(QWebEnginePage::DownloadLinkToDisk)); + menu.addAction(pageAction(QWebEnginePage::CopyLinkToClipboard)); menu.exec(mapToGlobal(event->pos())); return; } -#if QT_VERSION >= 0x050800 && defined(QTWEBENGINE) +#if defined(QTWEBENGINE) else { // for view source // QWebEngine caches standardContextMenu, guard so we only add signalmapper once static bool firstRun = true; @@ -352,7 +340,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu->exec(event->globalPos()); } #endif - QWEBVIEW::contextMenuEvent(event); + QWebEngineView::contextMenuEvent(event); } void WebView::triggerContextMenuAction(int id) @@ -445,10 +433,7 @@ BrowserView::BrowserView(QWidget* parent) #endif view->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true); - -#if QT_VERSION >= 0x050800 view->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled,false); -#endif connect(view->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)), this, SLOT(onDownloadRequested(QWebEngineDownloadItem*))); @@ -498,11 +483,7 @@ void BrowserView::onLinkClicked (const QUrl & url) // query QString q; if (url.hasQuery()) -#if QT_VERSION >= 0x050000 q = url.query(); -#else - q = QString::fromAscii(url.encodedQuery().data()); -#endif //QString fragment = url. fragment(); @@ -541,11 +522,7 @@ void BrowserView::onLinkClicked (const QUrl & url) } // Gui::Command::doCommand(Gui::Command::Gui,"execfile('%s')",(const char*) fi.absoluteFilePath(). toLocal8Bit()); QString filename = Base::Tools::escapeEncodeFilename(fi.absoluteFilePath()); -#if PY_MAJOR_VERSION < 3 - Gui::Command::doCommand(Gui::Command::Gui,"exec(open(unicode('%s', 'utf-8')).read())",(const char*) filename.toUtf8()); -#else Gui::Command::doCommand(Gui::Command::Gui,"with open('%s') as file:\n\texec(file.read())",(const char*) filename.toUtf8()); -#endif } catch (const Base::Exception& e) { QMessageBox::critical(this, tr("Error"), QString::fromUtf8(e.what())); @@ -801,9 +778,9 @@ bool BrowserView::onMsg(const char* pMsg,const char** ) bool BrowserView::onHasMsg(const char* pMsg) const { if (strcmp(pMsg,"Back")==0) - return view->page()->action(QWEBPAGE::Back)->isEnabled(); + return view->page()->action(QWebEnginePage::Back)->isEnabled(); if (strcmp(pMsg,"Next")==0) - return view->page()->action(QWEBPAGE::Forward)->isEnabled(); + return view->page()->action(QWebEnginePage::Forward)->isEnabled(); if (strcmp(pMsg,"Refresh")==0) return !isLoading; if (strcmp(pMsg,"Stop")==0) return isLoading; if (strcmp(pMsg,"ZoomIn")==0) return true; diff --git a/src/Mod/Web/Gui/BrowserView.h b/src/Mod/Web/Gui/BrowserView.h index d869ece741..55991e5d54 100644 --- a/src/Mod/Web/Gui/BrowserView.h +++ b/src/Mod/Web/Gui/BrowserView.h @@ -29,12 +29,12 @@ #include #include -#if QT_VERSION >= 0x050700 && defined(QTWEBENGINE) +#if defined(QTWEBENGINE) #include namespace WebGui { class WebEngineUrlRequestInterceptor; }; -#elif QT_VERSION >= 0x040400 && defined(QTWEBKIT) +#elif defined(QTWEBKIT) #include #endif