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

Reactivate menu

parent e09428c0
......@@ -1051,15 +1051,12 @@ void ViewerPrivate::initHtmlWidget()
#endif
}
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE
//TODO
connect(mViewer->page(), &QWebEnginePage::linkHovered,
this, &ViewerPrivate::slotUrlOn);
connect(mViewer, &MailWebEngineView::openUrl,
this, &ViewerPrivate::slotUrlOpen, Qt::QueuedConnection);
#if 0 //PORTING
connect(mViewer, &MailWebEngineView::popupMenu,
this, &ViewerPrivate::slotUrlPopup);
#endif
connect(mViewer, &MailWebEngineView::messageMayBeAScam, this, &ViewerPrivate::slotMessageMayBeAScam);
connect(mScamDetectionWarning, &ScamDetectionWarningWidget::showDetails, mViewer, &MailWebEngineView::slotShowDetails);
#else
......@@ -2012,6 +2009,7 @@ void ViewerPrivate::slotUrlOpen(const QUrl &url)
// known URLs, otherwise fallback to emitting a signal.
// That signal is caught by KMail, and in case of mailto URLs, a composer is shown.
qDebug()<<" void ViewerPrivate::slotUrlOpen(const QUrl &url)"<<url;
if (URLHandlerManager::instance()->handleClick(mClickedUrl, this)) {
return;
}
......
......@@ -25,6 +25,9 @@
#include "scamdetection/scamdetectionwebengine.h"
#include "scamdetection/scamcheckshorturl.h"
#include <QContextMenuEvent>
#include <MessageViewer/WebHitTest>
#include <MessageViewer/WebHitTestResult>
using namespace MessageViewer;
template<typename Arg, typename R, typename C>
......@@ -51,13 +54,15 @@ public:
MailWebEngineViewPrivate()
: mScamDetection(Q_NULLPTR),
mWebViewAccessKey(Q_NULLPTR),
mExternalReference(Q_NULLPTR)
mExternalReference(Q_NULLPTR),
mPageEngine(Q_NULLPTR)
{
}
ScamDetectionWebEngine *mScamDetection;
MailWebEngineAccessKey *mWebViewAccessKey;
MessageViewer::LoadExternalReferencesUrlInterceptor *mExternalReference;
MailWebEnginePage *mPageEngine;
};
MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent)
......@@ -74,11 +79,11 @@ MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent)
MessageViewer::NetworkAccessManagerWebEngine *networkAccessManager = new MessageViewer::NetworkAccessManagerWebEngine(this, ac, this);
d->mExternalReference = new MessageViewer::LoadExternalReferencesUrlInterceptor(this);
networkAccessManager->addInterceptor(d->mExternalReference);
MailWebEnginePage *pageEngine = new MailWebEnginePage(this);
setPage(pageEngine);
d->mPageEngine = new MailWebEnginePage(this);
setPage(d->mPageEngine);
setFocusPolicy(Qt::WheelFocus);
connect(pageEngine, &MailWebEnginePage::urlClicked, this, &MailWebEngineView::openUrl);
connect(d->mPageEngine, &MailWebEnginePage::urlClicked, this, &MailWebEngineView::openUrl);
//TODO need info about scrolling
}
......@@ -87,6 +92,18 @@ MailWebEngineView::~MailWebEngineView()
delete d;
}
void MailWebEngineView::contextMenuEvent(QContextMenuEvent *e)
{
MessageViewer::WebHitTest *webHit = d->mPageEngine->hitTestContent(e->pos());
connect(webHit, &MessageViewer::WebHitTest::finished, this, &MailWebEngineView::slotWebHitFinished);
}
void MailWebEngineView::slotWebHitFinished(const MessageViewer::WebHitTestResult &result)
{
Q_EMIT popupMenu(result.linkUrl(), result.imageUrl(), mapToGlobal(result.pos()));
// Q_EMIT popupMenu(const QUrl &url, const QUrl &imageUrl, const QPoint &point);
}
void MailWebEngineView::scrollUp(int pixels)
{
page()->runJavaScript(MessageViewer::WebEngineScript::scrollUp(pixels));
......
......@@ -23,6 +23,7 @@
class KActionCollection;
namespace MessageViewer
{
class WebHitTestResult;
class MailWebEngineViewPrivate;
class MESSAGEVIEWER_EXPORT MailWebEngineView : public MessageViewer::WebEngineView
{
......@@ -73,13 +74,19 @@ protected:
void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE;
Q_SIGNALS:
void openUrl(const QUrl &url);
void messageMayBeAScam();
/// Emitted when the user right-clicks somewhere
/// @param url if an URL was under the cursor, this parameter contains it. Otherwise empty
/// @param point position where the click happened, in local coordinates
void popupMenu(const QUrl &url, const QUrl &imageUrl, const QPoint &point);
private Q_SLOTS:
void handleScrollToAnchor(const QVariant &result);
void slotWebHitFinished(const MessageViewer::WebHitTestResult &result);
private:
MailWebEngineViewPrivate *const d;
};
......
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