diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2023-01-30 18:21:48 +0100 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2023-02-15 13:19:29 +0100 |
commit | 47564e329a71fed8b73be403bbdc30fbf684f7a4 (patch) | |
tree | 16ad3d22d7e301ed2458732eaafbdc9e2c5542ea /src/core/web_contents_adapter.cpp | |
parent | 552f941ec35987b643dac0fdb8a323366bf4e3d0 (diff) |
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/web_contents_adapter.cpp')
-rw-r--r-- | src/core/web_contents_adapter.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 081505d7f..5b880d31a 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1772,6 +1772,20 @@ void WebContentsAdapter::resetTouchSelectionController() rwhv->resetTouchSelectionController(); } +void WebContentsAdapter::changeTextDirection(bool leftToRight) +{ + CHECK_INITIALIZED(); + if (auto rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) { + auto textInputManager = rwhv->GetTextInputManager(); + if (!textInputManager) + return; + if (auto activeWidget = textInputManager->GetActiveWidget()) { + activeWidget->UpdateTextDirection(leftToRight ? base::i18n::TextDirection::LEFT_TO_RIGHT : base::i18n::TextDirection::RIGHT_TO_LEFT); + activeWidget->NotifyTextDirection(); + } + } +} + WebContentsAdapterClient::RenderProcessTerminationStatus WebContentsAdapterClient::renderProcessExitStatus(int terminationStatus) { auto status = WebContentsAdapterClient::RenderProcessTerminationStatus(-1); |