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