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

We need to clear selection when we switch message (it's an qtwebengine bug)

parent 8ee4bee6
......@@ -251,8 +251,7 @@ void Viewer::slotScrollNext()
QString Viewer::selectedText() const
{
Q_D(const Viewer);
QString temp = d->mViewer->selectedText();
return temp;
return d->mViewer->selectedText();
}
Viewer::DisplayFormatMessage Viewer::displayFormatMessageOverwrite() const
......
......@@ -1290,6 +1290,9 @@ void ViewerPrivate::printPreviewMessage(const Akonadi::Item &message)
void ViewerPrivate::resetStateForNewMessage()
{
#ifdef MESSAGEVIEWER_USE_QTWEBENGINE
mViewer->clearSelection();
#endif
mClickedUrl.clear();
mImageUrl.clear();
enableMessageDisplay(); // just to make sure it's on
......
......@@ -80,3 +80,4 @@ QString MailWebEngineScript::toggleFullAddressList(const QString &field, const Q
qDebug() << "QString MailWebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr) :" << source;
return source;
}
......@@ -267,6 +267,11 @@ void MailWebEngineView::toggleFullAddressList(const QString &field, const boost:
page()->runJavaScript(MessageViewer::MailWebEngineScript::replaceInnerHtml(field, html, doShow), invoke(this, &MailWebEngineView::updateToggleFullAddressList));
}
void MailWebEngineView::clearSelection()
{
page()->runJavaScript(WebEngineViewer::WebEngineScript::clearSelection());
}
void MailWebEngineView::updateToggleFullAddressList(const QVariant &result)
{
//qDebug() << " result" << result;
......
......@@ -64,6 +64,7 @@ public:
QList<QAction *> interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const;
void toggleFullAddressList(const QString &field, const boost::function<QString()> &delayedHtml, bool doShow);
void clearSelection();
public Q_SLOTS:
void slotZoomChanged(qreal zoom);
void slotShowDetails();
......
......@@ -189,3 +189,11 @@ QString WebEngineScript::scrollToRelativePosition(int pos)
const QString source = QString::fromLatin1("window.scrollTo(window.scrollX, %1); [window.scrollX, window.scrollY];").arg(pos);
return source;
}
QString WebEngineScript::clearSelection()
{
const QString source = QString::fromLatin1("if(\"document.selection\") {"
" document.selection.clear ();"
"};");
return source;
}
......@@ -38,6 +38,7 @@ WEBENGINEVIEWER_EXPORT QString scrollUp(int pixel);
WEBENGINEVIEWER_EXPORT QString scrollPercentage(int percent);
WEBENGINEVIEWER_EXPORT QString scrollToRelativePosition(int pos);
WEBENGINEVIEWER_EXPORT QString removeStyleToElement(const QString &element);
WEBENGINEVIEWER_EXPORT QString clearSelection();
}
}
#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