diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-05-11 13:43:45 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-07-02 04:33:41 +0000 |
commit | 42504596248a10eb31a5b719e0676b71f55871e4 (patch) | |
tree | e7f1008595bb417e2b92bcfbb5bf4c0eb71196bf /src/webenginewidgets/api/qwebenginepage.cpp | |
parent | 1e204d3b74fbe275fb4d9fe45bbb011742f828f9 (diff) |
Add back spellchecking support
This reverts commit:
* d364c05de52f9ab39034e56cac4e0a7981dc541d
* e507f140b70f464fb970d2f94357ac588dcc4f03
Moreover it fixes shut down of keyed services,
updates versioning of and fixes spellcheck unit
test context menu request, which otherwise
fails on windows.
Change-Id: I9bfc589544cb969abd6d2d7af69531b4c5c907b7
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/webenginewidgets/api/qwebenginepage.cpp')
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 63fb6eb44..c4dd4604e 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -1127,6 +1127,22 @@ void QWebEnginePage::triggerAction(WebAction action, bool) } } +/*! + * \since 5.8 + * Replace the current misspelled word with \a replacement. + * + * The current misspelled word can be found in QWebEngineContextMenuData::misspelledWord(), + * and suggested replacements in QWebEngineContextMenuData::spellCheckerSuggestions(). + * + * \sa contextMenuData(), + */ + +void QWebEnginePage::replaceMisspelledWord(const QString &replacement) +{ + Q_D(QWebEnginePage); + d->adapter->replaceMisspelling(replacement); +} + void QWebEnginePage::findText(const QString &subString, FindFlags options, const QWebEngineCallback<bool> &resultCallback) { Q_D(QWebEnginePage); @@ -1318,6 +1334,18 @@ QMenu *QWebEnginePage::createStandardContextMenu() QAction *action = 0; const WebEngineContextMenuData &contextMenuData = *d->contextData.d; + if (contextMenuData.isEditable && !contextMenuData.spellCheckerSuggestions.isEmpty()) { + QPointer<QWebEnginePage> thisRef(this); + for (int i=0; i < contextMenuData.spellCheckerSuggestions.count() && i < 4; i++) { + QAction *action = new QAction(menu); + QString replacement = contextMenuData.spellCheckerSuggestions.at(i); + QObject::connect(action, &QAction::triggered, [thisRef, replacement] { if (thisRef) thisRef->replaceMisspelledWord(replacement); }); + action->setText(replacement); + menu->addAction(action); + } + menu->addSeparator(); + } + if (!contextMenuData.linkText.isEmpty() && contextMenuData.linkUrl.isValid()) { action = QWebEnginePage::action(OpenLinkInThisWindow); action->setText(tr("Follow Link")); |