Commit 7f6a15b8 authored by Laurent Montel's avatar Laurent Montel 😁

Add more javascript script

parent 40bcd0f7
...@@ -259,22 +259,12 @@ void MailWebEngineView::scrollPageUp(int percent) ...@@ -259,22 +259,12 @@ void MailWebEngineView::scrollPageUp(int percent)
void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml) void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml)
{ {
const QString html = delayedHtml(); const QString html = delayedHtml();
qDebug()<<" void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml) not implemented " << delayedHtml;
if (html.isEmpty()) { if (html.isEmpty()) {
return; return;
} }
//TODO qDebug()<<" void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml) " << html;
#if 0 //TODO verify
QWebElement doc = page()->currentFrame()->documentElement(); page()->runJavaScript(MessageViewer::WebEngineScript::injectAttachments(html, QStringLiteral("*#attachmentInjectionPoint")));
QWebElement injectionPoint = doc.findFirst(QStringLiteral("*#attachmentInjectionPoint"));
if (injectionPoint.isNull()) {
return;
}
assert(injectionPoint.tagName().toLower() == QLatin1String("div"));
injectionPoint.setInnerXml(html)
#endif
} }
bool MailWebEngineView::replaceInnerHtml(const QString &id, const boost::function<QString()> &delayedHtml) bool MailWebEngineView::replaceInnerHtml(const QString &id, const boost::function<QString()> &delayedHtml)
......
...@@ -187,3 +187,12 @@ QString WebEngineScript::replaceInnerHtml() ...@@ -187,3 +187,12 @@ QString WebEngineScript::replaceInnerHtml()
//TODO //TODO
return {}; return {};
} }
QString WebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr)
{
const QString source = QString::fromLatin1("var element = document.getElementById('%1'); "
"if (element) { "
" element.innerHTML = '%2';"
"}").arg(elementStr).arg(delayedHtml);
return source;
}
...@@ -39,6 +39,7 @@ MESSAGEVIEWER_EXPORT QString scrollPercentage(int percent); ...@@ -39,6 +39,7 @@ MESSAGEVIEWER_EXPORT QString scrollPercentage(int percent);
MESSAGEVIEWER_EXPORT QString scrollToRelativePosition(int pos); MESSAGEVIEWER_EXPORT QString scrollToRelativePosition(int pos);
MESSAGEVIEWER_EXPORT QString removeStyleToElement(const QString &element); MESSAGEVIEWER_EXPORT QString removeStyleToElement(const QString &element);
MESSAGEVIEWER_EXPORT QString replaceInnerHtml(); MESSAGEVIEWER_EXPORT QString replaceInnerHtml();
MESSAGEVIEWER_EXPORT QString injectAttachments(const QString &delayedHtml, const QString &element);
} }
} }
#endif // WEBENGINESCRIPT_H #endif // WEBENGINESCRIPT_H
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