Commit ddc44a3b authored by Laurent Montel's avatar Laurent Montel 😁

Now kmail can use QtWebEngine

parent 482efdd6
...@@ -107,6 +107,7 @@ if (QTWEBENGINE_SUPPORT_OPTION) ...@@ -107,6 +107,7 @@ if (QTWEBENGINE_SUPPORT_OPTION)
webengine/webenginepage.cpp webengine/webenginepage.cpp
webengine/webenginescript.cpp webengine/webenginescript.cpp
webengine/webengineview.cpp webengine/webengineview.cpp
webengine/loadexternalreferencesurlinterceptor/loadexternalreferencesurlinterceptor.cpp
) )
set(libmessageviewer_web_LIB Qt5::WebEngine Qt5::WebEngineWidgets ${libmessageviewer_web_LIB}) set(libmessageviewer_web_LIB Qt5::WebEngine Qt5::WebEngineWidgets ${libmessageviewer_web_LIB})
endif() endif()
......
...@@ -25,11 +25,16 @@ ...@@ -25,11 +25,16 @@
//#define KMAIL_READER_HTML_DEBUG 1 //#define KMAIL_READER_HTML_DEBUG 1
#include "viewer.h" #include "viewer.h"
#include "config-messageviewer.h"
#include "viewer_p.h" #include "viewer_p.h"
#include "widgets/configurewidget.h" #include "widgets/configurewidget.h"
#include "csshelper.h" #include "csshelper.h"
#include "settings/messageviewersettings.h" #include "settings/messageviewersettings.h"
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE
#include "viewer/webengine/mailwebengineview.h"
#else
#include "viewer/webview/mailwebview.h" #include "viewer/webview/mailwebview.h"
#endif
#include "viewer/mimeparttree/mimetreemodel.h" #include "viewer/mimeparttree/mimetreemodel.h"
#include "viewer/mimeparttree/mimeparttreeview.h" #include "viewer/mimeparttree/mimeparttreeview.h"
#include "widgets/zoomactionmenu.h" #include "widgets/zoomactionmenu.h"
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
//#define MESSAGEVIEWER_READER_HTML_DEBUG 1 //#define MESSAGEVIEWER_READER_HTML_DEBUG 1
#include "viewer_p.h" #include "viewer_p.h"
#include "viewer.h" #include "viewer.h"
#include "messageviewer_debug.h" #include "messageviewer_debug.h"
...@@ -112,8 +111,6 @@ ...@@ -112,8 +111,6 @@
#include "csshelper.h" #include "csshelper.h"
#include "settings/messageviewersettings.h" #include "settings/messageviewersettings.h"
#include "widgets/htmlstatusbar.h" #include "widgets/htmlstatusbar.h"
#include "htmlwriter/webkitparthtmlwriter.h"
#include "widgets/mailsourceviewer.h"
#include "viewer/mimeparttree/mimetreemodel.h" #include "viewer/mimeparttree/mimetreemodel.h"
#include <MimeTreeParser/NodeHelper> #include <MimeTreeParser/NodeHelper>
#include <MimeTreeParser/ObjectTreeParser> #include <MimeTreeParser/ObjectTreeParser>
...@@ -124,7 +121,12 @@ ...@@ -124,7 +121,12 @@
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE #ifdef MESSAGEVIEWER_USE_QTWEBENGINE
#include "findbar/findbarwebengineview.h" #include "findbar/findbarwebengineview.h"
#include "viewer/webengine/mailwebengineview.h" #include "viewer/webengine/mailwebengineview.h"
#include <QWebEngineSettings>
#include "htmlwriter/webengineparthtmlwriter.h"
#include <widgets/mailsourcewebengineviewer.h>
#else #else
#include "widgets/mailsourceviewer.h"
#include "htmlwriter/webkitparthtmlwriter.h"
#include "viewer/webview/mailwebview.h" #include "viewer/webview/mailwebview.h"
#include "findbar/findbarwebview.h" #include "findbar/findbarwebview.h"
#endif #endif
...@@ -1050,12 +1052,14 @@ void ViewerPrivate::initHtmlWidget() ...@@ -1050,12 +1052,14 @@ void ViewerPrivate::initHtmlWidget()
} }
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE #ifdef MESSAGEVIEWER_USE_QTWEBENGINE
//TODO //TODO
connect(mViewer, &MailWebEngineView::linkHovered, connect(mViewer->page(), &QWebEnginePage::linkHovered,
this, &ViewerPrivate::slotUrlOn); this, &ViewerPrivate::slotUrlOn);
#if 0 //PORTING
connect(mViewer, &MailWebEngineView::linkClicked, connect(mViewer, &MailWebEngineView::linkClicked,
this, &ViewerPrivate::slotUrlOpen, Qt::QueuedConnection); this, &ViewerPrivate::slotUrlOpen, Qt::QueuedConnection);
connect(mViewer, &MailWebEngineView::popupMenu, connect(mViewer, &MailWebEngineView::popupMenu,
this, &ViewerPrivate::slotUrlPopup); this, &ViewerPrivate::slotUrlPopup);
#endif
connect(mViewer, &MailWebEngineView::messageMayBeAScam, this, &ViewerPrivate::slotMessageMayBeAScam); connect(mViewer, &MailWebEngineView::messageMayBeAScam, this, &ViewerPrivate::slotMessageMayBeAScam);
connect(mScamDetectionWarning, &ScamDetectionWarningWidget::showDetails, mViewer, &MailWebEngineView::slotShowDetails); connect(mScamDetectionWarning, &ScamDetectionWarningWidget::showDetails, mViewer, &MailWebEngineView::slotShowDetails);
#else #else
...@@ -1162,7 +1166,7 @@ void ViewerPrivate::readConfig() ...@@ -1162,7 +1166,7 @@ void ViewerPrivate::readConfig()
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE #ifdef MESSAGEVIEWER_USE_QTWEBENGINE
mViewer->settings()->setFontSize(QWebEngineSettings::MinimumFontSize, MessageViewer::MessageViewerSettings::self()->minimumFontSize()); mViewer->settings()->setFontSize(QWebEngineSettings::MinimumFontSize, MessageViewer::MessageViewerSettings::self()->minimumFontSize());
mViewer->settings()->setFontSize(QWebEngineSettings::MinimumLogicalFontSize, MessageViewer::MessageViewerSettings::self()->minimumFontSize()); mViewer->settings()->setFontSize(QWebEngineSettings::MinimumLogicalFontSize, MessageViewer::MessageViewerSettings::self()->minimumFontSize());
mViewer->settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, MessageViewer::MessageViewerSettings::self()->printBackgroundColorImages()); //FIXME mViewer->settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, MessageViewer::MessageViewerSettings::self()->printBackgroundColorImages());
#else #else
mViewer->settings()->setFontSize(QWebSettings::MinimumFontSize, MessageViewer::MessageViewerSettings::self()->minimumFontSize()); mViewer->settings()->setFontSize(QWebSettings::MinimumFontSize, MessageViewer::MessageViewerSettings::self()->minimumFontSize());
mViewer->settings()->setFontSize(QWebSettings::MinimumLogicalFontSize, MessageViewer::MessageViewerSettings::self()->minimumFontSize()); mViewer->settings()->setFontSize(QWebSettings::MinimumLogicalFontSize, MessageViewer::MessageViewerSettings::self()->minimumFontSize());
...@@ -2015,15 +2019,17 @@ void ViewerPrivate::slotUrlOpen(const QUrl &url) ...@@ -2015,15 +2019,17 @@ void ViewerPrivate::slotUrlOpen(const QUrl &url)
Q_EMIT urlClicked(mMessageItem, mClickedUrl); Q_EMIT urlClicked(mMessageItem, mClickedUrl);
} }
void ViewerPrivate::slotUrlOn(const QString &link, const QString &title, const QString &textContent) void ViewerPrivate::slotUrlOn(const QString &link)
{ {
Q_UNUSED(title)
Q_UNUSED(textContent)
// The "link" we get here is not URL-encoded, and therefore there is no way QUrl could // The "link" we get here is not URL-encoded, and therefore there is no way QUrl could
// parse it correctly. To workaround that, we use QWebFrame::hitTestContent() on the mouse position // parse it correctly. To workaround that, we use QWebFrame::hitTestContent() on the mouse position
// to get the URL before WebKit managed to mangle it. // to get the URL before WebKit managed to mangle it.
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE
//TODO
QUrl url(link);
#else
QUrl url(mViewer->linkOrImageUrlAt(QCursor::pos())); QUrl url(mViewer->linkOrImageUrlAt(QCursor::pos()));
#endif
const QString protocol = url.scheme(); const QString protocol = url.scheme();
if (protocol == QLatin1String("kmail") || if (protocol == QLatin1String("kmail") ||
protocol == QLatin1String("x-kmail") || protocol == QLatin1String("x-kmail") ||
...@@ -2127,13 +2133,11 @@ void ViewerPrivate::slotShowMessageSource() ...@@ -2127,13 +2133,11 @@ void ViewerPrivate::slotShowMessageSource()
mNodeHelper->messageWithExtraContent(mMessage.data()); mNodeHelper->messageWithExtraContent(mMessage.data());
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE #ifdef MESSAGEVIEWER_USE_QTWEBENGINE
//TODO
MailSourceWebEngineViewer *viewer = new MailSourceWebEngineViewer(); // deletes itself upon close MailSourceWebEngineViewer *viewer = new MailSourceWebEngineViewer(); // deletes itself upon close
viewer->setWindowTitle(i18n("Message as Plain Text")); viewer->setWindowTitle(i18n("Message as Plain Text"));
const QString rawMessage = QString::fromLatin1(mMessage->encodedContent()); const QString rawMessage = QString::fromLatin1(mMessage->encodedContent());
viewer->setRawSource(rawMessage); viewer->setRawSource(rawMessage);
//const QString htmlSource = mViewer->page()->mainFrame()->documentElement().toOuterXml(); viewer->setDisplayedSource(mViewer->page());
viewer->setDisplayedSource(htmlSource);
if (mUseFixedFont) { if (mUseFixedFont) {
viewer->setFixedFont(); viewer->setFixedFont();
} }
...@@ -2186,8 +2190,11 @@ void ViewerPrivate::updateReaderWin() ...@@ -2186,8 +2190,11 @@ void ViewerPrivate::updateReaderWin()
} }
mRecursionCountForDisplayMessage++; mRecursionCountForDisplayMessage++;
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE
mViewer->setAllowExternalContent(htmlLoadExternal()); mViewer->setAllowExternalContent(htmlLoadExternal());
#else
mViewer->setAllowExternalContent(htmlLoadExternal());
#endif
htmlWriter()->reset(); htmlWriter()->reset();
//TODO: if the item doesn't have the payload fetched, try to fetch it? Maybe not here, but in setMessageItem. //TODO: if the item doesn't have the payload fetched, try to fetch it? Maybe not here, but in setMessageItem.
if (mMessage) { if (mMessage) {
...@@ -2310,7 +2317,6 @@ void ViewerPrivate::slotPrintMsg() ...@@ -2310,7 +2317,6 @@ void ViewerPrivate::slotPrintMsg()
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE #ifdef MESSAGEVIEWER_USE_QTWEBENGINE
qDebug() << " ViewerPrivate::slotPrintMsg() not implemented"; qDebug() << " ViewerPrivate::slotPrintMsg() not implemented";
#else #else
QPrinter printer; QPrinter printer;
QScopedPointer<QPrintDialog> dlg(new QPrintDialog(&printer)); QScopedPointer<QPrintDialog> dlg(new QPrintDialog(&printer));
......
...@@ -480,7 +480,7 @@ public Q_SLOTS: ...@@ -480,7 +480,7 @@ public Q_SLOTS:
void slotUrlOpen(const QUrl &url = QUrl()); void slotUrlOpen(const QUrl &url = QUrl());
/** The mouse has moved on or off an URL. */ /** The mouse has moved on or off an URL. */
void slotUrlOn(const QString &link, const QString &title, const QString &textContent); void slotUrlOn(const QString &link);
/** The user presses the right mouse button on an URL. */ /** The user presses the right mouse button on an URL. */
void slotUrlPopup(const QUrl &, const QUrl &imageUrl, const QPoint &mousePos); void slotUrlPopup(const QUrl &, const QUrl &imageUrl, const QPoint &mousePos);
...@@ -608,8 +608,8 @@ public: ...@@ -608,8 +608,8 @@ public:
MimePartTreeView *mMimePartTree; MimePartTreeView *mMimePartTree;
#endif #endif
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE #ifdef MESSAGEVIEWER_USE_QTWEBENGINE
FindBarWebEngineView *mFindBar;
MailWebEngineView *mViewer; MailWebEngineView *mViewer;
FindBarWebEngineView *mFindBar;
#else #else
MailWebView *mViewer; MailWebView *mViewer;
FindBarWebView *mFindBar; FindBarWebView *mFindBar;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment