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
Pick-to: 5.15
Fixes: QTBUG-53110
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
bb10
Edward Welbourne 2020-04-20 11:16:57 +02:00 committed by Orgad Shaneh
parent df234035d0
commit 589e34eb32
1 changed files with 2 additions and 5 deletions

View File

@ -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)