1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 12:46:35 +01:00

Qt6 - Fix thumbnailer

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2023-09-28 22:55:50 +02:00
parent b0541447c5
commit 70bf79e371
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
3 changed files with 25 additions and 3 deletions

View File

@ -0,0 +1,18 @@
import QtQuick 2.2
import QtWebEngine 1.0
WebEngineView {
id: view
width: 1280
height: 720
onLoadingChanged: {
if (loadRequest.status == WebEngineView.LoadStartedStatus)
return;
var ok = loadRequest.status == WebEngineView.LoadSucceededStatus;
view.runJavaScript(thumbnailer.afterLoadScript(), function() {
thumbnailer.createThumbnail(ok);
});
}
}

View File

@ -6,11 +6,11 @@ WebEngineView {
width: 1280 width: 1280
height: 720 height: 720
onLoadingChanged: { onLoadingChanged: function(loadingInfo) {
if (loadRequest.status == WebEngineView.LoadStartedStatus) if (loadingInfo.status == WebEngineView.LoadStartedStatus)
return; return;
var ok = loadRequest.status == WebEngineView.LoadSucceededStatus; var ok = loadingInfo.status == WebEngineView.LoadSucceededStatus;
view.runJavaScript(thumbnailer.afterLoadScript(), function() { view.runJavaScript(thumbnailer.afterLoadScript(), function() {
thumbnailer.createThumbnail(ok); thumbnailer.createThumbnail(ok);
}); });

View File

@ -33,7 +33,11 @@ PageThumbnailer::PageThumbnailer(QObject* parent)
, m_loadTitle(false) , m_loadTitle(false)
{ {
m_view->setAttribute(Qt::WA_DontShowOnScreen); m_view->setAttribute(Qt::WA_DontShowOnScreen);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_view->setSource(QUrl(QSL("qrc:data/thumbnailer-qt5.qml")));
#else
m_view->setSource(QUrl(QSL("qrc:data/thumbnailer.qml"))); m_view->setSource(QUrl(QSL("qrc:data/thumbnailer.qml")));
#endif
m_view->rootContext()->setContextProperty(QSL("thumbnailer"), this); m_view->rootContext()->setContextProperty(QSL("thumbnailer"), this);
m_view->show(); m_view->show();
} }