From 230d6f6adc580c853cc05f484e5000703f3e42b0 Mon Sep 17 00:00:00 2001 From: Antti Kokko Date: Tue, 30 Jul 2019 11:25:41 +0300 Subject: Add changes file for Qt 5.13.1 + 335314146dece4fa86c661a4094a2f73e5e81a43 Doc: Fix documentation warnings for Qt Quick Controls 2 + 7d001497ddcda501c55aac35b4c7a60980d9c6b5 Fix flaky tst_qquickmenu test + 9310d5fb5285ae5eb4b94c01606791319b775b85 Container: Keep currentIndex at 0 when removing item 0 if possible + 7431b0549a9bb69f5f4a036fc931683dd4e20d2c tst_accessibility: Simplify role verification + c49bb5bda32477a878b6b82b99f853cef1340890 CursorDelegate: stop cursor timer when interval is set to 0 + 1427b243cb69768e7ce2e6ea3ad75619deac104b Don't unnecessarily transform keysequences into strings + 4259e99c1990dc88632b85d945e9093cca47a831 doc - use the correct attributions file + e23d4b68f3f3b1467f032e4ce3501dab0feb5fee Material: account for accent color in flat highlighted button's ripple + 33e590ea30931306e055fe4a6ae38da8b3fe3d0c Bump version + 783bfd2182f667817213faf3f54a285057bd2456 Add changes file for Qt 5.12.4 + 761df2ced0081905b4238c66783bb276f504cf3d Accessibility: Switch should have checkbox as role + 2ea51ddea2b903d8115648a89d56b1e4b551e660 Accessibility: Remove redundant checkbox role code + 48f587be28e8b46e93703d7a4393b915b224495f Doc: Add specs about focus property + 188773bd1383883cd7247b6ded0d0b1a41689155 Doc: correct name of property in snippet + bb88d84475f7c4bb69528da5096f4d2c91667a3c Add a test for having a ShaderEffect as a delegate + 7ded94bf0eb2b78f37bb9f84a0cc36e4ec520023 SplitView: fix preferredHeight not being restored in restoreState() + b00d649f109b080b7068c4a7a2a7731d7fb51ea1 Simplify test a bit and make it less error-prone (adding type-safety) + 463a55d9593d6b03e09db440008e8b9320a28bc5 Binary compatibility file against Qt5.13.0 for QtQuickControls2 + 13bdd61c6597586f62558ca337c193ce03db26cc Bump version + 3574033d526c0a78236148354e1f48d7b9aafe10 Bump version + ce7c431fb23157fa5125d1102a594de045818a72 Fix crash in QQuickContainerPrivate::removeItem + 4f5da1ed1dc1d294c1c79b9f6124cedeaa45c4b6 Doc: Replace example file lists with links to code.qt.io + 83813e43405109478769010acf2caf85a4229501 QQuickComboBox: emit countChanged signal when model is updated + 1d06eb3f8215b67c5061ee3a076df405724ff7ee Fix Flaky tests Change-Id: I856bfc432911684bc0057d1b196fc456ce8f4819 Reviewed-by: Shawn Rutledge Reviewed-by: Mitch Curtis --- dist/changes-5.13.1 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 dist/changes-5.13.1 diff --git a/dist/changes-5.13.1 b/dist/changes-5.13.1 new file mode 100644 index 00000000..3acd7b6e --- /dev/null +++ b/dist/changes-5.13.1 @@ -0,0 +1,31 @@ +Qt 5.13.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.13.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.13 series is binary compatible with the 5.12.x series. +Applications compiled for 5.12 will continue to run with 5.13. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Controls * +**************************************************************************** + + - [QTBUG-76356] Accessibility: a Switch now has checkbox as its accessibleRole. + - [QTBUG-75572] Fixed an issue with transforming Shortcut.sequence to string. + - [QTBUG-75844] The text cursor no longer disappears while dragging it + around on iOS with the magnifier showing. + - [QTBUG-75972] The countChanged signal now will be emitted when a new + model is set on a ComboBox. + - [QTBUG-67343] It's now OK to use a ShaderEffect in a ComboBox delegate + (fixed in Qt Quick, tested in Controls 2) -- cgit v1.2.3 From 6a3356dfd8a98131d2912d16c666419d5eeaa10e Mon Sep 17 00:00:00 2001 From: Antti Kokko Date: Tue, 20 Aug 2019 13:16:24 +0300 Subject: Add changes file for Qt 5.12.5 + 335314146dece4fa86c661a4094a2f73e5e81a43 Doc: Fix documentation warnings for Qt Quick Controls 2 + 761df2ced0081905b4238c66783bb276f504cf3d Accessibility: Switch should have checkbox as role + 2ea51ddea2b903d8115648a89d56b1e4b551e660 Accessibility: Remove redundant checkbox role code + 48f587be28e8b46e93703d7a4393b915b224495f Doc: Add specs about focus property + 188773bd1383883cd7247b6ded0d0b1a41689155 Doc: correct name of property in snippet + bb88d84475f7c4bb69528da5096f4d2c91667a3c Add a test for having a ShaderEffect as a delegate + 3574033d526c0a78236148354e1f48d7b9aafe10 Bump version + ce7c431fb23157fa5125d1102a594de045818a72 Fix crash in QQuickContainerPrivate::removeItem + 1d06eb3f8215b67c5061ee3a076df405724ff7ee Fix Flaky tests + da06da57002b64cf4bcde0ca708b3275a5f919ae QQuickTextArea: prevent changing size of background recursively Change-Id: I139ae9181197f900aab385bd0a93c6902d3b22f1 Reviewed-by: Mitch Curtis --- dist/changes-5.12.5 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 dist/changes-5.12.5 diff --git a/dist/changes-5.12.5 b/dist/changes-5.12.5 new file mode 100644 index 00000000..3d5d25e7 --- /dev/null +++ b/dist/changes-5.12.5 @@ -0,0 +1,28 @@ +Qt 5.12.5 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.12.0 through 5.12.4. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Controls * +**************************************************************************** + + - TextArea: + * [QTBUG-76369] Fixed rendering issue using the Material style. + + - Container + * [QTBUG-76164] Fixed crash when removing items. -- cgit v1.2.3 From 382531ab5e2270833d3805c57c00ebcf6b24d635 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 25 Apr 2019 18:23:32 +0300 Subject: QQuickIcon: properly resolve implicit values when the property has not been set explicitly, the resolved mask must not contain a respective bit set either Change-Id: Iab0bd600b5bf458e26ed4601d4d2f608021f1518 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickicon.cpp | 10 +++++----- tests/auto/controls/data/tst_abstractbutton.qml | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp index 1b8f4797..bfa2f8c1 100644 --- a/src/quicktemplates2/qquickicon.cpp +++ b/src/quicktemplates2/qquickicon.cpp @@ -204,19 +204,19 @@ QQuickIcon QQuickIcon::resolve(const QQuickIcon &other) const QQuickIcon resolved = *this; if (!(d->resolveMask & QQuickIconPrivate::NameResolved)) - resolved.setName(other.name()); + resolved.d->name = other.name(); if (!(d->resolveMask & QQuickIconPrivate::SourceResolved)) - resolved.setSource(other.source()); + resolved.d->source = other.source(); if (!(d->resolveMask & QQuickIconPrivate::WidthResolved)) - resolved.setWidth(other.width()); + resolved.d->width = other.width(); if (!(d->resolveMask & QQuickIconPrivate::HeightResolved)) - resolved.setHeight(other.height()); + resolved.d->height = other.height(); if (!(d->resolveMask & QQuickIconPrivate::ColorResolved)) - resolved.setColor(other.color()); + resolved.d->color = other.color(); return resolved; } diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml index 80155f69..ee26a6d6 100644 --- a/tests/auto/controls/data/tst_abstractbutton.qml +++ b/tests/auto/controls/data/tst_abstractbutton.qml @@ -599,7 +599,7 @@ TestCase { AbstractButton { action: Action { text: "Default" - icon.name: "default" + icon.name: checked ? "checked" : "unchecked" icon.source: "qrc:/icons/default.png" checkable: true checked: true @@ -617,6 +617,7 @@ TestCase { compare(control.checkable, true) compare(control.checked, true) compare(control.enabled, false) + compare(control.icon.name, "checked") var textSpy = signalSpy.createObject(control, { target: control, signalName: "textChanged" }) verify(textSpy.valid) @@ -630,6 +631,7 @@ TestCase { compare(control.checkable, false) // propagates compare(control.checked, false) // propagates compare(control.enabled, true) // propagates + compare(control.icon.name, "unchecked") // propagates compare(textSpy.count, 1) // changes via button @@ -637,19 +639,23 @@ TestCase { control.checkable = true control.checked = true control.enabled = false + control.icon.name = "default" compare(control.text, "Button") compare(control.checkable, true) compare(control.checked, true) compare(control.enabled, false) + compare(control.icon.name, "default") compare(control.action.text, "Action") // does NOT propagate compare(control.action.checkable, true) // propagates compare(control.action.checked, true) // propagates compare(control.action.enabled, true) // does NOT propagate + compare(control.action.icon.name, control.action.checked ? "checked" : "unchecked") // does NOT propagate compare(textSpy.count, 2) // remove the action so that only the button's properties are left control.action = null compare(control.text, "Button") + compare(control.icon.name, "default") compare(textSpy.count, 2) // setting an action while button has a particular property set -- cgit v1.2.3 From b059cc37c0c8cf329fe2847b323c8283664f3bdd Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 6 Sep 2019 10:39:31 +0200 Subject: tst_dial: fix copy-paste mistake Slider was incorrectly used in a03b6fec6. Change-Id: Ib76172f9ea0dca3b776a74df2329bd63c72f8517 Reviewed-by: Liang Qi --- tests/auto/controls/data/tst_dial.qml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml index cd2f6112..86999594 100644 --- a/tests/auto/controls/data/tst_dial.qml +++ b/tests/auto/controls/data/tst_dial.qml @@ -470,15 +470,15 @@ TestCase { function test_snapMode_data(immediate) { return [ - { tag: "NoSnap", snapMode: Slider.NoSnap, from: 0, to: 2, values: [0, 0, 1], positions: [0, 0.5, 0.5] }, - { tag: "SnapAlways (0..2)", snapMode: Slider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapAlways (1..3)", snapMode: Slider.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapAlways (-1..1)", snapMode: Slider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] }, - { tag: "SnapAlways (1..-1)", snapMode: Slider.SnapAlways, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (0..2)", snapMode: Slider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (1..3)", snapMode: Slider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [immediate ? 0.0 : 0.5, 0.5, 0.5] }, - { tag: "SnapOnRelease (1..-1)", snapMode: Slider.SnapOnRelease, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] } + { tag: "NoSnap", snapMode: Dial.NoSnap, from: 0, to: 2, values: [0, 0, 1], positions: [0, 0.5, 0.5] }, + { tag: "SnapAlways (0..2)", snapMode: Dial.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapAlways (1..3)", snapMode: Dial.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapAlways (-1..1)", snapMode: Dial.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] }, + { tag: "SnapAlways (1..-1)", snapMode: Dial.SnapAlways, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapOnRelease (0..2)", snapMode: Dial.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapOnRelease (1..3)", snapMode: Dial.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapOnRelease (-1..1)", snapMode: Dial.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [immediate ? 0.0 : 0.5, 0.5, 0.5] }, + { tag: "SnapOnRelease (1..-1)", snapMode: Dial.SnapOnRelease, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] } ] } -- cgit v1.2.3 From 0bcd8ed5c38a451e7458b820a25449c9cb408704 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 9 Sep 2019 16:10:37 +0300 Subject: QQuickIcon: properly resolve implicit values - take 2 This is a follow up of 382531ab5e2270833d3805c57c00ebcf6b24d635, and amends 1241c80eca725c9ac46a0b94d6bdec11a5d00302 . when the property has not been set explicitly, the resolved mask must not contain a respective bit set either Change-Id: I45a334b51fce09ead8e30fe3326a94f35b0f4f56 Reviewed-by: Liang Qi --- src/quicktemplates2/qquickicon.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp index 63ca96d5..61803e30 100644 --- a/src/quicktemplates2/qquickicon.cpp +++ b/src/quicktemplates2/qquickicon.cpp @@ -227,22 +227,22 @@ QQuickIcon QQuickIcon::resolve(const QQuickIcon &other) const QQuickIcon resolved = *this; if (!(d->resolveMask & QQuickIconPrivate::NameResolved)) - resolved.d->name = other.name(); + resolved.d->name = other.d->name; if (!(d->resolveMask & QQuickIconPrivate::SourceResolved)) - resolved.d->source = other.source(); + resolved.d->source = other.d->source; if (!(d->resolveMask & QQuickIconPrivate::WidthResolved)) - resolved.d->width = other.width(); + resolved.d->width = other.d->width; if (!(d->resolveMask & QQuickIconPrivate::HeightResolved)) - resolved.d->height = other.height(); + resolved.d->height = other.d->height; if (!(d->resolveMask & QQuickIconPrivate::ColorResolved)) - resolved.d->color = other.color(); + resolved.d->color = other.d->color; if (!(d->resolveMask & QQuickIconPrivate::CacheResolved)) - resolved.setCache(other.cache()); + resolved.d->cache = other.d->cache; return resolved; } -- cgit v1.2.3 From 1fec97053884d998442710a5d4258ffb6bed8955 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 25 Apr 2019 18:23:43 +0300 Subject: QQuickIcon: prevent detach-ing when there is nothing to change saves a bunch of pointless detach attempts on each deep-copy Change-Id: Ibb1ae99bd54b2d35f9c9aa9e541fb03891ad94ec Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickicon.cpp | 13 +++++++++++++ src/quicktemplates2/qquickicon_p.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp index 61803e30..bf0a4658 100644 --- a/src/quicktemplates2/qquickicon.cpp +++ b/src/quicktemplates2/qquickicon.cpp @@ -112,12 +112,14 @@ void QQuickIcon::setName(const QString &name) if ((d->resolveMask & QQuickIconPrivate::NameResolved) && d->name == name) return; + d.detach(); d->name = name; d->resolveMask |= QQuickIconPrivate::NameResolved; } void QQuickIcon::resetName() { + d.detach(); d->name = QString(); d->resolveMask &= ~QQuickIconPrivate::NameResolved; } @@ -132,12 +134,14 @@ void QQuickIcon::setSource(const QUrl &source) if ((d->resolveMask & QQuickIconPrivate::SourceResolved) && d->source == source) return; + d.detach(); d->source = source; d->resolveMask |= QQuickIconPrivate::SourceResolved; } void QQuickIcon::resetSource() { + d.detach(); d->source = QString(); d->resolveMask &= ~QQuickIconPrivate::SourceResolved; } @@ -152,12 +156,14 @@ void QQuickIcon::setWidth(int width) if ((d->resolveMask & QQuickIconPrivate::WidthResolved) && d->width == width) return; + d.detach(); d->width = width; d->resolveMask |= QQuickIconPrivate::WidthResolved; } void QQuickIcon::resetWidth() { + d.detach(); d->width = 0; d->resolveMask &= ~QQuickIconPrivate::WidthResolved; } @@ -172,12 +178,14 @@ void QQuickIcon::setHeight(int height) if ((d->resolveMask & QQuickIconPrivate::HeightResolved) && d->height == height) return; + d.detach(); d->height = height; d->resolveMask |= QQuickIconPrivate::HeightResolved; } void QQuickIcon::resetHeight() { + d.detach(); d->height = 0; d->resolveMask &= ~QQuickIconPrivate::HeightResolved; } @@ -192,12 +200,14 @@ void QQuickIcon::setColor(const QColor &color) if ((d->resolveMask & QQuickIconPrivate::ColorResolved) && d->color == color) return; + d.detach(); d->color = color; d->resolveMask |= QQuickIconPrivate::ColorResolved; } void QQuickIcon::resetColor() { + d.detach(); d->color = Qt::transparent; d->resolveMask &= ~QQuickIconPrivate::ColorResolved; } @@ -212,12 +222,14 @@ void QQuickIcon::setCache(bool cache) if ((d->resolveMask & QQuickIconPrivate::CacheResolved) && d->cache == cache) return; + d.detach(); d->cache = cache; d->resolveMask |= QQuickIconPrivate::CacheResolved; } void QQuickIcon::resetCache() { + d.detach(); d->cache = true; d->resolveMask &= ~QQuickIconPrivate::CacheResolved; } @@ -225,6 +237,7 @@ void QQuickIcon::resetCache() QQuickIcon QQuickIcon::resolve(const QQuickIcon &other) const { QQuickIcon resolved = *this; + resolved.d.detach(); if (!(d->resolveMask & QQuickIconPrivate::NameResolved)) resolved.d->name = other.d->name; diff --git a/src/quicktemplates2/qquickicon_p.h b/src/quicktemplates2/qquickicon_p.h index 57cab720..1835585d 100644 --- a/src/quicktemplates2/qquickicon_p.h +++ b/src/quicktemplates2/qquickicon_p.h @@ -107,7 +107,7 @@ public: QQuickIcon resolve(const QQuickIcon &other) const; private: - QSharedDataPointer d; + QExplicitlySharedDataPointer d; }; QT_END_NAMESPACE -- cgit v1.2.3 From c18c7bd7f9596e5ad3d13876a91203e1ceba2544 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 9 Sep 2019 15:59:49 +0200 Subject: DialogButtonBox: fix standard buttons not being translated When calling QQmlEngine::retranslate() after component completion, buttons in a DialogButtonBox were not being retranslated. For now the only way to be notified of language change events is by installing an event filter on the application, but in the future we can use the solution to QTBUG-78141 instead. Change-Id: Ibc435c3829945489adcbaa8a813013fe735a9c38 Fixes: QTBUG-75085 Reviewed-by: Andy Shaw --- src/quicktemplates2/qquickdialogbuttonbox.cpp | 44 ++++++++++- src/quicktemplates2/qquickdialogbuttonbox_p_p.h | 2 + tests/auto/translation/data/dialogButtonBox.qml | 61 +++++++++++++++ tests/auto/translation/qtbase_fr.ts | 22 ++++++ tests/auto/translation/translation.pro | 19 +++++ tests/auto/translation/tst_translation.cpp | 100 ++++++++++++++++++++++++ 6 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 tests/auto/translation/data/dialogButtonBox.qml create mode 100644 tests/auto/translation/qtbase_fr.ts create mode 100644 tests/auto/translation/translation.pro create mode 100644 tests/auto/translation/tst_translation.cpp diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index 91fb41f2..10d80778 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -430,7 +430,8 @@ void QQuickDialogButtonBoxPrivate::removeStandardButtons() while (i >= 0) { QQuickAbstractButton *button = qobject_cast(q->itemAt(i)); if (button) { - QQuickDialogButtonBoxAttached *attached = qobject_cast(qmlAttachedPropertiesObject(button, false)); + QQuickDialogButtonBoxAttached *attached = qobject_cast( + qmlAttachedPropertiesObject(button, false)); if (attached) { QQuickDialogButtonBoxAttachedPrivate *p = QQuickDialogButtonBoxAttachedPrivate::get(attached); if (p->standardButton != QPlatformDialogHelper::NoButton) { @@ -443,6 +444,24 @@ void QQuickDialogButtonBoxPrivate::removeStandardButtons() } } +void QQuickDialogButtonBoxPrivate::updateLanguage() +{ + Q_Q(QQuickDialogButtonBox); + int i = q->count() - 1; + while (i >= 0) { + QQuickAbstractButton *button = qobject_cast(itemAt(i)); + if (button) { + QQuickDialogButtonBoxAttached *attached = qobject_cast( + qmlAttachedPropertiesObject(button, true)); + const auto boxAttachedPrivate = QQuickDialogButtonBoxAttachedPrivate::get(attached); + const QPlatformDialogHelper::StandardButton standardButton = boxAttachedPrivate->standardButton; + const QString buttonText = QGuiApplicationPrivate::platformTheme()->standardButtonText(standardButton); + button->setText(QPlatformTheme::removeMnemonics(buttonText)); + } + --i; + } +} + QQuickDialogButtonBox::QQuickDialogButtonBox(QQuickItem *parent) : QQuickContainer(*(new QQuickDialogButtonBoxPrivate), parent) { @@ -684,11 +703,34 @@ void QQuickDialogButtonBox::updatePolish() d->updateLayout(); } +class LanguageEventFilter : public QObject +{ +public: + LanguageEventFilter(QQuickDialogButtonBoxPrivate *box) + : QObject(box->q_ptr) + , boxPrivate(box) + { + } + +protected: + bool eventFilter(QObject *, QEvent *event) + { + if (event->type() == QEvent::LanguageChange) + boxPrivate->updateLanguage(); + return false; + } + +private: + QQuickDialogButtonBoxPrivate *boxPrivate; +}; + void QQuickDialogButtonBox::componentComplete() { Q_D(QQuickDialogButtonBox); QQuickContainer::componentComplete(); d->updateLayout(); + // TODO: use the solution in QTBUG-78141 instead, when it's implemented. + qApp->installEventFilter(new LanguageEventFilter(d)); } void QQuickDialogButtonBox::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h index 66386911..6f9c9033 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h +++ b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h @@ -78,6 +78,8 @@ public: QQuickAbstractButton *createStandardButton(QPlatformDialogHelper::StandardButton button); void removeStandardButtons(); + void updateLanguage(); + Qt::Alignment alignment = 0; QQuickDialogButtonBox::Position position = QQuickDialogButtonBox::Footer; QPlatformDialogHelper::StandardButtons standardButtons = QPlatformDialogHelper::NoButton; diff --git a/tests/auto/translation/data/dialogButtonBox.qml b/tests/auto/translation/data/dialogButtonBox.qml new file mode 100644 index 00000000..03a3ae0e --- /dev/null +++ b/tests/auto/translation/data/dialogButtonBox.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.13 +import QtQuick.Controls 2.13 + +Item { + property Dialog dialog: Dialog { + width: 300 + height: 300 + visible: true + standardButtons: DialogButtonBox.Save | DialogButtonBox.Discard + } +} diff --git a/tests/auto/translation/qtbase_fr.ts b/tests/auto/translation/qtbase_fr.ts new file mode 100644 index 00000000..a2a05a07 --- /dev/null +++ b/tests/auto/translation/qtbase_fr.ts @@ -0,0 +1,22 @@ + + + + + QPlatformTheme + + Save + Enregistrer + + + Discard + Ne pas tenir compte + + + + QGnomeTheme + + &Save + &Enregistrer + + + diff --git a/tests/auto/translation/translation.pro b/tests/auto/translation/translation.pro new file mode 100644 index 00000000..d2d9d6ee --- /dev/null +++ b/tests/auto/translation/translation.pro @@ -0,0 +1,19 @@ +CONFIG += testcase +TARGET = tst_translation +SOURCES += tst_translation.cpp + +macos:CONFIG -= app_bundle + +QT += testlib gui-private quicktemplates2-private + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/*.qml + +# We only want to run lrelease, which is why we use EXTRA_TRANSLATIONS. +EXTRA_TRANSLATIONS = qtbase_fr.ts +# Embed the translations in a qrc file. +CONFIG += lrelease embed_translations diff --git a/tests/auto/translation/tst_translation.cpp b/tests/auto/translation/tst_translation.cpp new file mode 100644 index 00000000..9cbca915 --- /dev/null +++ b/tests/auto/translation/tst_translation.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "../shared/visualtestutil.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace QQuickVisualTestUtil; + +class tst_translation : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void dialogButtonBox(); +}; + +void tst_translation::dialogButtonBox() +{ + QQuickView view(testFileUrl("dialogButtonBox.qml")); + if (view.status() != QQuickView::Ready) + QFAIL("Failed to load QML file"); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QQuickDialog *dialog = view.rootObject()->property("dialog").value(); + QVERIFY(dialog); + + QQuickDialogButtonBox *dialogButtonBox = qobject_cast(dialog->footer()); + QVERIFY(dialogButtonBox); + + QQuickAbstractButton *saveButton = dialogButtonBox->standardButton(QPlatformDialogHelper::Save); + QVERIFY(saveButton); + QString defaultSaveText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Save); + defaultSaveText = QPlatformTheme::removeMnemonics(defaultSaveText); + QCOMPARE(saveButton->text(), defaultSaveText); + + QQuickAbstractButton *discardButton = dialogButtonBox->standardButton(QPlatformDialogHelper::Discard); + QVERIFY(discardButton); + QString defaultDiscardText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Discard); + defaultDiscardText = QPlatformTheme::removeMnemonics(defaultDiscardText); + QCOMPARE(discardButton->text(), defaultDiscardText); + + QTranslator translator; + QVERIFY(translator.load(":/i18n/qtbase_fr.qm")); + QVERIFY(qApp->installTranslator(&translator)); + view.engine()->retranslate(); + + QString translatedSaveText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Save); + translatedSaveText = QPlatformTheme::removeMnemonics(translatedSaveText); + QCOMPARE(saveButton->text(), translatedSaveText); + + QString translatedDiscardText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Discard); + translatedDiscardText = QPlatformTheme::removeMnemonics(translatedDiscardText); + QCOMPARE(discardButton->text(), translatedDiscardText); +} + +QTEST_MAIN(tst_translation) + +#include "tst_translation.moc" -- cgit v1.2.3