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