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 --- tests/auto/controls/data/tst_abstractbutton.qml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') 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(-) (limited to 'tests') 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 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 --- 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 ++++++++++++++++++++++++ 4 files changed, 202 insertions(+) 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 (limited to 'tests') 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