From 63ebd81fe82fb9902b0f94791b88fb2e62dc95d7 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 20 Apr 2020 11:16:57 +0200 Subject: [PATCH] Don't fall back to QGuiApplication for line control's layoutDirection If the widget whose line control we are has its own locale setting, then we should use that rather than the default UI layout direction. Instead, the client of the QWidgetLineControl needs to handle the case where auto-detection of the text direction can't be done based on the content of the line control. Fortunately, QWidget's handling of text direction handles setting to auto gracefully as unsetting, on which it consults the parent widget to set a sensible default. Change-Id: Id0d247f1e6e7219b6d0ece5856ca93ee87778c74 Fixes: QTBUG-53110 Reviewed-by: Orgad Shaneh (cherry picked from commit 589e34eb3210d8725d68941dbeb096424dda68df) --- src/widgets/widgets/qwidgetlinecontrol_p.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index a8fffd23dc4..357b5413629 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -354,11 +354,8 @@ public: void setPasswordMaskDelay(int delay) { m_passwordMaskDelay = delay; } Qt::LayoutDirection layoutDirection() const { - if (m_layoutDirection == Qt::LayoutDirectionAuto) { - if (m_text.isEmpty()) - return QGuiApplication::inputMethod()->inputDirection(); + if (m_layoutDirection == Qt::LayoutDirectionAuto && !m_text.isEmpty()) return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight; - } return m_layoutDirection; } void setLayoutDirection(Qt::LayoutDirection direction)