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 <orgads@gmail.com>
(cherry picked from commit 589e34eb3210d8725d68941dbeb096424dda68df)
This commit is contained in:
Edward Welbourne 2020-04-20 11:16:57 +02:00 committed by Volker Hilsheimer
parent 0d4b67a95b
commit 63ebd81fe8

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/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtWidgets module of the Qt Toolkit. ** This file is part of the QtWidgets module of the Qt Toolkit.
@ -354,11 +354,8 @@ public:
void setPasswordMaskDelay(int delay) { m_passwordMaskDelay = delay; } void setPasswordMaskDelay(int delay) { m_passwordMaskDelay = delay; }
Qt::LayoutDirection layoutDirection() const { Qt::LayoutDirection layoutDirection() const {
if (m_layoutDirection == Qt::LayoutDirectionAuto) { if (m_layoutDirection == Qt::LayoutDirectionAuto && !m_text.isEmpty())
if (m_text.isEmpty())
return QGuiApplication::inputMethod()->inputDirection();
return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight; return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
}
return m_layoutDirection; return m_layoutDirection;
} }
void setLayoutDirection(Qt::LayoutDirection direction) void setLayoutDirection(Qt::LayoutDirection direction)