From 7d172fcf39fa2a5d7d5202f20c599eb678f6cb58 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 11 Apr 2016 15:31:36 +0200 Subject: Update spellchecker APIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * marks new properties in QQuickWebEngineProfile as FINAL * removes QT_NO_SPELLCHECK from API headers * renames spellCheckLanguages() to availableDictionaries() * removes "togle spellcheck" methods and actions * use WEBENGINE_CONFIG instead of CONFIG for disable the feature at compile time: WEBENGINE_CONFIG+=no_spellcheck Done-With: Peter Varga Task-number: QTBUG-52371 Change-Id: I8c8eff497b9e7afe0cec2edc97dec248151487f2 Reviewed-by: Michael BrĂ¼ning --- .../api/qwebenginecontextmenudata.cpp | 2 -- .../api/qwebenginecontextmenudata.h | 3 --- src/webenginewidgets/api/qwebenginepage.cpp | 23 ---------------------- src/webenginewidgets/api/qwebenginepage.h | 5 ----- src/webenginewidgets/api/qwebengineprofile.cpp | 10 ++++------ src/webenginewidgets/api/qwebengineprofile.h | 4 +--- src/webenginewidgets/webenginewidgets.pro | 5 +---- 7 files changed, 6 insertions(+), 46 deletions(-) (limited to 'src/webenginewidgets') diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp b/src/webenginewidgets/api/qwebenginecontextmenudata.cpp index ae24016f6..17a562ea1 100644 --- a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp +++ b/src/webenginewidgets/api/qwebenginecontextmenudata.cpp @@ -186,7 +186,6 @@ bool QWebEngineContextMenuData::isContentEditable() const return d ? d->isEditable : false; } -#if !defined(QT_NO_SPELLCHECK) /*! If the context is a word considered misspelled by the spell-checker, returns the misspelled word. */ @@ -206,7 +205,6 @@ QStringList QWebEngineContextMenuData::spellCheckerSuggestions() const return d->spellCheckerSuggestions; return QStringList(); } -#endif /*! \internal diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.h b/src/webenginewidgets/api/qwebenginecontextmenudata.h index 44f1def94..fd1080eec 100644 --- a/src/webenginewidgets/api/qwebenginecontextmenudata.h +++ b/src/webenginewidgets/api/qwebenginecontextmenudata.h @@ -76,11 +76,8 @@ public: QUrl mediaUrl() const; MediaType mediaType() const; bool isContentEditable() const; - -#if !defined(QT_NO_SPELLCHECK) QString misspelledWord() const; QStringList spellCheckerSuggestions() const; -#endif private: void reset(); diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 00dffa3a2..8ba6c8770 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -896,11 +896,6 @@ QAction *QWebEnginePage::action(WebAction action) const case SavePage: text = tr("Save &Page"); break; -#if !defined(QT_NO_SPELLCHECK) - case ToggleSpellcheck: - text = tr("Check Spelling"); - break; -#endif default: break; } @@ -1089,17 +1084,11 @@ void QWebEnginePage::triggerAction(WebAction action, bool) case SavePage: d->adapter->save(); break; -#if !defined(QT_NO_SPELLCHECK) - case ToggleSpellcheck: - d->adapter->toogleSpellCheckEnabled(); - break; -#endif default: Q_UNREACHABLE(); } } -#if !defined(QT_NO_SPELLCHECK) /*! * \since 5.7 * Replace the current misspelled word with \a replacement. @@ -1115,7 +1104,6 @@ void QWebEnginePage::replaceMisspelledWord(const QString &replacement) Q_D(QWebEnginePage); d->adapter->replaceMisspelling(replacement); } -#endif void QWebEnginePage::findText(const QString &subString, FindFlags options, const QWebEngineCallback &resultCallback) { @@ -1298,7 +1286,6 @@ QMenu *QWebEnginePage::createStandardContextMenu() QAction *action = 0; const WebEngineContextMenuData &contextMenuData = *d->contextData.d; -#if !defined(QT_NO_SPELLCHECK) if (contextMenuData.isEditable && !contextMenuData.spellCheckerSuggestions.isEmpty()) { QPointer thisRef(this); for (int i=0; i < contextMenuData.spellCheckerSuggestions.count() && i < 4; i++) { @@ -1310,7 +1297,6 @@ QMenu *QWebEnginePage::createStandardContextMenu() } menu->addSeparator(); } -#endif if (!contextMenuData.linkText.isEmpty() && contextMenuData.linkUrl.isValid()) { action = QWebEnginePage::action(OpenLinkInThisWindow); @@ -1374,15 +1360,6 @@ QMenu *QWebEnginePage::createStandardContextMenu() if (d->isFullScreenMode()) menu->addAction(QWebEnginePage::action(ExitFullScreen)); -#if !defined(QT_NO_SPELLCHECK) - if (contextMenuData.isEditable) { - QAction* spellcheckAction(QWebEnginePage::action(ToggleSpellcheck)); - menu->addAction(spellcheckAction); - spellcheckAction->setCheckable(true); - spellcheckAction->setChecked(contextMenuData.isSpellCheckerEnabled); - } -#endif - return menu; } diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 66d634c77..7b99270c0 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -123,9 +123,6 @@ public: Unselect, SavePage, OpenLinkInNewBackgroundTab, -#if !defined(QT_NO_SPELLCHECK) - ToggleSpellcheck, -#endif WebActionCount }; @@ -209,9 +206,7 @@ public: #endif virtual void triggerAction(WebAction action, bool checked = false); -#if !defined(QT_NO_SPELLCHECK) void replaceMisspelledWord(const QString &replacement); -#endif virtual bool event(QEvent*); #ifdef Q_QDOC diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 22d4d088f..3a2254427 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -555,22 +555,21 @@ QWebEngineProfile *QWebEngineProfile::defaultProfile() return profile; } -#if !defined(QT_NO_SPELLCHECK) /*! \since 5.7 - Returns the subset of \a acceptLanguages supported by the spell checker. + Returns the subset of \a languages supported by the spell checker. Checks whether the spell checker dictionary is installed for the specified - language from the \a acceptLanguages list. If the dictionary file is missing + language from the \a languages list. If the dictionary file is missing or corrupted, the language is removed from the returned list. \sa setSpellCheckLanguage() */ -QStringList QWebEngineProfile::spellCheckLanguages(const QStringList &acceptLanguages) +QStringList QWebEngineProfile::availableDictionaries(const QStringList &languages) { const Q_D(QWebEngineProfile); - return d->browserContext()->spellCheckLanguages(acceptLanguages); + return d->browserContext()->spellCheckLanguages(languages); } /*! @@ -617,7 +616,6 @@ bool QWebEngineProfile::isSpellCheckEnabled() const const Q_D(QWebEngineProfile); return d->browserContext()->isSpellCheckEnabled(); } -#endif /*! Returns the default settings for all pages in this profile. diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h index 1a9bfe43a..9c473eee9 100644 --- a/src/webenginewidgets/api/qwebengineprofile.h +++ b/src/webenginewidgets/api/qwebengineprofile.h @@ -121,13 +121,11 @@ public: void clearHttpCache(); -#if !defined(QT_NO_SPELLCHECK) - QStringList spellCheckLanguages(const QStringList &acceptLanguages); + QStringList availableDictionaries(const QStringList &languages); void setSpellCheckLanguage(const QString &language); QString spellCheckLanguage() const; void setSpellCheckEnabled(bool enabled); bool isSpellCheckEnabled() const; -#endif static QWebEngineProfile *defaultProfile(); diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro index e3f02433c..cd9a2d10b 100644 --- a/src/webenginewidgets/webenginewidgets.pro +++ b/src/webenginewidgets/webenginewidgets.pro @@ -48,10 +48,7 @@ HEADERS = \ DEFINES += QT_UI_DELEGATES } -no_spellcheck { - DEFINES += QT_NO_SPELLCHECK - MODULE_DEFINES += QT_NO_SPELLCHECK -} else { +!contains(WEBENGINE_CONFIG, no_spellcheck) { DEFINES += ENABLE_SPELLCHECK } -- cgit v1.2.3