Commit e0a99b1e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make it works

parent c7308487
...@@ -212,7 +212,7 @@ void MailWebEngineAccessKey::keyReleaseEvent(QKeyEvent *e) ...@@ -212,7 +212,7 @@ void MailWebEngineAccessKey::keyReleaseEvent(QKeyEvent *e)
// Activate only when the CTRL key is pressed and released by itself. // Activate only when the CTRL key is pressed and released by itself.
if (e->key() == Qt::Key_Control && e->modifiers() == Qt::NoModifier) { if (e->key() == Qt::Key_Control && e->modifiers() == Qt::NoModifier) {
showAccessKeys(); showAccessKeys();
d->mAccessKeyActivated = MailWebEngineAccessKeyPrivate::Activated;
} else { } else {
d->mAccessKeyActivated = MailWebEngineAccessKeyPrivate::NotActivated; d->mAccessKeyActivated = MailWebEngineAccessKeyPrivate::NotActivated;
} }
...@@ -273,24 +273,18 @@ bool MailWebEngineAccessKey::checkForAccessKey(QKeyEvent *event) ...@@ -273,24 +273,18 @@ bool MailWebEngineAccessKey::checkForAccessKey(QKeyEvent *event)
} }
QChar key = text.at(0).toUpper(); QChar key = text.at(0).toUpper();
bool handled = false; bool handled = false;
qDebug()<<" sssssssssssssssss";
if (d->mAccessKeyNodes.contains(key)) { if (d->mAccessKeyNodes.contains(key)) {
//qDebug()<<" MailWebEngineAccessKey::checkForAccessKey****"<<key; qDebug()<<" MailWebEngineAccessKey::checkForAccessKey****"<<key;
MessageViewer::MailWebEngineAccessKeyAnchor element = d->mAccessKeyNodes[key]; MessageViewer::MailWebEngineAccessKeyAnchor element = d->mAccessKeyNodes[key];
QPoint p = element.boundingRect().center(); if (element.tagName().compare(QLatin1String("A"), Qt::CaseInsensitive) == 0) {
#if 0 const QString linkKey(linkElementKey(element, d->mWebEngine->url()));
QWebFrame *frame = element.webFrame(); if (!linkKey.isEmpty()) {
Q_ASSERT(frame); Q_EMIT openUrl(QUrl(linkKey));
do {
p -= frame->scrollPosition();
frame = frame->parentFrame();
} while (frame && frame != d->mWebView->page()->mainFrame());
#endif
QMouseEvent pevent(QEvent::MouseButtonPress, p, Qt::LeftButton, 0, 0);
QCoreApplication::sendEvent(this, &pevent);
QMouseEvent revent(QEvent::MouseButtonRelease, p, Qt::LeftButton, 0, 0);
QCoreApplication::sendEvent(this, &revent);
handled = true; handled = true;
} }
}
}
return handled; return handled;
} }
...@@ -392,11 +386,13 @@ void MailWebEngineAccessKey::handleSearchAccessKey(const QVariant &res) ...@@ -392,11 +386,13 @@ void MailWebEngineAccessKey::handleSearchAccessKey(const QVariant &res)
makeAccessKeyLabel(accessKey, element); makeAccessKeyLabel(accessKey, element);
} }
} }
d->mAccessKeyActivated = (d->mAccessKeyLabels.isEmpty() ? MailWebEngineAccessKeyPrivate::Activated : MailWebEngineAccessKeyPrivate::NotActivated); d->mAccessKeyActivated = (!d->mAccessKeyLabels.isEmpty() ? MailWebEngineAccessKeyPrivate::Activated : MailWebEngineAccessKeyPrivate::NotActivated);
qDebug()<<" d->mAccessKeyActivated"<<d->mAccessKeyActivated;
} }
void MailWebEngineAccessKey::showAccessKeys() void MailWebEngineAccessKey::showAccessKeys()
{ {
d->mAccessKeyActivated = MailWebEngineAccessKeyPrivate::Activated;
d->mWebEngine->page()->runJavaScript(MessageViewer::MailWebEngineAccessKeyUtils::script(), invoke(this, &MailWebEngineAccessKey::handleSearchAccessKey)); d->mWebEngine->page()->runJavaScript(MessageViewer::MailWebEngineAccessKeyUtils::script(), invoke(this, &MailWebEngineAccessKey::handleSearchAccessKey));
} }
...@@ -48,6 +48,8 @@ public: ...@@ -48,6 +48,8 @@ public:
void makeAccessKeyLabel(QChar accessKey, const MessageViewer::MailWebEngineAccessKeyAnchor &element); void makeAccessKeyLabel(QChar accessKey, const MessageViewer::MailWebEngineAccessKeyAnchor &element);
bool checkForAccessKey(QKeyEvent *event); bool checkForAccessKey(QKeyEvent *event);
Q_SIGNALS:
void openUrl(const QUrl &url);
public Q_SLOTS: public Q_SLOTS:
void hideAccessKeys(); void hideAccessKeys();
......
...@@ -46,6 +46,7 @@ MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent) ...@@ -46,6 +46,7 @@ MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent)
d->mWebViewAccessKey = new MailWebEngineAccessKey(this, this); d->mWebViewAccessKey = new MailWebEngineAccessKey(this, this);
d->mWebViewAccessKey->setActionCollection(ac); d->mWebViewAccessKey->setActionCollection(ac);
d->mScamDetection = new ScamDetectionWebEngine(this); d->mScamDetection = new ScamDetectionWebEngine(this);
connect(d->mWebViewAccessKey, &MailWebEngineAccessKey::openUrl, this, &MailWebEngineView::openUrl);
new MessageViewer::NetworkAccessManagerWebEngine(this, ac, this); new MessageViewer::NetworkAccessManagerWebEngine(this, ac, this);
MailWebEnginePage *pageEngine = new MailWebEnginePage(this); MailWebEnginePage *pageEngine = new MailWebEnginePage(this);
......
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