Call setLayoutDirection() in QGuiApplicationPrivate::init() if not called before
Without this patch, setLayoutDirection() is called only by LanguageChange event handling, which triggers only upon installing, removing, or clearing QTranslators. This caused two problems: * If the QTranslators are installed in a Q_COREAPP_STARTUP_FUNCTION the event is lost since the QGuiApplication is still not there. * If the application doesn't use QTranslators at all, i.e., uses gettext, some other translation system, or because it has no messages at all, setLayoutDirection() is never called and the layout direction is wrong. The initialization of layout_direction has been changed from Qt::LeftToRight to Qt::LayoutDirectionAuto but that has no impact since QGuiApplication::layoutDirection will make sure Qt::LeftToRight is returned if layout_direction has still not been set. Change-Id: Ic60fe9a318c8afe1c503e3796ec54cfc687e7164 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>bb10
parent
7733a5fccc
commit
5af6efc911
|
|
@ -163,7 +163,7 @@ int QGuiApplicationPrivate::mouse_double_click_distance = -1;
|
|||
|
||||
QWindow *QGuiApplicationPrivate::currentMousePressWindow = 0;
|
||||
|
||||
static Qt::LayoutDirection layout_direction = Qt::LeftToRight;
|
||||
static Qt::LayoutDirection layout_direction = Qt::LayoutDirectionAuto;
|
||||
static bool force_reverse = false;
|
||||
|
||||
QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0;
|
||||
|
|
@ -1273,7 +1273,6 @@ void QGuiApplicationPrivate::init()
|
|||
pluginList << argv[i];
|
||||
} else if (arg == "-reverse") {
|
||||
force_reverse = true;
|
||||
QGuiApplication::setLayoutDirection(Qt::RightToLeft);
|
||||
#ifdef Q_OS_MAC
|
||||
} else if (arg.startsWith("-psn_")) {
|
||||
// eat "-psn_xxxx" on Mac, which is passed when starting an app from Finder.
|
||||
|
|
@ -1397,6 +1396,9 @@ void QGuiApplicationPrivate::init()
|
|||
#else
|
||||
Q_UNUSED(loadTestability);
|
||||
#endif // QT_NO_LIBRARY
|
||||
|
||||
if (layout_direction == Qt::LayoutDirectionAuto || force_reverse)
|
||||
QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight);
|
||||
}
|
||||
|
||||
extern void qt_cleanupFontDatabase();
|
||||
|
|
@ -3254,7 +3256,10 @@ void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction)
|
|||
|
||||
Qt::LayoutDirection QGuiApplication::layoutDirection()
|
||||
{
|
||||
return layout_direction;
|
||||
// layout_direction is only ever Qt::LayoutDirectionAuto if setLayoutDirection
|
||||
// was never called, or called with Qt::LayoutDirectionAuto (which is a no-op).
|
||||
// In that case we return the default LeftToRight.
|
||||
return layout_direction == Qt::LayoutDirectionAuto ? Qt::LeftToRight : layout_direction;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue