diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 0ebaf9a3..ba3be78d 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -1344,16 +1344,14 @@ 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 \l {LayoutMirroring::enabled}{LayoutMirroring.enabled} is \c true. \sa locale, {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(); } /*! diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml index 3c416546..c131baab 100644 --- a/tests/auto/controls/data/tst_control.qml +++ b/tests/auto/controls/data/tst_control.qml @@ -435,8 +435,8 @@ TestCase { compare(control.mirrored, false) control.locale = Qt.locale("ar_EG") - compare(control.mirrored, true) - compare(mirroredSpy.count, 1) + compare(control.mirrored, false) + compare(mirroredSpy.count, 0) control.LayoutMirroring.enabled = true compare(control.mirrored, true) diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 27043d1c..90c22a24 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -809,9 +809,9 @@ TestCase { compare(control.popup.button1.locale.name, defaultLocale.name) compare(control.popup.button2.locale.name, defaultLocale.name) compare(control.localespy.count, 3) - compare(control.mirrorspy.count, 1) + compare(control.mirrorspy.count, 0) compare(control.button.localespy.count, 3) - compare(control.button.mirrorspy.count, 1) + compare(control.button.mirrorspy.count, 0) compare(control.popup.localespy.count, 2) compare(control.popup.button1.localespy.count, 2) compare(control.popup.button2.localespy.count, 2) @@ -824,14 +824,14 @@ TestCase { compare(control.popup.button1.locale.name, "ar_EG") compare(control.popup.button2.locale.name, "ar_EG") compare(control.localespy.count, 3) - compare(control.mirrorspy.count, 1) + compare(control.mirrorspy.count, 0) compare(control.button.localespy.count, 3) - compare(control.button.mirrorspy.count, 1) + compare(control.button.mirrorspy.count, 0) compare(control.popup.localespy.count, 3) compare(control.popup.button1.localespy.count, 3) - compare(control.popup.button1.mirrorspy.count, 1) + compare(control.popup.button1.mirrorspy.count, 0) compare(control.popup.button2.localespy.count, 3) - compare(control.popup.button2.mirrorspy.count, 1) + compare(control.popup.button2.mirrorspy.count, 0) control.button.locale = Qt.locale("nb_NO") compare(control.ApplicationWindow.window.locale.name, "ar_EG") @@ -841,9 +841,9 @@ TestCase { compare(control.popup.button1.locale.name, "ar_EG") compare(control.popup.button2.locale.name, "ar_EG") compare(control.localespy.count, 3) - compare(control.mirrorspy.count, 1) + compare(control.mirrorspy.count, 0) compare(control.button.localespy.count, 4) - compare(control.button.mirrorspy.count, 2) + compare(control.button.mirrorspy.count, 0) compare(control.popup.localespy.count, 3) compare(control.popup.button1.localespy.count, 3) compare(control.popup.button2.localespy.count, 3) @@ -856,9 +856,9 @@ TestCase { compare(control.popup.button1.locale.name, "ar_EG") compare(control.popup.button2.locale.name, "ar_EG") compare(control.localespy.count, 3) - compare(control.mirrorspy.count, 1) + compare(control.mirrorspy.count, 0) compare(control.button.localespy.count, 4) - compare(control.button.mirrorspy.count, 2) + compare(control.button.mirrorspy.count, 0) compare(control.popup.localespy.count, 3) compare(control.popup.button1.localespy.count, 3) compare(control.popup.button2.localespy.count, 3) @@ -871,14 +871,14 @@ TestCase { compare(control.popup.button1.locale.name, "nb_NO") compare(control.popup.button2.locale.name, "ar_EG") compare(control.localespy.count, 3) - compare(control.mirrorspy.count, 1) + compare(control.mirrorspy.count, 0) compare(control.button.localespy.count, 4) - compare(control.button.mirrorspy.count, 2) + compare(control.button.mirrorspy.count, 0) compare(control.popup.localespy.count, 3) compare(control.popup.button1.localespy.count, 4) - compare(control.popup.button1.mirrorspy.count, 2) + compare(control.popup.button1.mirrorspy.count, 0) compare(control.popup.button2.localespy.count, 3) - compare(control.popup.button2.mirrorspy.count, 1) + compare(control.popup.button2.mirrorspy.count, 0) control.popup.locale = Qt.locale("fi_FI") compare(control.ApplicationWindow.window.locale.name, "ar_EG") @@ -888,14 +888,14 @@ TestCase { compare(control.popup.button1.locale.name, "nb_NO") compare(control.popup.button2.locale.name, "fi_FI") compare(control.localespy.count, 3) - compare(control.mirrorspy.count, 1) + compare(control.mirrorspy.count, 0) compare(control.button.localespy.count, 4) - compare(control.button.mirrorspy.count, 2) + compare(control.button.mirrorspy.count, 0) compare(control.popup.localespy.count, 4) compare(control.popup.button1.localespy.count, 4) - compare(control.popup.button1.mirrorspy.count, 2) + compare(control.popup.button1.mirrorspy.count, 0) compare(control.popup.button2.localespy.count, 4) - compare(control.popup.button2.mirrorspy.count, 2) + compare(control.popup.button2.mirrorspy.count, 0) control.ApplicationWindow.window.locale = undefined compare(control.ApplicationWindow.window.locale.name, defaultLocale.name) @@ -905,14 +905,14 @@ TestCase { compare(control.popup.button1.locale.name, "nb_NO") compare(control.popup.button2.locale.name, "fi_FI") compare(control.localespy.count, 4) - compare(control.mirrorspy.count, 2) + compare(control.mirrorspy.count, 0) compare(control.button.localespy.count, 4) - compare(control.button.mirrorspy.count, 2) + compare(control.button.mirrorspy.count, 0) compare(control.popup.localespy.count, 4) compare(control.popup.button1.localespy.count, 4) - compare(control.popup.button1.mirrorspy.count, 2) + compare(control.popup.button1.mirrorspy.count, 0) compare(control.popup.button2.localespy.count, 4) - compare(control.popup.button2.mirrorspy.count, 2) + compare(control.popup.button2.mirrorspy.count, 0) control.popup.locale = undefined compare(control.ApplicationWindow.window.locale.name, defaultLocale.name) @@ -922,14 +922,183 @@ TestCase { compare(control.popup.button1.locale.name, "nb_NO") compare(control.popup.button2.locale.name, defaultLocale.name) compare(control.localespy.count, 4) - compare(control.mirrorspy.count, 2) + compare(control.mirrorspy.count, 0) compare(control.button.localespy.count, 4) - compare(control.button.mirrorspy.count, 2) + compare(control.button.mirrorspy.count, 0) compare(control.popup.localespy.count, 5) compare(control.popup.button1.localespy.count, 4) - compare(control.popup.button1.mirrorspy.count, 2) + compare(control.popup.button1.mirrorspy.count, 0) compare(control.popup.button2.localespy.count, 5) - compare(control.popup.button2.mirrorspy.count, 2) + compare(control.popup.button2.mirrorspy.count, 0) + } + + function test_mirrored() { + var control = createTemporaryObject(localeChangeComponent, applicationWindow.contentItem) + verify(control) + + let defaultLayoutMirroringEnabled = false + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.button.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.popup.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.popup.button1.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.popup.button2.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + + control.ApplicationWindow.window.locale = Qt.locale("nb_NO") + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, "nb_NO") + compare(control.LayoutMirroring.enabled, "nb_NO") + compare(control.button.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.button1.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.button2.LayoutMirroring.enabled, "nb_NO") + compare(control.localespy.count, 1) + compare(control.button.localespy.count, 1) + compare(control.popup.localespy.count, 1) + compare(control.popup.button1.localespy.count, 1) + compare(control.popup.button2.localespy.count, 1) + + control.ApplicationWindow.window.locale = undefined + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.button.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.popup.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.popup.button1.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.popup.button2.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.localespy.count, 2) + compare(control.button.localespy.count, 2) + compare(control.popup.localespy.count, 2) + compare(control.popup.button1.localespy.count, 2) + compare(control.popup.button2.localespy.count, 2) + + control.locale = Qt.locale("ar_EG") + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.LayoutMirroring.enabled, "ar_EG") + compare(control.button.LayoutMirroring.enabled, "ar_EG") + compare(control.popup.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.popup.button1.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.popup.button2.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.localespy.count, 3) + compare(control.mirrorspy.count, 0) + compare(control.button.localespy.count, 3) + compare(control.button.mirrorspy.count, 0) + compare(control.popup.localespy.count, 2) + compare(control.popup.button1.localespy.count, 2) + compare(control.popup.button2.localespy.count, 2) + + control.ApplicationWindow.window.locale = Qt.locale("ar_EG") + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, "ar_EG") + compare(control.LayoutMirroring.enabled, "ar_EG") + compare(control.button.LayoutMirroring.enabled, "ar_EG") + compare(control.popup.LayoutMirroring.enabled, "ar_EG") + compare(control.popup.button1.LayoutMirroring.enabled, "ar_EG") + compare(control.popup.button2.LayoutMirroring.enabled, "ar_EG") + compare(control.localespy.count, 3) + compare(control.mirrorspy.count, 0) + compare(control.button.localespy.count, 3) + compare(control.button.mirrorspy.count, 0) + compare(control.popup.localespy.count, 3) + compare(control.popup.button1.localespy.count, 3) + compare(control.popup.button1.mirrorspy.count, 0) + compare(control.popup.button2.localespy.count, 3) + compare(control.popup.button2.mirrorspy.count, 0) + + control.button.locale = Qt.locale("nb_NO") + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, "ar_EG") + compare(control.LayoutMirroring.enabled, "ar_EG") + compare(control.button.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.LayoutMirroring.enabled, "ar_EG") + compare(control.popup.button1.LayoutMirroring.enabled, "ar_EG") + compare(control.popup.button2.LayoutMirroring.enabled, "ar_EG") + compare(control.localespy.count, 3) + compare(control.mirrorspy.count, 0) + compare(control.button.localespy.count, 4) + compare(control.button.mirrorspy.count, 0) + compare(control.popup.localespy.count, 3) + compare(control.popup.button1.localespy.count, 3) + compare(control.popup.button2.localespy.count, 3) + + control.locale = undefined + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, "ar_EG") + compare(control.LayoutMirroring.enabled, "ar_EG") + compare(control.button.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.LayoutMirroring.enabled, "ar_EG") + compare(control.popup.button1.LayoutMirroring.enabled, "ar_EG") + compare(control.popup.button2.LayoutMirroring.enabled, "ar_EG") + compare(control.localespy.count, 3) + compare(control.mirrorspy.count, 0) + compare(control.button.localespy.count, 4) + compare(control.button.mirrorspy.count, 0) + compare(control.popup.localespy.count, 3) + compare(control.popup.button1.localespy.count, 3) + compare(control.popup.button2.localespy.count, 3) + + control.popup.button1.locale = Qt.locale("nb_NO") + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, "ar_EG") + compare(control.LayoutMirroring.enabled, "ar_EG") + compare(control.button.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.LayoutMirroring.enabled, "ar_EG") + compare(control.popup.button1.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.button2.LayoutMirroring.enabled, "ar_EG") + compare(control.localespy.count, 3) + compare(control.mirrorspy.count, 0) + compare(control.button.localespy.count, 4) + compare(control.button.mirrorspy.count, 0) + compare(control.popup.localespy.count, 3) + compare(control.popup.button1.localespy.count, 4) + compare(control.popup.button1.mirrorspy.count, 0) + compare(control.popup.button2.localespy.count, 3) + compare(control.popup.button2.mirrorspy.count, 0) + + control.popup.locale = Qt.locale("fi_FI") + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, "ar_EG") + compare(control.LayoutMirroring.enabled, "ar_EG") + compare(control.button.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.LayoutMirroring.enabled, "fi_FI") + compare(control.popup.button1.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.button2.LayoutMirroring.enabled, "fi_FI") + compare(control.localespy.count, 3) + compare(control.mirrorspy.count, 0) + compare(control.button.localespy.count, 4) + compare(control.button.mirrorspy.count, 0) + compare(control.popup.localespy.count, 4) + compare(control.popup.button1.localespy.count, 4) + compare(control.popup.button1.mirrorspy.count, 0) + compare(control.popup.button2.localespy.count, 4) + compare(control.popup.button2.mirrorspy.count, 0) + + control.ApplicationWindow.window.locale = undefined + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.button.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.LayoutMirroring.enabled, "fi_FI") + compare(control.popup.button1.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.button2.LayoutMirroring.enabled, "fi_FI") + compare(control.localespy.count, 4) + compare(control.mirrorspy.count, 0) + compare(control.button.localespy.count, 4) + compare(control.button.mirrorspy.count, 0) + compare(control.popup.localespy.count, 4) + compare(control.popup.button1.localespy.count, 4) + compare(control.popup.button1.mirrorspy.count, 0) + compare(control.popup.button2.localespy.count, 4) + compare(control.popup.button2.mirrorspy.count, 0) + + control.popup.locale = undefined + compare(control.ApplicationWindow.window.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.button.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.popup.button1.LayoutMirroring.enabled, "nb_NO") + compare(control.popup.button2.LayoutMirroring.enabled, defaultLayoutMirroringEnabled) + compare(control.localespy.count, 4) + compare(control.mirrorspy.count, 0) + compare(control.button.localespy.count, 4) + compare(control.button.mirrorspy.count, 0) + compare(control.popup.localespy.count, 5) + compare(control.popup.button1.localespy.count, 4) + compare(control.popup.button1.mirrorspy.count, 0) + compare(control.popup.button2.localespy.count, 5) + compare(control.popup.button2.mirrorspy.count, 0) } function test_size() { diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml index 24f8a207..79f371cc 100644 --- a/tests/auto/controls/data/tst_rangeslider.qml +++ b/tests/auto/controls/data/tst_rangeslider.qml @@ -235,26 +235,31 @@ TestCase { // RTL locale control.locale = Qt.locale("ar_EG") - compare(control.first.visualPosition, 0.75) - compare(control.second.visualPosition, 0.0) + compare(control.mirrored, false) + compare(control.first.visualPosition, 0.25) + compare(control.second.visualPosition, 1.0) // RTL locale + LayoutMirroring control.LayoutMirroring.enabled = true + compare(control.mirrored, true) compare(control.first.visualPosition, 0.75) compare(control.second.visualPosition, 0.0) // LTR locale + LayoutMirroring control.locale = Qt.locale("en_US") + compare(control.mirrored, true) compare(control.first.visualPosition, 0.75) compare(control.second.visualPosition, 0.0) // LTR locale control.LayoutMirroring.enabled = false + compare(control.mirrored, false) compare(control.first.visualPosition, 0.25) compare(control.second.visualPosition, 1.0) // LayoutMirroring control.LayoutMirroring.enabled = true + compare(control.mirrored, true) compare(control.first.visualPosition, 0.75) compare(control.second.visualPosition, 0.0) } @@ -784,7 +789,8 @@ TestCase { // RTL control.first.value = 0 - control.locale = Qt.locale("ar_EG") + control.LayoutMirroring.enabled = true + compare(control.mirrored, true) mousePress(control, control.first.handle.x + control.first.handle.width / 2, control.first.handle.y + control.first.handle.height / 2, Qt.LeftButton) diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 280138c5..7465b94a 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -179,22 +179,27 @@ TestCase { // RTL locale control.locale = Qt.locale("ar_EG") - compare(control.visualPosition, 0.75) + compare(control.mirrored, false) + compare(control.visualPosition, 0.25) // RTL locale + LayoutMirroring control.LayoutMirroring.enabled = true + compare(control.mirrored, true) compare(control.visualPosition, 0.75) // LTR locale + LayoutMirroring control.locale = Qt.locale("en_US") + compare(control.mirrored, true) compare(control.visualPosition, 0.75) // LTR locale control.LayoutMirroring.enabled = false + compare(control.mirrored, false) compare(control.visualPosition, 0.25) // LayoutMirroring control.LayoutMirroring.enabled = true + compare(control.mirrored, true) compare(control.visualPosition, 0.75) } @@ -617,7 +622,8 @@ TestCase { // RTL control.value = 0 - control.locale = Qt.locale("ar_EG") + control.LayoutMirroring.enabled = true + compare(control.mirrored, true) mousePress(control, 0, 0, Qt.LeftButton) compare(pressedSpy.count, 3)