diff options
author | Viktor Engelmann <Viktor.Engelmann@qt.io> | 2017-03-17 11:23:49 +0100 |
---|---|---|
committer | Viktor Engelmann <viktor.engelmann@qt.io> | 2017-04-03 13:53:08 +0000 |
commit | 317270cdda436ca0ef7d28ce53de7b09deb9858f (patch) | |
tree | 0ba60c53fc452bd521d3cc1196be0dc275a525d2 /src/webengine | |
parent | 534c6dd960dc627040aba0cf2039e70ac92fa73a (diff) |
Add several QtWebKit WebActions
Add WebActions ToggleBold, ToggleItalic, ToggleUnderline,
ToggleStrikethrough, AlignLeft, AlignCenter, AlignRight,
AlignJustified, Indent, Outdent, InsertOrderedList and
InsertUnorderedList.
All use the javascript document.execCommand with
parameters according to
https://developer.mozilla.org/de/docs/Web/API/Document/execCommand
Task-number: QTBUG-59221
Change-Id: Ife18d660fefa2073351c5ad959611ec47b680dc6
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 36 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p.h | 16 | ||||
-rw-r--r-- | src/webengine/doc/src/webengineview.qdoc | 40 |
3 files changed, 92 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 6383f3468..8077e2c0b 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -1709,6 +1709,42 @@ void QQuickWebEngineView::triggerWebAction(WebAction action) case ViewSource: d->adapter->viewSource(); break; + case ToggleBold: + runJavaScript("document.execCommand('bold');", QQuickWebEngineScript::ApplicationWorld); + break; + case ToggleItalic: + runJavaScript("document.execCommand('italic');", QQuickWebEngineScript::ApplicationWorld); + break; + case ToggleUnderline: + runJavaScript("document.execCommand('underline');", QQuickWebEngineScript::ApplicationWorld); + break; + case ToggleStrikethrough: + runJavaScript("document.execCommand('strikethrough');", QQuickWebEngineScript::ApplicationWorld); + break; + case AlignLeft: + runJavaScript("document.execCommand('justifyLeft');", QQuickWebEngineScript::ApplicationWorld); + break; + case AlignCenter: + runJavaScript("document.execCommand('justifyCenter');", QQuickWebEngineScript::ApplicationWorld); + break; + case AlignRight: + runJavaScript("document.execCommand('justifyRight');", QQuickWebEngineScript::ApplicationWorld); + break; + case AlignJustified: + runJavaScript("document.execCommand('justifyFull');", QQuickWebEngineScript::ApplicationWorld); + break; + case Indent: + runJavaScript("document.execCommand('indent');", QQuickWebEngineScript::ApplicationWorld); + break; + case Outdent: + runJavaScript("document.execCommand('outdent');", QQuickWebEngineScript::ApplicationWorld); + break; + case InsertOrderedList: + runJavaScript("document.execCommand('insertOrderedList');", QQuickWebEngineScript::ApplicationWorld); + break; + case InsertUnorderedList: + runJavaScript("document.execCommand('insertUnorderedList');", QQuickWebEngineScript::ApplicationWorld); + break; default: Q_UNREACHABLE(); } diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index 92eb5d7de..f42720581 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -246,6 +246,22 @@ public: Unselect, SavePage, ViewSource, + + ToggleBold, + ToggleItalic, + ToggleUnderline, + ToggleStrikethrough, + + AlignLeft, + AlignCenter, + AlignRight, + AlignJustified, + Indent, + Outdent, + + InsertOrderedList, + InsertUnorderedList, + WebActionCount }; Q_ENUM(WebAction) diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc index 27c3d6920..e452746d9 100644 --- a/src/webengine/doc/src/webengineview.qdoc +++ b/src/webengine/doc/src/webengineview.qdoc @@ -793,6 +793,46 @@ \value WebEngineView.ViewSource Show the source of the current page in a new tab. (Added in Qt 5.8) + \value WebEngineView.ToggleBold + Toggles boldness for the selection or at the cursor position. + Requires \c contenteditable="true". (Added in Qt 5.10) + \value WebEngineView.ToggleItalic + Toggles italics for the selection or at the cursor position. + Requires \c contenteditable="true". (Added in Qt 5.10) + \value WebEngineView.ToggleUnderline + Toggles underlining of the selection or at the cursor position. + Requires \c contenteditable="true". (Added in Qt 5.10) + \value WebEngineView.ToggleStrikethrough + Toggles striking through the selection or at the cursor position. + Requires \c contenteditable="true". (Added in Qt 5.10) + + \value WebEngineView.AlignLeft + Aligns the lines containing the selection or the cursor to the left. + Requires \c contenteditable="true". (Added in Qt 5.10) + \value WebEngineView.AlignCenter + Aligns the lines containing the selection or the cursor at the center. + Requires \c contenteditable="true". (Added in Qt 5.10) + \value WebEngineView.AlignRight + Aligns the lines containing the selection or the cursor to the right. + Requires \c contenteditable="true". (Added in Qt 5.10) + \value WebEngineView.AlignJustified + Stretches the lines containing the selection or the cursor so that each + line has equal width. + Requires \c contenteditable="true". (Added in Qt 5.10) + \value WebEngineView.Indent + Indents the lines containing the selection or the cursor. + Requires \c contenteditable="true". (Added in Qt 5.10) + \value WebEngineView.Outdent + Outdents the lines containing the selection or the cursor. + Requires \c contenteditable="true". (Added in Qt 5.10) + + \value WebEngineView.InsertOrderedList + Inserts an ordered list at the current cursor position, deleting the current selection. + Requires \c contenteditable="true". (Added in Qt 5.10) + \value WebEngineView.InsertUnorderedList + Inserts an unordered list at the current cursor position, + deleting the current selection. + Requires \c contenteditable="true". (Added in Qt 5.10) \omitvalue WebActionCount */ |