summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-03-30 08:07:57 +0200
committerMontel Laurent <[email protected]>2016-03-30 08:07:57 +0200
commitfee23ccf113c78bcea5f9fcf3652c4f2f1f6aae1 (patch)
tree6e4e1d1a31c146e1f56f42b641cf45df753528b2
parente09428c07e03aa2573383678b72d30abb7544b89 (diff)
Reactivate menu
-rw-r--r--messageviewer/src/viewer/viewer_p.cpp4
-rw-r--r--messageviewer/src/viewer/webengine/mailwebengineview.cpp25
-rw-r--r--messageviewer/src/viewer/webengine/mailwebengineview.h7
3 files changed, 29 insertions, 7 deletions
diff --git a/messageviewer/src/viewer/viewer_p.cpp b/messageviewer/src/viewer/viewer_p.cpp
index 50414b4..639406d 100644
--- a/messageviewer/src/viewer/viewer_p.cpp
+++ b/messageviewer/src/viewer/viewer_p.cpp
@@ -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;
}
diff --git a/messageviewer/src/viewer/webengine/mailwebengineview.cpp b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
index 475a23d..e0d46bc 100644
--- a/messageviewer/src/viewer/webengine/mailwebengineview.cpp
+++ b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
@@ -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));
diff --git a/messageviewer/src/viewer/webengine/mailwebengineview.h b/messageviewer/src/viewer/webengine/mailwebengineview.h
index a9a69c5..c21673f 100644
--- a/messageviewer/src/viewer/webengine/mailwebengineview.h
+++ b/messageviewer/src/viewer/webengine/mailwebengineview.h
@@ -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;
};