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

Improve popupmenu action

parent 6c5fc4b8
......@@ -175,7 +175,6 @@ void ScamDetectionWebEngine::showDetails()
if (!d->mDetailsDialog) {
d->mDetailsDialog = new MessageViewer::ScamDetectionDetailsDialog;
}
d->mDetailsDialog->setDetails(d->mDetails);
d->mDetailsDialog->show();
}
......@@ -124,6 +124,7 @@
#include <QWebEngineSettings>
#include "htmlwriter/webengineparthtmlwriter.h"
#include <widgets/mailsourcewebengineviewer.h>
#include <MessageViewer/WebHitTestResult>
#else
#include "widgets/mailsourceviewer.h"
#include "htmlwriter/webkitparthtmlwriter.h"
......@@ -153,6 +154,7 @@
#include <widgets/zoomactionmenu.h>
#include <kpimtextedit/texttospeechwidget.h>
#include <grantleetheme/grantleethememanager.h>
#include <grantleetheme/grantleetheme.h>
......@@ -2052,7 +2054,33 @@ void ViewerPrivate::slotUrlOn(const QString &link)
KPIM::BroadcastStatus::instance()->setTransientStatusMsg(msg);
Q_EMIT showStatusBarMessage(msg);
}
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE
void ViewerPrivate::slotUrlPopup(const MessageViewer::WebHitTestResult &result)
{
if (!mMsgDisplay) {
return;
}
mClickedUrl = result.linkUrl();
mImageUrl = result.imageUrl();
const QPoint aPos = mViewer->mapToGlobal(result.pos());
if (URLHandlerManager::instance()->handleContextMenuRequest(mClickedUrl, aPos, this)) {
return;
}
if (!mActionCollection) {
return;
}
if (mClickedUrl.scheme() == QLatin1String("mailto")) {
mCopyURLAction->setText(i18n("Copy Email Address"));
} else {
mCopyURLAction->setText(i18n("Copy Link Address"));
}
Q_EMIT popupMenu(mMessageItem, mClickedUrl, mImageUrl, aPos);
}
#else
void ViewerPrivate::slotUrlPopup(const QUrl &aUrl, const QUrl &imageUrl, const QPoint &aPos)
{
if (!mMsgDisplay) {
......@@ -2077,6 +2105,7 @@ void ViewerPrivate::slotUrlPopup(const QUrl &aUrl, const QUrl &imageUrl, const Q
Q_EMIT popupMenu(mMessageItem, aUrl, imageUrl, aPos);
}
#endif
void ViewerPrivate::slotLoadExternalReference()
{
......
......@@ -79,6 +79,7 @@ class CSSHelper;
class FindBarWebEngineView;
class MailWebEngineView;
class WebEnginePartHtmlWriter;
class WebHitTestResult;
#else
class FindBarWebView;
class MailWebView;
......@@ -483,7 +484,11 @@ public Q_SLOTS:
void slotUrlOn(const QString &link);
/** The user presses the right mouse button on an URL. */
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE
void slotUrlPopup(const MessageViewer::WebHitTestResult &result);
#else
void slotUrlPopup(const QUrl &, const QUrl &imageUrl, const QPoint &mousePos);
#endif
/** The user selected "Find" from the menu. */
void slotFind();
......
......@@ -106,7 +106,7 @@ void MailWebEngineView::contextMenuEvent(QContextMenuEvent *e)
void MailWebEngineView::slotWebHitFinished(const MessageViewer::WebHitTestResult &result)
{
Q_EMIT popupMenu(result.linkUrl(), result.imageUrl(), mapToGlobal(result.pos()));
Q_EMIT popupMenu(result);
}
void MailWebEngineView::scrollUp(int pixels)
......
......@@ -78,12 +78,13 @@ Q_SIGNALS:
/// 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);
void popupMenu(const MessageViewer::WebHitTestResult &result);
private Q_SLOTS:
void handleScrollToAnchor(const QVariant &result);
void slotWebHitFinished(const MessageViewer::WebHitTestResult &result);
void slotLoadFinished();
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