Commit 3fb1a170 authored by Laurent Montel's avatar Laurent Montel 😁

Minor

parent 9ee29e96
......@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
set(MESSAGELIB_LIB_VERSION "5.1.75")
set(MESSAGELIB_LIB_VERSION "5.1.76")
set(KF5_VERSION "5.19.0")
set(KDEPIMLIBS_LIB_VERSION "5.1.42")
......
......@@ -57,19 +57,20 @@ TestWebEngineView::TestWebEngineView(QWidget *parent)
void TestWebEngineView::contextMenuEvent(QContextMenuEvent *e)
{
qDebug() << " void TestWebEngine::contextMenuEvent(QContextMenuEvent *e)";
const MessageViewer::WebHitTestResult webHit = static_cast<MessageViewer::WebEnginePage *>(page())->hitTestContent(e->pos());
MessageViewer::WebHitTestResult *webHit = static_cast<MessageViewer::WebEnginePage *>(page())->hitTestContent(e->pos());
qDebug() << " alternateText" << webHit.alternateText();
qDebug() << " boundingRect" << webHit.boundingRect();
qDebug() << " imageUrl" << webHit.imageUrl();
qDebug() << " isContentEditable" << webHit.isContentEditable();
qDebug() << " isContentSelected" << webHit.isContentSelected();
qDebug() << " isNull" << webHit.isNull();
qDebug() << " linkTitle" << webHit.linkTitle();
qDebug() << " linkUrl" << webHit.linkUrl();
qDebug() << " mediaUrl" << webHit.mediaUrl();
qDebug() << " mediaPaused" << webHit.mediaPaused();
qDebug() << " mediaMuted" << webHit.mediaMuted();
qDebug() << " pos" << webHit.pos();
qDebug() << " tagName" << webHit.tagName();
qDebug() << " alternateText" << webHit->alternateText();
qDebug() << " boundingRect" << webHit->boundingRect();
qDebug() << " imageUrl" << webHit->imageUrl();
qDebug() << " isContentEditable" << webHit->isContentEditable();
qDebug() << " isContentSelected" << webHit->isContentSelected();
qDebug() << " isNull" << webHit->isNull();
qDebug() << " linkTitle" << webHit->linkTitle();
qDebug() << " linkUrl" << webHit->linkUrl();
qDebug() << " mediaUrl" << webHit->mediaUrl();
qDebug() << " mediaPaused" << webHit->mediaPaused();
qDebug() << " mediaMuted" << webHit->mediaMuted();
qDebug() << " pos" << webHit->pos();
qDebug() << " tagName" << webHit->tagName();
delete webHit;
}
......@@ -45,9 +45,9 @@ WebEnginePage::~WebEnginePage()
delete d;
}
MessageViewer::WebHitTestResult WebEnginePage::hitTestContent(const QPoint &pos)
MessageViewer::WebHitTestResult *WebEnginePage::hitTestContent(const QPoint &pos)
{
return WebHitTestResult(this, pos);
return new WebHitTestResult(this, pos);
}
QVariant WebEnginePage::execJavaScript(const QString &scriptSource, int timeout)
......
......@@ -31,7 +31,7 @@ class MESSAGEVIEWER_EXPORT WebEnginePage : public QWebEnginePage
public:
explicit WebEnginePage(QObject *parent = Q_NULLPTR);
~WebEnginePage();
WebHitTestResult hitTestContent(const QPoint &pos);
WebHitTestResult *hitTestContent(const QPoint &pos);
QVariant execJavaScript(const QString &scriptSource, int timeout = 500);
private:
......
......@@ -37,14 +37,34 @@
#include <QWebEnginePage>
using namespace MessageViewer;
template<typename Arg, typename R, typename C>
WebHitTestResult::WebHitTestResult(WebEnginePage *page, const QPoint &pos)
: m_isNull(true)
, m_isContentEditable(false)
, m_isContentSelected(false)
, m_mediaPaused(false)
, m_mediaMuted(false)
, m_pos(pos)
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;
}
WebHitTestResult::WebHitTestResult(WebEnginePage *page, const QPoint &pos, QObject *parent)
: QObject(parent),
m_isNull(true),
m_isContentEditable(false),
m_isContentSelected(false),
m_mediaPaused(false),
m_mediaMuted(false),
m_pos(pos)
{
QString source = QStringLiteral("(function() {"
"var e = document.elementFromPoint(%1, %2);"
......
......@@ -36,6 +36,7 @@
#define WebHitTestResult_H
#include "messageviewer_export.h"
#include <QObject>
#include <QUrl>
#include <QRect>
#include <QString>
......@@ -44,10 +45,11 @@
namespace MessageViewer
{
class WebEnginePage;
class MESSAGEVIEWER_EXPORT WebHitTestResult
class MESSAGEVIEWER_EXPORT WebHitTestResult : public QObject
{
Q_OBJECT
public:
explicit WebHitTestResult(MessageViewer::WebEnginePage *page, const QPoint &pos);
explicit WebHitTestResult(MessageViewer::WebEnginePage *page, const QPoint &pos, QObject *parent = Q_NULLPTR);
~WebHitTestResult();
QString alternateText() const;
QRect boundingRect() const;
......@@ -63,6 +65,9 @@ public:
QPoint pos() const;
QString tagName() const;
Q_SIGNALS:
void finished(WebHitTestResult *);
private:
void init(const QUrl &url, const QVariantMap &map);
......
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