summaryrefslogtreecommitdiff
path: root/src/core/api
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2023-01-30 18:21:48 +0100
committerSzabolcs David <davidsz@inf.u-szeged.hu>2023-02-15 13:19:29 +0100
commit47564e329a71fed8b73be403bbdc30fbf684f7a4 (patch)
tree16ad3d22d7e301ed2458732eaafbdc9e2c5542ea /src/core/api
parent552f941ec35987b643dac0fdb8a323366bf4e3d0 (diff)
downloadqtwebengine-47564e329a71fed8b73be403bbdc30fbf684f7a4.tar.gz
Support LTR and RTL text directions in input fields
Implement WebActions to temporarily change text direction directly from context menu - like Chrome does. They only work for the selected input field. Omit the "default" option since it is always grayed out in Chrome. Task-number: QTWB-67 Change-Id: I4bacbd82c6bd7261ac465eec9da3776613f98074 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/api')
-rw-r--r--src/core/api/qwebenginepage.cpp12
-rw-r--r--src/core/api/qwebenginepage.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/src/core/api/qwebenginepage.cpp b/src/core/api/qwebenginepage.cpp
index ac44fad10..db795f846 100644
--- a/src/core/api/qwebenginepage.cpp
+++ b/src/core/api/qwebenginepage.cpp
@@ -1179,6 +1179,12 @@ QAction *QWebEnginePage::action(WebAction action) const
case InsertUnorderedList:
text = tr("Insert &Unordered List");
break;
+ case ChangeTextDirectionLTR:
+ text = tr("Change text direction left to right");
+ break;
+ case ChangeTextDirectionRTL:
+ text = tr("Change text direction right to left");
+ break;
case NoWebAction:
case WebActionCount:
Q_UNREACHABLE();
@@ -1452,6 +1458,12 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
case InsertUnorderedList:
runJavaScript(QStringLiteral("document.execCommand('insertUnorderedList');"), QWebEngineScript::ApplicationWorld);
break;
+ case ChangeTextDirectionLTR:
+ d->adapter->changeTextDirection(true /*left to right*/);
+ break;
+ case ChangeTextDirectionRTL:
+ d->adapter->changeTextDirection(false /*left to right*/);
+ break;
case NoWebAction:
break;
case WebActionCount:
diff --git a/src/core/api/qwebenginepage.h b/src/core/api/qwebenginepage.h
index c60feb3ab..e58cb3a84 100644
--- a/src/core/api/qwebenginepage.h
+++ b/src/core/api/qwebenginepage.h
@@ -122,6 +122,9 @@ public:
InsertOrderedList,
InsertUnorderedList,
+ ChangeTextDirectionLTR,
+ ChangeTextDirectionRTL,
+
WebActionCount
};
Q_ENUM(WebAction)