From 6b687ad7ec46fed10766f5d26809c4fe430db608 Mon Sep 17 00:00:00 2001 From: Hyunkook Khang Date: Tue, 23 Feb 2021 10:51:31 +0900 Subject: Fix layout is always RTL when locale is RTL isMirrored() will always return true when locale is RTL, so that we cannot change the layout. To fix this, remove out the relation between LayoutMirroring.enabled and locale's text direction. [ChangeLog][Controls][Important Behavior Changes] Control's locale property no longer affects layout direction. Use LayoutMirroring instead. Fixes: QTBUG-91227 Change-Id: Ibedd3f09828f81f1889077892452a27c90e21533 Reviewed-by: Hyunkook Khang Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickapplicationwindow.cpp | 2 +- src/quicktemplates2/qquickcontrol.cpp | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index 62679110..00cab471 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -635,7 +635,7 @@ void QQuickApplicationWindow::resetFont() the window's locale, that locale propagates to all child controls in the window, overriding the system default locale. - \sa Control::locale, {LayoutMirroring}{LayoutMirroring} + \sa Control::locale */ QLocale QQuickApplicationWindow::locale() const { diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index c07a097b..89f6abd4 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -232,8 +232,7 @@ void QQuickControlPrivate::handleUngrab() void QQuickControlPrivate::mirrorChange() { Q_Q(QQuickControl); - if (locale.textDirection() == Qt::LeftToRight) - q->mirrorChange(); + q->mirrorChange(); } void QQuickControlPrivate::setTopPadding(qreal value, bool reset) @@ -636,13 +635,10 @@ void QQuickControlPrivate::updateLocale(const QLocale &l, bool e) QLocale old = q->locale(); hasLocale = e; if (old != l) { - bool wasMirrored = q->isMirrored(); locale = l; q->localeChange(l, old); QQuickControlPrivate::updateLocaleRecur(q, l); emit q->localeChanged(); - if (wasMirrored != q->isMirrored()) - q->mirrorChange(); } } @@ -1246,7 +1242,7 @@ void QQuickControl::resetSpacing() control's locale, that locale propagates to all of the control's children, overriding the system default locale. - \sa mirrored, {LayoutMirroring}{LayoutMirroring} + \sa mirrored */ QLocale QQuickControl::locale() const { @@ -1280,16 +1276,17 @@ void QQuickControl::resetLocale() This property holds whether the control is mirrored. This property is provided for convenience. A control is considered mirrored - when its visual layout direction is right-to-left; that is, when using a - right-to-left locale or when \l {LayoutMirroring::enabled}{LayoutMirroring.enabled} - is \c true. + when its visual layout direction is right-to-left; that is, when + \l {LayoutMirroring::enabled}{LayoutMirroring.enabled} is \c true. - \sa locale, {LayoutMirroring}{LayoutMirroring}, {Right-to-left User Interfaces} + As of Qt 6.2, the \l locale property no longer affects this property. + + \sa {LayoutMirroring}{LayoutMirroring}, {Right-to-left User Interfaces} */ bool QQuickControl::isMirrored() const { Q_D(const QQuickControl); - return d->isMirrored() || d->locale.textDirection() == Qt::RightToLeft; + return d->isMirrored(); } /*! -- cgit v1.2.3