diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-04-28 11:32:24 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-05-06 20:17:08 +0000 |
commit | d364c05de52f9ab39034e56cac4e0a7981dc541d (patch) | |
tree | 66f9fba711bb49536b577ef3552c4ddf7006ad6b /src | |
parent | e87ba5b27bf753498adb00eef53f224c1123d25f (diff) |
Remove spellchecking support
Spellchecking API needs a bit more reviews and love.
Current API is not intuitive and partly broken.
Change-Id: Ie9cd371f38cca2f6b3f56a8699ad874cd332c318
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/webengine/api/qquickwebenginecontextmenudata.cpp | 30 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginecontextmenudata_p.h | 7 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 79 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.h | 7 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 17 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p.h | 2 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginecontextmenudata.cpp | 20 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginecontextmenudata.h | 2 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 28 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.h | 2 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 61 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.h | 5 |
12 files changed, 1 insertions, 259 deletions
diff --git a/src/webengine/api/qquickwebenginecontextmenudata.cpp b/src/webengine/api/qquickwebenginecontextmenudata.cpp index 221b42245..684903ec0 100644 --- a/src/webengine/api/qquickwebenginecontextmenudata.cpp +++ b/src/webengine/api/qquickwebenginecontextmenudata.cpp @@ -170,30 +170,6 @@ bool QQuickWebEngineContextMenuData::isContentEditable() const return d ? d->isEditable : false; } -/*! - \qmlproperty QString WebEngineDownloadItem::misspelledWord - - If the context is a word considered misspelled by the spell-checker, returns the misspelled word. -*/ -QString QQuickWebEngineContextMenuData::misspelledWord() const -{ - if (d) - return d->misspelledWord; - return QString(); -} - -/*! - \qmlproperty QStringList WebEngineDownloadItem::spellCheckerSuggestions - - If the context is a word considered misspelled by the spell-checker, returns a list of suggested replacements. -*/ -QStringList QQuickWebEngineContextMenuData::spellCheckerSuggestions() const -{ - if (d) - return d->spellCheckerSuggestions; - return QStringList(); -} - void QQuickWebEngineContextMenuData::update(const QtWebEngineCore::WebEngineContextMenuData &update) { const QQuickWebEngineContextMenuData old(d); @@ -222,12 +198,6 @@ void QQuickWebEngineContextMenuData::update(const QtWebEngineCore::WebEngineCont if (isContentEditable() != old.isContentEditable()) Q_EMIT isContentEditableChanged(); - - if (misspelledWord() != old.misspelledWord()) - Q_EMIT misspelledWordChanged(); - - if (spellCheckerSuggestions() != old.spellCheckerSuggestions()) - Q_EMIT spellCheckerSuggestionsChanged(); } QQuickWebEngineContextMenuData::QQuickWebEngineContextMenuData(const QQuickWebEngineContextMenuDataPrivate *p, QObject *parent) diff --git a/src/webengine/api/qquickwebenginecontextmenudata_p.h b/src/webengine/api/qquickwebenginecontextmenudata_p.h index 0989eaa5a..aa081cbe6 100644 --- a/src/webengine/api/qquickwebenginecontextmenudata_p.h +++ b/src/webengine/api/qquickwebenginecontextmenudata_p.h @@ -92,8 +92,6 @@ public: Q_PROPERTY(QUrl mediaUrl READ mediaUrl NOTIFY mediaUrlChanged) Q_PROPERTY(MediaType mediaType READ mediaType NOTIFY mediaTypeChanged) Q_PROPERTY(bool isContentEditable READ isContentEditable NOTIFY isContentEditableChanged) - Q_PROPERTY(QString misspelledWord READ misspelledWord NOTIFY misspelledWordChanged) - Q_PROPERTY(QStringList spellCheckerSuggestions READ spellCheckerSuggestions NOTIFY spellCheckerSuggestionsChanged) bool isValid() const; @@ -105,9 +103,6 @@ public: MediaType mediaType() const; bool isContentEditable() const; - QString misspelledWord() const; - QStringList spellCheckerSuggestions() const; - Q_SIGNALS: void isValidChanged(); void positionChanged(); @@ -117,8 +112,6 @@ Q_SIGNALS: void mediaUrlChanged(); void mediaTypeChanged(); void isContentEditableChanged(); - void misspelledWordChanged(); - void spellCheckerSuggestionsChanged(); private: void update(const QtWebEngineCore::WebEngineContextMenuData &update); diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 6901b3e0e..c1f8f3179 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -613,85 +613,6 @@ QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile() } /*! - \property QQuickWebEngineProfile::spellCheckLanguage - \brief the language used by the spell checker. - - \since QtWebEngine 1.3 -*/ - -/*! - \qmlproperty QString WebEngineProfile::spellCheckLanguage - - This property holds the language used by the spell checker. - The language should match the name of the \c .bdic dictionary. - For example, the \a language \c en-US will load the \c en-US.bdic - dictionary file. - - The web engine checks for the \c qtwebengine_dictionaries subdirectory - first in the local directory and if it is not found in the Qt - installation directory: - - \list - \li QCoreApplication::applicationDirPath()/qtwebengine_dictionaries - \li [QLibraryInfo::DataPath]/qtwebengine_dictionaries - \endlist - - For more information about how to compile \c .bdic dictionaries, see the - \l{WebEngine Widgets Spellchecker Example}{Spellchecker Example}. - - \since QtWebEngine 1.3 -*/ -void QQuickWebEngineProfile::setSpellCheckLanguage(const QString &language) -{ - Q_D(QQuickWebEngineProfile); - if (language != d->browserContext()->spellCheckLanguage()) { - d->browserContext()->setSpellCheckLanguage(language); - emit spellCheckLanguageChanged(); - } -} - -/*! - \since 5.7 - - Returns the language used by the spell checker. -*/ -QString QQuickWebEngineProfile::spellCheckLanguage() const -{ - const Q_D(QQuickWebEngineProfile); - return d->browserContext()->spellCheckLanguage(); -} - -/*! - \property QQuickWebEngineProfile::spellCheckEnabled - \brief whether the web engine spell checker is enabled. - - \since QtWebEngine 1.3 -*/ - -/*! - \qmlproperty QString WebEngineProfile::spellCheckEnabled - - This property holds whether the web engine spell checker is enabled. - - \since QtWebEngine 1.3 -*/ -void QQuickWebEngineProfile::setSpellCheckEnabled(bool enable) -{ - Q_D(QQuickWebEngineProfile); - if (enable != isSpellCheckEnabled()) { - d->browserContext()->setSpellCheckEnabled(enable); - emit spellCheckEnabledChanged(); - } -} - -bool QQuickWebEngineProfile::isSpellCheckEnabled() const -{ - const Q_D(QQuickWebEngineProfile); - return d->browserContext()->isSpellCheckEnabled(); -} - -/*! - Returns the cookie store for this profile. */ QWebEngineCookieStore *QQuickWebEngineProfile::cookieStore() const diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h index 273375fc6..5c1218de9 100644 --- a/src/webengine/api/qquickwebengineprofile.h +++ b/src/webengine/api/qquickwebengineprofile.h @@ -71,8 +71,6 @@ class Q_WEBENGINE_EXPORT QQuickWebEngineProfile : public QObject { Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL REVISION 1) Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL) Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL) - Q_PROPERTY(QString spellCheckLanguage READ spellCheckLanguage WRITE setSpellCheckLanguage NOTIFY spellCheckLanguageChanged FINAL REVISION 2) - Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY spellCheckEnabledChanged FINAL REVISION 2) public: QQuickWebEngineProfile(QObject *parent = Q_NULLPTR); @@ -131,11 +129,6 @@ public: void clearHttpCache(); - Q_REVISION(2) void setSpellCheckLanguage(const QString &language); - Q_REVISION(2) QString spellCheckLanguage() const; - Q_REVISION(2) void setSpellCheckEnabled(bool enabled); - Q_REVISION(2) bool isSpellCheckEnabled() const; - static QQuickWebEngineProfile *defaultProfile(); Q_SIGNALS: diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index f265ccfb6..1b1dcec25 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -202,16 +202,7 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu // Populate our menu MenuItemHandler *item = 0; - if (contextMenuData.isContentEditable() && !contextMenuData.spellCheckerSuggestions().isEmpty()) { - const QPointer<QQuickWebEngineView> qRef(q); - for (int i=0; i < contextMenuData.spellCheckerSuggestions().count() && i < 4; i++) { - item = new MenuItemHandler(menu); - QString replacement = contextMenuData.spellCheckerSuggestions().at(i); - QObject::connect(item, &MenuItemHandler::triggered, [qRef, replacement] { qRef->replaceMisspelledWord(replacement); }); - ui()->addMenuItem(item, replacement); - } - ui()->addMenuSeparator(menu); - } + if (!data.linkText.isEmpty() && data.linkUrl.isValid()) { item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::OpenLinkInThisWindow); }); @@ -1237,12 +1228,6 @@ void QQuickWebEngineView::printToPdf(const QJSValue &callback, PrintedPageSizeId d->m_callbacks.insert(requestId, callback); } -void QQuickWebEngineView::replaceMisspelledWord(const QString &replacement) -{ - Q_D(QQuickWebEngineView); - d->adapter->replaceMisspelling(replacement); -} - bool QQuickWebEngineView::isFullScreen() const { Q_D(const QQuickWebEngineView); diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index 843e34f42..d287b46ca 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -471,8 +471,6 @@ public Q_SLOTS: Q_REVISION(2) void triggerWebAction(WebAction action); Q_REVISION(3) void printToPdf(const QString &filePath, PrintedPageSizeId pageSizeId = PrintedPageSizeId::A4, PrintedPageOrientation orientation = PrintedPageOrientation::Portrait); Q_REVISION(3) void printToPdf(const QJSValue &callback, PrintedPageSizeId pageSizeId = PrintedPageSizeId::A4, PrintedPageOrientation orientation = PrintedPageOrientation::Portrait); - Q_REVISION(3) void replaceMisspelledWord(const QString &replacement); - private Q_SLOTS: void lazyInitialize(); diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp b/src/webenginewidgets/api/qwebenginecontextmenudata.cpp index 17a562ea1..c7019977b 100644 --- a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp +++ b/src/webenginewidgets/api/qwebenginecontextmenudata.cpp @@ -187,26 +187,6 @@ bool QWebEngineContextMenuData::isContentEditable() const } /*! - If the context is a word considered misspelled by the spell-checker, returns the misspelled word. -*/ -QString QWebEngineContextMenuData::misspelledWord() const -{ - if (d) - return d->misspelledWord; - return QString(); -} - -/*! - If the context is a word considered misspelled by the spell-checker, returns a list of suggested replacements. -*/ -QStringList QWebEngineContextMenuData::spellCheckerSuggestions() const -{ - if (d) - return d->spellCheckerSuggestions; - return QStringList(); -} - -/*! \internal */ QWebEngineContextMenuData &QWebEngineContextMenuData::operator=(const QWebEngineContextDataPrivate &priv) diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.h b/src/webenginewidgets/api/qwebenginecontextmenudata.h index fd1080eec..4bea34ee0 100644 --- a/src/webenginewidgets/api/qwebenginecontextmenudata.h +++ b/src/webenginewidgets/api/qwebenginecontextmenudata.h @@ -76,8 +76,6 @@ public: QUrl mediaUrl() const; MediaType mediaType() const; bool isContentEditable() const; - QString misspelledWord() const; - QStringList spellCheckerSuggestions() const; private: void reset(); diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index e41271471..0e7f02f16 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -1098,22 +1098,6 @@ void QWebEnginePage::triggerAction(WebAction action, bool) } } -/*! - * \since 5.7 - * 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); @@ -1292,18 +1276,6 @@ 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")); diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 7b99270c0..0c6450d20 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -206,8 +206,6 @@ public: #endif virtual void triggerAction(WebAction action, bool checked = false); - void replaceMisspelledWord(const QString &replacement); - virtual bool event(QEvent*); #ifdef Q_QDOC void findText(const QString &subString, FindFlags options = 0); diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 361a60944..664323034 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -556,67 +556,6 @@ QWebEngineProfile *QWebEngineProfile::defaultProfile() } /*! - \since 5.7 - - Sets the current \a language for the spell checker. - The language should match the name of the \c .bdic dictionary. - For example, the \a language \c en-US will load the \c en-US.bdic - dictionary file. - - The web engine checks for the \c qtwebengine_dictionaries subdirectory - first in the local directory and if it is not found in the Qt - installation directory: - - \list - \li QCoreApplication::applicationDirPath()/qtwebengine_dictionaries - \li [QLibraryInfo::DataPath]/qtwebengine_dictionaries - \endlist - - For more information about how to compile \c .bdic dictionaries, see the - \l{WebEngine Widgets Spellchecker Example}{Spellchecker Example}. - -*/ -void QWebEngineProfile::setSpellCheckLanguage(const QString &language) -{ - Q_D(QWebEngineProfile); - d->browserContext()->setSpellCheckLanguage(language); -} - -/*! - \since 5.7 - - Returns the language used by the spell checker. -*/ -QString QWebEngineProfile::spellCheckLanguage() const -{ - const Q_D(QWebEngineProfile); - return d->browserContext()->spellCheckLanguage(); -} - -/*! - \since 5.7 - - Enables spell checker if \a enable is \c true, otherwise disables it. - \sa isSpellCheckEnabled() - */ -void QWebEngineProfile::setSpellCheckEnabled(bool enable) -{ - Q_D(QWebEngineProfile); - d->browserContext()->setSpellCheckEnabled(enable); -} -/*! - \since 5.7 - - Returns \c true if the spell checker is enabled; otherwise returns \c false. - \sa setSpellCheckEnabled() - */ -bool QWebEngineProfile::isSpellCheckEnabled() const -{ - const Q_D(QWebEngineProfile); - return d->browserContext()->isSpellCheckEnabled(); -} - -/*! Returns the default settings for all pages in this profile. */ QWebEngineSettings *QWebEngineProfile::settings() const diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h index 868b4b0f5..22a913fb2 100644 --- a/src/webenginewidgets/api/qwebengineprofile.h +++ b/src/webenginewidgets/api/qwebengineprofile.h @@ -121,11 +121,6 @@ public: void clearHttpCache(); - void setSpellCheckLanguage(const QString &language); - QString spellCheckLanguage() const; - void setSpellCheckEnabled(bool enabled); - bool isSpellCheckEnabled() const; - static QWebEngineProfile *defaultProfile(); Q_SIGNALS: |