Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 578010 Details for
Bug 686842
kde-apps/kmail-18.12.3-r1: crashes when closing message
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
messagelib patch
msglib.patch (text/plain), 26.96 KB, created by
Giuseppe Vitillaro
on 2019-05-29 18:07:32 UTC
(
hide
)
Description:
messagelib patch
Filename:
MIME Type:
Creator:
Giuseppe Vitillaro
Created:
2019-05-29 18:07:32 UTC
Size:
26.96 KB
patch
obsolete
>diff --git a/messageviewer/src/viewer/webengine/mailwebenginepage.cpp b/messageviewer/src/viewer/webengine/mailwebenginepage.cpp >index cd91494b..f3790b9f 100644 >--- a/messageviewer/src/viewer/webengine/mailwebenginepage.cpp >+++ b/messageviewer/src/viewer/webengine/mailwebenginepage.cpp >@@ -1,81 +1,71 @@ > /* > Copyright (C) 2016-2018 Laurent Montel <montel@kde.org> > > This library is free software; you can redistribute it and/or > modify it under the terms of the GNU Library General Public > License as published by the Free Software Foundation; either > version 2 of the License, or (at your option) any later version. > > This library is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > Library General Public License for more details. > > You should have received a copy of the GNU Library General Public License > along with this library; see the file COPYING.LIB. If not, write to > the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, > Boston, MA 02110-1301, USA. > */ > #include "mailwebenginepage.h" > #include <QFontDatabase> > #include <QWebEngineSettings> > #include <QWebEngineProfile> > > using namespace MessageViewer; > > MailWebEnginePage::MailWebEnginePage(QObject *parent) > : WebEngineViewer::WebEnginePage(parent) > { > initialize(); > } > >-MailWebEnginePage::MailWebEnginePage(QWebEngineProfile *profile, QObject *parent) >- : WebEngineViewer::WebEnginePage(profile, parent) >-{ >- initialize(); >-} >- >-MailWebEnginePage::~MailWebEnginePage() >-{ >-} >- > void MailWebEnginePage::initialize() > { > settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false); > settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false); > settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false); > settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, false); > settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, false); > settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, false); > settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, false); > settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, false); > settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); > settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, false); > settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, false); > settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false); > settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false); > settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, false); > settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false); > > settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false); > settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, false); > profile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies); > profile()->setHttpCacheType(QWebEngineProfile::MemoryHttpCache); > > const QFontInfo font(QFontDatabase().systemFont(QFontDatabase::GeneralFont)); > settings()->setFontFamily(QWebEngineSettings::StandardFont, font.family()); > settings()->setFontSize(QWebEngineSettings::DefaultFontSize, font.pixelSize()); > connect(this, &QWebEnginePage::featurePermissionRequested, > this, &MailWebEnginePage::slotFeaturePermissionRequested); > } > > void MailWebEnginePage::setPrintElementBackground(bool printElementBackground) > { > settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, printElementBackground); > } > > void MailWebEnginePage::slotFeaturePermissionRequested(const QUrl &url, QWebEnginePage::Feature feature) > { > //Denied all permissions. > setFeaturePermission(url, feature, QWebEnginePage::PermissionDeniedByUser); > } >diff --git a/messageviewer/src/viewer/webengine/mailwebenginepage.h b/messageviewer/src/viewer/webengine/mailwebenginepage.h >index 7f8e6ebe..d581efda 100644 >--- a/messageviewer/src/viewer/webengine/mailwebenginepage.h >+++ b/messageviewer/src/viewer/webengine/mailwebenginepage.h >@@ -1,41 +1,40 @@ > /* > Copyright (C) 2016-2018 Laurent Montel <montel@kde.org> > > This library is free software; you can redistribute it and/or > modify it under the terms of the GNU Library General Public > License as published by the Free Software Foundation; either > version 2 of the License, or (at your option) any later version. > > This library is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > Library General Public License for more details. > > You should have received a copy of the GNU Library General Public License > along with this library; see the file COPYING.LIB. If not, write to > the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, > Boston, MA 02110-1301, USA. > */ > #ifndef MAILWEBENGINEPAGE_H > #define MAILWEBENGINEPAGE_H > > #include "messageviewer_export.h" > #include <WebEngineViewer/WebEnginePage> > > namespace MessageViewer { > class MESSAGEVIEWER_EXPORT MailWebEnginePage : public WebEngineViewer::WebEnginePage > { > Q_OBJECT > public: > explicit MailWebEnginePage(QObject *parent = nullptr); >- explicit MailWebEnginePage(QWebEngineProfile *profile, QObject *parent = nullptr); >- ~MailWebEnginePage(); >+ virtual ~MailWebEnginePage() = default; > > void setPrintElementBackground(bool printElementBackground); > > private: > void slotFeaturePermissionRequested(const QUrl &url, QWebEnginePage::Feature feature); > void initialize(); > }; > } > #endif // MAILWEBENGINEPAGE_H >diff --git a/messageviewer/src/viewer/webengine/mailwebengineview.cpp b/messageviewer/src/viewer/webengine/mailwebengineview.cpp >index 0685a8d8..09224cf4 100644 >--- a/messageviewer/src/viewer/webengine/mailwebengineview.cpp >+++ b/messageviewer/src/viewer/webengine/mailwebengineview.cpp >@@ -1,391 +1,390 @@ > /* > Copyright (C) 2016-2018 Laurent Montel <montel@kde.org> > > This library is free software; you can redistribute it and/or > modify it under the terms of the GNU Library General Public > License as published by the Free Software Foundation; either > version 2 of the License, or (at your option) any later version. > > This library is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > Library General Public License for more details. > > You should have received a copy of the GNU Library General Public License > along with this library; see the file COPYING.LIB. If not, write to > the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, > Boston, MA 02110-1301, USA. > */ > #include "mailwebengineview.h" > #include "mailwebenginepage.h" > #include "webengineviewer/webengineaccesskey.h" > #include "webengineviewer/webenginescript.h" > #include "messageviewer/messageviewersettings.h" > #include "../urlhandlermanager.h" > #include "loadexternalreferencesurlinterceptor/loadexternalreferencesurlinterceptor.h" > #include "blockexternalresourcesurlinterceptor/blockexternalresourcesurlinterceptor.h" > #include "blockmailtrackingurlinterceptor/blockmailtrackingurlinterceptor.h" > #include "cidreferencesurlinterceptor/cidreferencesurlinterceptor.h" > #include <WebEngineViewer/InterceptorManager> > #include <WebEngineViewer/WebEngineManageScript> > > #include "scamdetection/scamdetectionwebengine.h" > #include "scamdetection/scamcheckshorturl.h" > #include <QContextMenuEvent> > #include <WebEngineViewer/WebHitTest> > >-#include <QWebEngineProfile> > #include <QPrinter> > > #include <WebEngineViewer/WebHitTestResult> > > using namespace MessageViewer; > template<typename Arg, typename R, typename C> > struct InvokeWrapper { > R *receiver; > void (C::*memberFunction)(Arg); > void operator()(Arg result) > { > (receiver->*memberFunction)(result); > } > }; > > template<typename Arg, typename R, typename C> > > InvokeWrapper<Arg, R, C> invoke(R *receiver, void (C::*memberFunction)(Arg)) > { > InvokeWrapper<Arg, R, C> wrapper = {receiver, memberFunction}; > return wrapper; > } > > class MessageViewer::MailWebEngineViewPrivate > { > public: > MailWebEngineViewPrivate() > { > } > > QUrl mHoveredUrl; > QPoint mLastClickPosition; > ScamDetectionWebEngine *mScamDetection = nullptr; > WebEngineViewer::WebEngineAccessKey *mWebViewAccessKey = nullptr; > MessageViewer::LoadExternalReferencesUrlInterceptor *mExternalReference = nullptr; > MailWebEnginePage *mPageEngine = nullptr; > WebEngineViewer::InterceptorManager *mNetworkAccessManager = nullptr; > MessageViewer::ViewerPrivate *mViewer = nullptr; > MessageViewer::BlockMailTrackingUrlInterceptor *mBlockMailTrackingUrl = nullptr; > bool mCanStartDrag = false; > }; > > MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent) > : WebEngineViewer::WebEngineView(parent) > , d(new MessageViewer::MailWebEngineViewPrivate) > { >- d->mPageEngine = new MailWebEnginePage(new QWebEngineProfile(this), this); >+ d->mPageEngine = new MailWebEnginePage(this); > setPage(d->mPageEngine); > d->mWebViewAccessKey = new WebEngineViewer::WebEngineAccessKey(this, this); > d->mWebViewAccessKey->setActionCollection(ac); > d->mScamDetection = new ScamDetectionWebEngine(this); > connect(d->mScamDetection, &ScamDetectionWebEngine::messageMayBeAScam, this, > &MailWebEngineView::messageMayBeAScam); > connect(d->mWebViewAccessKey, &WebEngineViewer::WebEngineAccessKey::openUrl, this, > &MailWebEngineView::openUrl); > connect(this, &MailWebEngineView::loadFinished, this, &MailWebEngineView::slotLoadFinished); > > d->mNetworkAccessManager = new WebEngineViewer::InterceptorManager(this, ac, this); > d->mExternalReference = new MessageViewer::LoadExternalReferencesUrlInterceptor(this); > d->mNetworkAccessManager->addInterceptor(d->mExternalReference); > MessageViewer::CidReferencesUrlInterceptor *cidReference > = new MessageViewer::CidReferencesUrlInterceptor(this); > d->mNetworkAccessManager->addInterceptor(cidReference); > MessageViewer::BlockExternalResourcesUrlInterceptor *blockExternalUrl > = new MessageViewer::BlockExternalResourcesUrlInterceptor(this); > connect(blockExternalUrl, &BlockExternalResourcesUrlInterceptor::formSubmittedForbidden, this, > &MailWebEngineView::formSubmittedForbidden); > d->mNetworkAccessManager->addInterceptor(blockExternalUrl); > > d->mBlockMailTrackingUrl > = new MessageViewer::BlockMailTrackingUrlInterceptor(this); > connect(d->mBlockMailTrackingUrl, &BlockMailTrackingUrlInterceptor::mailTrackingFound, this, > &MailWebEngineView::mailTrackingFound); > > setFocusPolicy(Qt::WheelFocus); > connect(d->mPageEngine, &MailWebEnginePage::urlClicked, this, &MailWebEngineView::openUrl); > connect( > page(), &QWebEnginePage::scrollPositionChanged, d->mWebViewAccessKey, > &WebEngineViewer::WebEngineAccessKey::hideAccessKeys); > initializeScripts(); > } > > MailWebEngineView::~MailWebEngineView() > { > delete d; > } > > void MailWebEngineView::readConfig() > { > if (MessageViewer::MessageViewerSettings::self()->mailTrackingUrlEnabled()) { > d->mNetworkAccessManager->addInterceptor(d->mBlockMailTrackingUrl); > } else { > d->mNetworkAccessManager->removeInterceptor(d->mBlockMailTrackingUrl); > } > } > > void MailWebEngineView::setLinkHovered(const QUrl &url) > { > //TODO we need to detect image url too. > d->mHoveredUrl = url; > } > > void MailWebEngineView::runJavaScriptInWordId(const QString &script) > { > page()->runJavaScript(script, WebEngineViewer::WebEngineManageScript::scriptWordId()); > } > > void MailWebEngineView::setViewer(MessageViewer::ViewerPrivate *viewer) > { > d->mViewer = viewer; > } > > void MailWebEngineView::initializeScripts() > { > initializeJQueryScript(); > } > > void MailWebEngineView::contextMenuEvent(QContextMenuEvent *e) > { > WebEngineViewer::WebHitTest *webHit = d->mPageEngine->hitTestContent(e->pos()); > connect(webHit, &WebEngineViewer::WebHitTest::finished, this, > &MailWebEngineView::slotWebHitFinished); > } > > void MailWebEngineView::slotWebHitFinished(const WebEngineViewer::WebHitTestResult &result) > { > Q_EMIT popupMenu(result); > } > > void MailWebEngineView::scrollUp(int pixels) > { > runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollUp(pixels)); > } > > void MailWebEngineView::scrollDown(int pixels) > { > runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollDown(pixels)); > } > > void MailWebEngineView::selectAll() > { > page()->triggerAction(QWebEnginePage::SelectAll); > } > > void MailWebEngineView::slotZoomChanged(qreal zoom) > { > setZoomFactor(zoom); > } > > void MailWebEngineView::scamCheck() > { > d->mScamDetection->scanPage(page()); > } > > void MailWebEngineView::slotShowDetails() > { > d->mScamDetection->showDetails(); > } > > void MailWebEngineView::forwardKeyReleaseEvent(QKeyEvent *e) > { > if (MessageViewer::MessageViewerSettings::self()->accessKeyEnabled()) { > d->mWebViewAccessKey->keyReleaseEvent(e); > } > } > > void MailWebEngineView::forwardMousePressEvent(QMouseEvent *event) > { > if (d->mViewer && !d->mHoveredUrl.isEmpty()) { > if (event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier)) { > // special processing for shift+click > if (URLHandlerManager::instance()->handleShiftClick(d->mHoveredUrl, d->mViewer)) { > event->accept(); > return; > } > } > if (event->button() == Qt::LeftButton) { > d->mCanStartDrag = URLHandlerManager::instance()->willHandleDrag(d->mHoveredUrl, > d->mViewer); > d->mLastClickPosition = event->pos(); > } > } > } > > void MailWebEngineView::forwardMouseMoveEvent(QMouseEvent *event) > { > if (d->mViewer && !d->mHoveredUrl.isEmpty()) { > // If we are potentially handling a drag, deal with that. > if (d->mCanStartDrag && (event->buttons() & Qt::LeftButton)) { > if ((d->mLastClickPosition - event->pos()).manhattanLength() > > QApplication::startDragDistance()) { > if (URLHandlerManager::instance()->handleDrag(d->mHoveredUrl, d->mViewer)) { > // If the URL handler manager started a drag, don't handle this in the future > d->mCanStartDrag = false; > } > } > event->accept(); > } > } > } > > void MailWebEngineView::forwardMouseReleaseEvent(QMouseEvent *event) > { > Q_UNUSED(event); > d->mCanStartDrag = false; > } > > void MailWebEngineView::forwardKeyPressEvent(QKeyEvent *e) > { > if (e && hasFocus()) { > if (MessageViewer::MessageViewerSettings::self()->accessKeyEnabled()) { > d->mWebViewAccessKey->keyPressEvent(e); > } > } > } > > void MailWebEngineView::forwardWheelEvent(QWheelEvent *e) > { > if (MessageViewer::MessageViewerSettings::self()->accessKeyEnabled()) { > d->mWebViewAccessKey->wheelEvent(e); > } > if (QApplication::keyboardModifiers() & Qt::ControlModifier) { > const int numDegrees = e->delta() / 8; > const int numSteps = numDegrees / 15; > Q_EMIT wheelZoomChanged(numSteps); > e->accept(); > } > } > > void MailWebEngineView::resizeEvent(QResizeEvent *e) > { > if (MessageViewer::MessageViewerSettings::self()->accessKeyEnabled()) { > d->mWebViewAccessKey->resizeEvent(e); > } > QWebEngineView::resizeEvent(e); > } > > void MailWebEngineView::saveMainFrameScreenshotInFile(const QString &filename) > { > //TODO need to verify it > QImage image(size(), QImage::Format_ARGB32_Premultiplied); > image.fill(Qt::transparent); > > QPainter painter(&image); > painter.setRenderHint(QPainter::Antialiasing, true); > painter.setRenderHint(QPainter::TextAntialiasing, true); > painter.setRenderHint(QPainter::SmoothPixmapTransform, true); > render(&painter); > painter.end(); > image.save(filename); > } > > void MailWebEngineView::showAccessKeys() > { > d->mWebViewAccessKey->showAccessKeys(); > } > > void MailWebEngineView::hideAccessKeys() > { > d->mWebViewAccessKey->hideAccessKeys(); > } > > void MailWebEngineView::isScrolledToBottom() > { > page()->runJavaScript(WebEngineViewer::WebEngineScript::isScrolledToBottom(), > WebEngineViewer::WebEngineManageScript::scriptWordId(), > invoke(this, &MailWebEngineView::handleIsScrolledToBottom)); > } > > void MailWebEngineView::setElementByIdVisible(const QString &id, bool visible) > { > runJavaScriptInWordId(WebEngineViewer::WebEngineScript::setElementByIdVisible(id, visible)); > } > > void MailWebEngineView::removeAttachmentMarking(const QString &id) > { > runJavaScriptInWordId(WebEngineViewer::WebEngineScript::removeStyleToElement(id)); > } > > void MailWebEngineView::markAttachment(const QString &id, const QString &style) > { > runJavaScriptInWordId(WebEngineViewer::WebEngineScript::setStyleToElement(id, style)); > } > > void MailWebEngineView::scrollToAnchor(const QString &anchor) > { > page()->runJavaScript(WebEngineViewer::WebEngineScript::searchElementPosition(anchor), > WebEngineViewer::WebEngineManageScript::scriptWordId(), > invoke(this, &MailWebEngineView::handleScrollToAnchor)); > } > > void MailWebEngineView::handleIsScrolledToBottom(const QVariant &result) > { > bool scrolledToBottomResult = false; > if (result.isValid()) { > scrolledToBottomResult = result.toBool(); > } > Q_EMIT pageIsScrolledToBottom(scrolledToBottomResult); > } > > void MailWebEngineView::handleScrollToAnchor(const QVariant &result) > { > if (result.isValid()) { > const QList<QVariant> lst = result.toList(); > if (lst.count() == 2) { > const QPoint pos(lst.at(0).toInt(), lst.at(1).toInt()); > runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollToPosition(pos)); > } > } > } > > void MailWebEngineView::scrollPageDown(int percent) > { > runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollPercentage(percent)); > } > > void MailWebEngineView::scrollPageUp(int percent) > { > scrollPageDown(-percent); > } > > void MailWebEngineView::scrollToRelativePosition(qreal pos) > { > runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollToRelativePosition(pos)); > } > > void MailWebEngineView::setAllowExternalContent(bool b) > { > if (d->mExternalReference->allowExternalContent() != b) { > d->mExternalReference->setAllowExternalContent(b); > reload(); > } > } > > QList<QAction *> MailWebEngineView::interceptorUrlActions( > const WebEngineViewer::WebHitTestResult &result) const > { > return d->mNetworkAccessManager->interceptorUrlActions(result); > } > > void MailWebEngineView::slotLoadFinished() > { > scamCheck(); > } > > void MailWebEngineView::setPrintElementBackground(bool printElementBackground) > { > d->mPageEngine->setPrintElementBackground(printElementBackground); > } > > bool MailWebEngineView::execPrintPreviewPage(QPrinter *printer, int timeout) > { > return d->mPageEngine->execPrintPreviewPage(printer, timeout); > } >diff --git a/webengineviewer/src/webenginepage.cpp b/webengineviewer/src/webenginepage.cpp >index 447ac26b..2fcb6c2b 100644 >--- a/webengineviewer/src/webenginepage.cpp >+++ b/webengineviewer/src/webenginepage.cpp >@@ -1,106 +1,118 @@ > /* > Copyright (C) 2016-2018 Laurent Montel <montel@kde.org> > > This library is free software; you can redistribute it and/or > modify it under the terms of the GNU Library General Public > License as published by the Free Software Foundation; either > version 2 of the License, or (at your option) any later version. > > This library is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > Library General Public License for more details. > > You should have received a copy of the GNU Library General Public License > along with this library; see the file COPYING.LIB. If not, write to > the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, > Boston, MA 02110-1301, USA. > */ > > #include "webenginepage.h" > #include "webhittest.h" > #include "webhittestresult.h" > > #include <KLocalizedString> > > #include <QEventLoop> > #include <QWebEngineDownloadItem> > #include <QPointer> > #include <QTimer> > #include <QFileDialog> > #include <QWebEngineProfile> > #include <QPrinter> > using namespace WebEngineViewer; > > WebEnginePage::WebEnginePage(QObject *parent) >- : QWebEnginePage(parent) >+ : QWebEnginePage(new QWebEngineProfile, parent) > { >+ // Create a private (off the record) QWebEngineProfile here to isolate the >+ // browsing settings, and adopt it as a child so that it will be deleted >+ // when we are destroyed. The profile must remain active for as long as >+ // any QWebEnginePage's belonging to it exist, see the API documentation >+ // of QWebEnginePage::QWebEnginePage(QWebEngineProfile *, QObject *). >+ // Deleting it as our child on destruction is safe. >+ // >+ // Do not try to save a line of code by setting the parent on construction: >+ // >+ // WebEnginePage::WebEnginePage(QObject *parent) >+ // : QWebEnginePage(new QWebEngineProfile(this), parent) >+ // >+ // because the QWebEngineProfile constructor will call out to the QWebEnginePage >+ // and crash because the QWebEnginePage is not fully constructed yet. >+ profile()->setParent(this); >+ > init(); > } > > WebEnginePage::WebEnginePage(QWebEngineProfile *profile, QObject *parent) > : QWebEnginePage(profile, parent) > { > init(); > } > >-WebEnginePage::~WebEnginePage() >-{ >-} >- > void WebEnginePage::init() > { > connect(profile(), &QWebEngineProfile::downloadRequested, this, &WebEnginePage::saveHtml); > } > > WebEngineViewer::WebHitTest *WebEnginePage::hitTestContent(const QPoint &pos) > { > return new WebHitTest(this, pos); > } > > void WebEnginePage::saveHtml(QWebEngineDownloadItem *download) > { > const QString fileName = QFileDialog::getSaveFileName(view(), i18n("Save HTML Page")); > if (!fileName.isEmpty()) { > download->setSavePageFormat(QWebEngineDownloadItem::SingleHtmlSaveFormat); > download->setPath(fileName); > download->accept(); > } > } > > bool WebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) > { > if (isMainFrame && type == NavigationTypeLinkClicked) { > Q_EMIT urlClicked(url); > return false; > } > return true; > } > > void WebEnginePage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) > { > Q_UNUSED(level); > Q_UNUSED(sourceID); > //Don't convert to debug categories > qDebug() << "WebEnginePage::javaScriptConsoleMessage lineNumber: " << lineNumber << " message: " << message; > Q_EMIT showConsoleMessage(message); > } > > bool WebEnginePage::execPrintPreviewPage(QPrinter *printer, int timeout) > { > QPointer<QEventLoop> loop = new QEventLoop; > bool result = false; > QTimer::singleShot(timeout, loop.data(), &QEventLoop::quit); > > print(printer, [loop, &result](bool res) { > if (loop && loop->isRunning()) { > result = res; > loop->quit(); > } > }); > > loop->exec(); > delete loop; > > return result; > } >diff --git a/webengineviewer/src/webenginepage.h b/webengineviewer/src/webenginepage.h >index be383685..95c7c760 100644 >--- a/webengineviewer/src/webenginepage.h >+++ b/webengineviewer/src/webenginepage.h >@@ -1,56 +1,87 @@ > /* > Copyright (C) 2016-2018 Laurent Montel <montel@kde.org> > > This library is free software; you can redistribute it and/or > modify it under the terms of the GNU Library General Public > License as published by the Free Software Foundation; either > version 2 of the License, or (at your option) any later version. > > This library is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > Library General Public License for more details. > > You should have received a copy of the GNU Library General Public License > along with this library; see the file COPYING.LIB. If not, write to > the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, > Boston, MA 02110-1301, USA. > */ > > #ifndef WEBENGINEPAGE_H > #define WEBENGINEPAGE_H > > #include <QWebEnginePage> > #include "webengineviewer_export.h" > class QWebEngineProfile; > class QWebEngineDownloadItem; > class QPrinter; > namespace WebEngineViewer { > class WebHitTest; > class WEBENGINEVIEWER_EXPORT WebEnginePage : public QWebEnginePage > { > Q_OBJECT > public: >+ /** >+ * Constructor. >+ * >+ * A private QWebEngineProfile, only applying to this QWebEnginePage, >+ * will be created to implement browser settings. It can be accessed via >+ * @c profile(), but it should not be shared or reused unless care is >+ * taken that the profile is not deleted until all of the QWebEnginePage's >+ * belonging to it are deleted first. >+ * >+ * @param parent The parent object >+ **/ > explicit WebEnginePage(QObject *parent = nullptr); >- explicit WebEnginePage(QWebEngineProfile *profile, QObject *parent = nullptr); > >- ~WebEnginePage() override; >+ /** >+ * Constructor. >+ * >+ * The specified QWebEngineProfile will be used. See the description of >+ * @c WebEnginePage(QObject *) and the API documentation of QWebEnginePage >+ * for caution regarding the lifetime of the profile. >+ * >+ * @param profile The profile to be used >+ * @param parent The parent object >+ * @deprecated Use the single argument constructor, which creates and uses >+ * a private profile. >+ **/ >+#ifndef WEBENGINEVIEWER_NO_DEPRECATED >+ explicit WEBENGINEVIEWER_DEPRECATED WebEnginePage(QWebEngineProfile *profile, QObject *parent = nullptr); >+#endif >+ >+ /** >+ * Destructor. If there is a private QWebEngineProfile then it will also >+ * be destroyed. >+ **/ >+ virtual ~WebEnginePage() override = default; >+ > WebEngineViewer::WebHitTest *hitTestContent(const QPoint &pos); > > void saveHtml(QWebEngineDownloadItem *download); > Q_REQUIRED_RESULT bool execPrintPreviewPage(QPrinter *printer, int timeout); > > Q_SIGNALS: > void urlClicked(const QUrl &url); > void showConsoleMessage(const QString &message); > > protected: > bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override; > void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) override; > > private: > void init(); > }; > } > > #endif // WEBENGINEPAGE_H
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 686842
:
577976
| 578010