summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2015-11-19 00:33:10 +0100
committerAlbert Astals Cid <aacid@kde.org>2015-11-30 19:05:37 +0000
commit5af6efc911f80b6d8dea4d29879cc9e76da492e6 (patch)
tree460a7120320af3c5ce00fd3a21bb0793210c9c64 /src/gui/kernel
parent7733a5fccc39aa5141e5968eef3fa47bc62917d9 (diff)
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>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 00bad52432..087bed439c 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -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;
}
/*!