Automatically reflect new input context input direction when locale changes
All platforms except Wayland fail to check for input direction change when the locale changes, and only emitLocaleChanged. We can simplify this for the platforms by checking if the new locale caused a change in input direction, and if so emit inputDirectionChanged on their behalf. Change-Id: I84d8df9392db5e716f5c277d0cc9e17e5a21783f Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
parent
84d0ebabaa
commit
d9bb8c0a17
@ -47,6 +47,11 @@ QT_BEGIN_NAMESPACE
|
||||
QPlatformInputContext::QPlatformInputContext()
|
||||
: QObject(*(new QPlatformInputContextPrivate))
|
||||
{
|
||||
// Delay initialization of cached input direction
|
||||
// until super class has finished constructing.
|
||||
QMetaObject::invokeMethod(this, [this]{
|
||||
m_inputDirection = inputDirection();
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -198,6 +203,9 @@ QLocale QPlatformInputContext::locale() const
|
||||
void QPlatformInputContext::emitLocaleChanged()
|
||||
{
|
||||
emit QGuiApplication::inputMethod()->localeChanged();
|
||||
|
||||
// Changing the locale might have updated the input direction
|
||||
emitInputDirectionChanged(inputDirection());
|
||||
}
|
||||
|
||||
Qt::LayoutDirection QPlatformInputContext::inputDirection() const
|
||||
@ -207,7 +215,11 @@ Qt::LayoutDirection QPlatformInputContext::inputDirection() const
|
||||
|
||||
void QPlatformInputContext::emitInputDirectionChanged(Qt::LayoutDirection newDirection)
|
||||
{
|
||||
if (newDirection == m_inputDirection)
|
||||
return;
|
||||
|
||||
emit QGuiApplication::inputMethod()->inputDirectionChanged(newDirection);
|
||||
m_inputDirection = newDirection;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -72,6 +72,8 @@ private:
|
||||
friend class QGuiApplication;
|
||||
friend class QGuiApplicationPrivate;
|
||||
friend class QInputMethod;
|
||||
|
||||
Qt::LayoutDirection m_inputDirection;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user