From 3323e3c8c00c8f92159992fc1b87bf99767255e6 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Tue, 29 Mar 2016 10:22:58 +0200 Subject: [PATCH] Revert "Revert "Merge pull request #239 from calamares/qtwebengine"" This reverts commit 8806bb67acdcba5a9fd54677907d1b7fa79921ea. --- src/modules/webview/CMakeLists.txt | 41 ++++++++++++++++++++++---- src/modules/webview/WebViewConfig.h.in | 7 +++++ src/modules/webview/WebViewStep.cpp | 18 ++++++++++- src/modules/webview/WebViewStep.h | 13 ++++++-- 4 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 src/modules/webview/WebViewConfig.h.in diff --git a/src/modules/webview/CMakeLists.txt b/src/modules/webview/CMakeLists.txt index eb5c81a68..c4b0107a3 100644 --- a/src/modules/webview/CMakeLists.txt +++ b/src/modules/webview/CMakeLists.txt @@ -1,11 +1,42 @@ -find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED WebKit WebKitWidgets ) +list( APPEND CALA_WEBVIEW_INCLUDE_DIRECTORIES + ${PROJECT_BINARY_DIR}/src/libcalamaresui +) +list( APPEND CALA_WEBVIEW_LINK_LIBRARIES + calamaresui +) -include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui - ${QT_QTWEBKIT_INCLUDE_DIR} ) + +if ( Qt5Core_VERSION VERSION_LESS 5.6 ) + find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED WebKit WebKitWidgets ) + + list( APPEND CALA_WEBVIEW_INCLUDE_DIRECTORIES + ${QT_QTWEBKIT_INCLUDE_DIR} + ) + list( APPEND CALA_WEBVIEW_LINK_LIBRARIES + Qt5::WebKit + Qt5::WebKitWidgets + ) + set( WEBVIEW_WITH_WEBKIT 1 ) +else() + find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED WebEngine WebEngineWidgets ) + + list( APPEND CALA_WEBVIEW_INCLUDE_DIRECTORIES + ${QT_QTWEBENGINE_INCLUDE_DIR} + ) + list( APPEND CALA_WEBVIEW_LINK_LIBRARIES + Qt5::WebEngine + Qt5::WebEngineWidgets + ) + set( WEBVIEW_WITH_WEBENGINE 1 ) +endif() + +include_directories( ${CALA_WEBVIEW_INCLUDE_DIRECTORIES} ) set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules ) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/WebViewConfig.h.in + ${CMAKE_CURRENT_BINARY_DIR}/WebViewConfig.h ) calamares_add_plugin( webview TYPE viewmodule @@ -13,8 +44,6 @@ calamares_add_plugin( webview SOURCES WebViewStep.cpp LINK_LIBRARIES - calamaresui - Qt5::WebKit - Qt5::WebKitWidgets + ${CALA_WEBVIEW_LINK_LIBRARIES} SHARED_LIB ) diff --git a/src/modules/webview/WebViewConfig.h.in b/src/modules/webview/WebViewConfig.h.in new file mode 100644 index 000000000..6611e44c0 --- /dev/null +++ b/src/modules/webview/WebViewConfig.h.in @@ -0,0 +1,7 @@ +#ifndef CALAMARESWEBVIEWCONFIG_H +#define CALAMARESWEBVIEWCONFIG_H + +#cmakedefine WEBVIEW_WITH_WEBENGINE +#cmakedefine WEBVIEW_WITH_WEBKIT + +#endif // CALAMARESWEBVIEWCONFIG_H diff --git a/src/modules/webview/WebViewStep.cpp b/src/modules/webview/WebViewStep.cpp index 7fa5b5989..b1d50bf7c 100644 --- a/src/modules/webview/WebViewStep.cpp +++ b/src/modules/webview/WebViewStep.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2015, Rohan Garg + * Copyright 2016, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +20,12 @@ #include "WebViewStep.h" #include + +#ifdef WEBVIEW_WITH_WEBKIT #include +#else +#include +#endif CALAMARES_PLUGIN_FACTORY_DEFINITION( WebViewStepFactory, registerPlugin(); ) @@ -27,7 +33,17 @@ WebViewStep::WebViewStep( QObject* parent ) : Calamares::ViewStep( parent ) { emit nextStatusChanged( true ); - m_view = new QWebView; + m_view = new C_QWEBVIEW(); +#ifdef WEBVIEW_WITH_WEBKIT + m_view->settings()->setFontFamily( QWebSettings::StandardFont, + m_view->settings()-> + fontFamily( QWebSettings::SansSerifFont ) ); + m_view->setRenderHints( QPainter::Antialiasing | + QPainter::TextAntialiasing | + QPainter::HighQualityAntialiasing | + QPainter::SmoothPixmapTransform | + QPainter::NonCosmeticDefaultPen ); +#endif } diff --git a/src/modules/webview/WebViewStep.h b/src/modules/webview/WebViewStep.h index af95ea269..9d8405a97 100644 --- a/src/modules/webview/WebViewStep.h +++ b/src/modules/webview/WebViewStep.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2015, Rohan Garg + * Copyright 2016, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +20,7 @@ #ifndef WEBVIEWPLUGIN_H #define WEBVIEWPLUGIN_H -#include +#include "WebViewConfig.h" #include #include @@ -28,7 +29,13 @@ #include -class QWebView; +#ifdef WEBVIEW_WITH_WEBKIT +#define C_QWEBVIEW QWebView +#else +#define C_QWEBVIEW QWebEngineView +#endif + +class C_QWEBVIEW; class PLUGINDLLEXPORT WebViewStep : public Calamares::ViewStep { @@ -57,7 +64,7 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; private: - QWebView *m_view; + C_QWEBVIEW *m_view; QString m_url; QString m_prettyName; };