summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Fieroni <bvbfan@abv.bg>2016-11-07 18:29:08 (GMT)
committerAnthony Fieroni <bvbfan@abv.bg>2016-11-07 18:29:08 (GMT)
commit6dccc7739ba3d754b9209674a8985ce9d9546c2c (patch)
tree0def4e6b6a485fff7904b96b3d4e6056e2ed7cbd
parente5619efafdd9c316e6d3e609ddd73939dea3e270 (diff)
[htmlcore] Port to QtWebEngine
REVIEW: 129348 Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
-rw-r--r--thumbnail/CMakeLists.txt43
-rw-r--r--thumbnail/htmlcreator.cpp34
-rw-r--r--thumbnail/htmlcreator.h8
3 files changed, 39 insertions, 46 deletions
diff --git a/thumbnail/CMakeLists.txt b/thumbnail/CMakeLists.txt
index 2600bfe..5bfd946 100644
--- a/thumbnail/CMakeLists.txt
+++ b/thumbnail/CMakeLists.txt
@@ -71,14 +71,14 @@ set(jpegthumbnail_PART_SRCS jpegcreator.cpp)
kconfig_add_kcfg_files(jpegthumbnail_PART_SRCS jpegcreatorsettings5.kcfgc)
add_library(jpegthumbnail MODULE ${jpegthumbnail_PART_SRCS})
-target_link_libraries(jpegthumbnail
+target_link_libraries(jpegthumbnail
Qt5::Core
Qt5::Gui
KF5::KIOCore
KF5::KIOWidgets
${JPEG_LIBRARIES}
- KF5::I18n
- KF5::ConfigCore
+ KF5::I18n
+ KF5::ConfigCore
KF5::ConfigGui
)
@@ -122,18 +122,21 @@ target_link_libraries(textthumbnail
install(TARGETS textthumbnail DESTINATION ${PLUGIN_INSTALL_DIR})
-# ########### next target ###############
-#
-# if(NOT WINCE)
-# set(htmlthumbnail_PART_SRCS htmlcreator.cpp)
-#
-# add_library(htmlthumbnail MODULE ${htmlthumbnail_PART_SRCS})
-#
-# target_link_libraries(htmlthumbnail KF5::WebKit)
-#
-# install(TARGETS htmlthumbnail DESTINATION ${PLUGIN_INSTALL_DIR})
-# endif()
+############ next target ###############
+
+find_package(Qt5WebEngineWidgets 5.6.0 QUIET)
+
+if (Qt5WebEngineWidgets_FOUND)
+
+ set(htmlthumbnail_PART_SRCS htmlcreator.cpp)
+ add_library(htmlthumbnail MODULE ${htmlthumbnail_PART_SRCS})
+
+ target_link_libraries(htmlthumbnail Qt5::Core Qt5::WebEngineWidgets KF5::KIOWidgets)
+
+ install(TARGETS htmlthumbnail DESTINATION ${PLUGIN_INSTALL_DIR})
+
+endif()
########### next target ###############
if(NOT WIN32)
@@ -176,18 +179,18 @@ endif()
########### next target ###############
# if(X11_Xcursor_FOUND)
-#
+#
# set(cursorthumbnail_PART_SRCS cursorcreator.cpp)
-#
+#
# add_library(cursorthumbnail MODULE ${cursorthumbnail_PART_SRCS})
-#
+#
# target_link_libraries(cursorthumbnail ${X11_Xcursor_LIB} ${KIO_LIBRARIES})
-#
+#
# install(TARGETS cursorthumbnail DESTINATION ${PLUGIN_INSTALL_DIR})
# install( FILES cursorthumbnail.desktop DESTINATION ${SERVICES_INSTALL_DIR})
-#
+#
# endif()
-#
+#
########### next target ###############
diff --git a/thumbnail/htmlcreator.cpp b/thumbnail/htmlcreator.cpp
index 99d2636..29d1902 100644
--- a/thumbnail/htmlcreator.cpp
+++ b/thumbnail/htmlcreator.cpp
@@ -21,14 +21,11 @@
#include "htmlcreator.h"
+#include <QUrl>
#include <QImage>
#include <QPainter>
-#include <QtWebKit/QWebFrame>
-
-#include <kapplication.h>
-#include <kwebpage.h>
-#include <QUrl>
-#include <QDebug>
+#include <QWebEnginePage>
+#include <QWebEngineSettings>
extern "C"
{
@@ -52,24 +49,23 @@ bool HTMLCreator::create(const QString &path, int width, int height, QImage &img
{
if (!m_page)
{
- m_page = new KWebPage;
- connect(m_page, &KWebPage::loadFinished, this, &HTMLCreator::slotFinished);
- m_page->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
- m_page->settings()->setAttribute(QWebSettings::JavaEnabled, false);
- m_page->settings()->setAttribute(QWebSettings::PluginsEnabled, false);
- m_page->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, false);
- m_page->settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
+ m_page = new QWebEnginePage;
+ connect(m_page, &QWebEnginePage::loadFinished, this, &HTMLCreator::slotFinished);
+ m_page->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
+ m_page->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false);
+ m_page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, false);
+ m_page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true);
}
QUrl url = QUrl::fromUserInput(path); // the argument should be a QUrl!
m_loadedOk = false;
- m_page->mainFrame()->load(url);
+ m_page->load(url);
const int t = startTimer((url.isLocalFile()?5000:30000));
m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
killTimer(t);
- if (m_page->mainFrame()->contentsSize().isEmpty()) {
+ if (m_page->contentsSize().isEmpty()) {
m_loadedOk = false;
}
@@ -88,13 +84,7 @@ bool HTMLCreator::create(const QString &path, int width, int height, QImage &img
pix = QPixmap(400, 600);
}
pix.fill(Qt::transparent);
- const int borderX = pix.width() / width;
- const int borderY = pix.height() / height;
- QRect clip (borderX, borderY, pix.width() - borderX * 2, pix.height() - borderY * 2);
- QPainter p (&pix);
- m_page->setViewportSize(m_page->mainFrame()->contentsSize());
- m_page->mainFrame()->render(&p, QWebFrame::ContentsLayer, clip);
-
+ m_page->view()->render(&pix);
img = pix.toImage();
return true;
}
diff --git a/thumbnail/htmlcreator.h b/thumbnail/htmlcreator.h
index 0f1770a..329b64b 100644
--- a/thumbnail/htmlcreator.h
+++ b/thumbnail/htmlcreator.h
@@ -22,12 +22,12 @@
#ifndef HTMLCREATOR_H
#define HTMLCREATOR_H
-#include <QtCore/QObject>
-#include <QtCore/QEventLoop>
+#include <QObject>
+#include <QEventLoop>
#include <kio/thumbcreator.h>
-class KWebPage;
+class QWebEnginePage;
class HTMLCreator : public QObject, public ThumbCreator
{
@@ -46,7 +46,7 @@ private Q_SLOTS:
private:
bool m_loadedOk;
- KWebPage *m_page;
+ QWebEnginePage *m_page;
QEventLoop m_eventLoop;
};