From e5c0371d18e285d7849cbd0569970e209bd01b49 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 3 Mar 2017 14:40:40 +0100 Subject: Fix propagation of locale from widget to its children Fix the condition in QWidgetPrivate::resolveLocale() to decide whether to propagate locale: make it match setLocale_helper()'s condition when deciding whether to propagate to descendants. This lead to a QDateTimeEdit's calendar popup not getting told what locale to use correctly, unless we setLocale() on it overtly, which then blocked propagation of locale changes to it unless QDateTimeEdit manually propagated the changes. Fix the documentation of WA_WindowPropagation to mention locale as also being propagated (which it was in several places, only neglecting this one in resolveLocale). [ChangeLog][QWidget][Qt::WA_WindowPropagation] Propagate locale consistently, along with font and palette, within the widget hierarchy. Previously, locale was propagated on ancestral setLocale(), but not on creation of the descendant. Task-number: QTBUG-59106 Change-Id: I92270f7789c8eda66a458274a658c84c7b0df754 Reviewed-by: David Faure --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 731a8c5d91..2698777ac8 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -277,6 +277,7 @@ private slots: #endif void setLocale(); + void propagateLocale(); void deleteStyle(); void multipleToplevelFocusCheck(); void setFocus(); @@ -1203,6 +1204,33 @@ void tst_QWidget::setLocale() QCOMPARE(child2.locale(), QLocale(QLocale::French)); } +void tst_QWidget::propagateLocale() +{ + QWidget parent; + parent.setLocale(QLocale::French); + // Non-window widget; propagates locale: + QWidget *child = new QWidget(&parent); + QVERIFY(!child->isWindow()); + QVERIFY(!child->testAttribute(Qt::WA_WindowPropagation)); + QCOMPARE(child->locale(), QLocale(QLocale::French)); + parent.setLocale(QLocale::Italian); + QCOMPARE(child->locale(), QLocale(QLocale::Italian)); + delete child; + // Window: doesn't propagate locale: + child = new QWidget(&parent, Qt::Window); + QVERIFY(child->isWindow()); + QVERIFY(!child->testAttribute(Qt::WA_WindowPropagation)); + QCOMPARE(child->locale(), QLocale()); + parent.setLocale(QLocale::French); + QCOMPARE(child->locale(), QLocale()); + // ... unless we tell it to: + child->setAttribute(Qt::WA_WindowPropagation, true); + QVERIFY(child->testAttribute(Qt::WA_WindowPropagation)); + QCOMPARE(child->locale(), QLocale(QLocale::French)); + parent.setLocale(QLocale::Italian); + QCOMPARE(child->locale(), QLocale(QLocale::Italian)); +} + void tst_QWidget::visible_setWindowOpacity() { QScopedPointer testWidget(new QWidget); -- cgit v1.2.3