aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2021-05-21 16:41:31 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-17 07:59:14 +0000
commite7b03676349ba309d0c0bb3392d7b0cf701e9a53 (patch)
tree8993150bb44ae3be464f0f00c49c7350843a05a3
parent742ea91e4892a7eef01fbd933d8a43fb1386a8a2 (diff)
Add missing palette property to QQuickWindow
This was forgotten in 1875ad7f92cad270cc5857d71096a4b46c27c562. Fixes: QTBUG-91365 Change-Id: I8dabf0e2a5a13f0db5feac5c03e3494948393cb7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 249db12b6020cc3a8f04841b1e28cd529f4929d9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick/items/qquickwindow.h3
-rw-r--r--tests/auto/quick/qquickpalette/CMakeLists.txt24
-rw-r--r--tests/auto/quick/qquickpalette/data/palette-item-custom.qml73
-rw-r--r--tests/auto/quick/qquickpalette/data/palette-item-default.qml54
-rw-r--r--tests/auto/quick/qquickpalette/data/palette-window-custom.qml73
-rw-r--r--tests/auto/quick/qquickpalette/data/palette-window-default.qml54
-rw-r--r--tests/auto/quick/qquickpalette/tst_qquickpalette.cpp68
7 files changed, 341 insertions, 8 deletions
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index cd39bc13d3..48878b057d 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -65,6 +65,7 @@ class QQuickRenderControl;
class QSGRectangleNode;
class QSGImageNode;
class QSGNinePatchNode;
+class QQuickPalette;
class QQuickRenderTarget;
class QQuickGraphicsDevice;
class QQuickGraphicsConfiguration;
@@ -76,6 +77,8 @@ class Q_QUICK_EXPORT QQuickWindow : public QWindow
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(QQuickItem* contentItem READ contentItem CONSTANT)
Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged REVISION(2, 1))
+ Q_PRIVATE_PROPERTY(QQuickWindow::d_func(), QQuickPalette *palette READ palette WRITE setPalette
+ RESET resetPalette NOTIFY paletteChanged REVISION(6, 2))
QDOC_PROPERTY(QWindow* transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged)
Q_CLASSINFO("DefaultProperty", "data")
Q_DECLARE_PRIVATE(QQuickWindow)
diff --git a/tests/auto/quick/qquickpalette/CMakeLists.txt b/tests/auto/quick/qquickpalette/CMakeLists.txt
index a68873d5dc..98036c0a38 100644
--- a/tests/auto/quick/qquickpalette/CMakeLists.txt
+++ b/tests/auto/quick/qquickpalette/CMakeLists.txt
@@ -1,18 +1,28 @@
-# Generated from qquickpalette.pro.
-
-#####################################################################
-## tst_qquickpalette Test:
-#####################################################################
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ data/*)
+list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qquickpalette
SOURCES
+ ../../shared/util.h
+ ../../shared/util.cpp
tst_qquickpalette.cpp
PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::QmlPrivate
Qt::QuickPrivate
+ TESTDATA ${test_data}
+)
+
+qt_internal_extend_target(tst_qquickpalette CONDITION ANDROID OR IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\":/data\\\"
)
-## Scopes:
-#####################################################################
+qt_internal_extend_target(tst_qquickpalette CONDITION NOT ANDROID AND NOT IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\"
+)
diff --git a/tests/auto/quick/qquickpalette/data/palette-item-custom.qml b/tests/auto/quick/qquickpalette/data/palette-item-custom.qml
new file mode 100644
index 0000000000..96aca3ec0d
--- /dev/null
+++ b/tests/auto/quick/qquickpalette/data/palette-item-custom.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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
+
+Item {
+ palette.alternateBase: "aqua"
+ palette.base: "azure"
+ palette.brightText: "beige"
+ palette.button: "bisque"
+ palette.buttonText: "chocolate"
+ palette.dark: "coral"
+ palette.highlight: "crimson"
+ palette.highlightedText: "fuchsia"
+ palette.light: "gold"
+ palette.link: "indigo"
+ palette.linkVisited: "ivory"
+ palette.mid: "khaki"
+ palette.midlight: "lavender"
+ palette.shadow: "linen"
+ palette.text: "moccasin"
+ palette.toolTipBase: "navy"
+ palette.toolTipText: "orchid"
+ palette.window: "plum"
+ palette.windowText: "salmon"
+}
diff --git a/tests/auto/quick/qquickpalette/data/palette-item-default.qml b/tests/auto/quick/qquickpalette/data/palette-item-default.qml
new file mode 100644
index 0000000000..d9dcdeceba
--- /dev/null
+++ b/tests/auto/quick/qquickpalette/data/palette-item-default.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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
+
+Item {
+}
diff --git a/tests/auto/quick/qquickpalette/data/palette-window-custom.qml b/tests/auto/quick/qquickpalette/data/palette-window-custom.qml
new file mode 100644
index 0000000000..715f973d1f
--- /dev/null
+++ b/tests/auto/quick/qquickpalette/data/palette-window-custom.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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.Window
+
+Window {
+ palette.alternateBase: "aqua"
+ palette.base: "azure"
+ palette.brightText: "beige"
+ palette.button: "bisque"
+ palette.buttonText: "chocolate"
+ palette.dark: "coral"
+ palette.highlight: "crimson"
+ palette.highlightedText: "fuchsia"
+ palette.light: "gold"
+ palette.link: "indigo"
+ palette.linkVisited: "ivory"
+ palette.mid: "khaki"
+ palette.midlight: "lavender"
+ palette.shadow: "linen"
+ palette.text: "moccasin"
+ palette.toolTipBase: "navy"
+ palette.toolTipText: "orchid"
+ palette.window: "plum"
+ palette.windowText: "salmon"
+}
diff --git a/tests/auto/quick/qquickpalette/data/palette-window-default.qml b/tests/auto/quick/qquickpalette/data/palette-window-default.qml
new file mode 100644
index 0000000000..bb3358588e
--- /dev/null
+++ b/tests/auto/quick/qquickpalette/data/palette-window-default.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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.Window
+
+Window {
+}
diff --git a/tests/auto/quick/qquickpalette/tst_qquickpalette.cpp b/tests/auto/quick/qquickpalette/tst_qquickpalette.cpp
index e211a034ee..cca7b54a8a 100644
--- a/tests/auto/quick/qquickpalette/tst_qquickpalette.cpp
+++ b/tests/auto/quick/qquickpalette/tst_qquickpalette.cpp
@@ -40,11 +40,22 @@
#include <QtTest/qtest.h>
#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+
#include <QtQuick/private/qquickpalette_p.h>
#include <QtQuick/private/qquickabstractpaletteprovider_p.h>
#include <QtQuick/private/qquickpalettecolorprovider_p.h>
-class tst_QQuickPalette : public QObject
+#include "../../shared/util.h"
+
+// Use this to get a more descriptive failure message (QTBUG-87039).
+#define COMPARE_PALETTES(actualPalette, expectedPalette) \
+ QVERIFY2(actualPalette == expectedPalette, \
+ qPrintable(QString::fromLatin1("\n Actual: %1\n Expected: %2") \
+ .arg(QDebug::toString(actualPalette)).arg(QDebug::toString(expectedPalette))));
+
+class tst_QQuickPalette : public QQmlDataTest
{
Q_OBJECT
@@ -73,6 +84,9 @@ private Q_SLOTS:
void createFromQtPalette();
void convertToQtPalette();
+
+ void qml_data();
+ void qml();
};
using GroupGetter = QQuickColorGroup* (QQuickPalette::* )() const;
@@ -299,6 +313,58 @@ void tst_QQuickPalette::convertToQtPalette()
QCOMPARE(palette.toQPalette(), somePalette.resolve(pp->defaultPalette()));
}
+// QTBUG-93691
+void tst_QQuickPalette::qml_data()
+{
+ QTest::addColumn<QString>("testFile");
+ QTest::addColumn<QPalette>("expectedPalette");
+
+ const QPalette defaultPalette;
+ QTest::newRow("Item") << "palette-item-default.qml" << defaultPalette;
+ QTest::newRow("Window") << "palette-window-default.qml" << defaultPalette;
+
+ QPalette customPalette;
+ customPalette.setColor(QPalette::AlternateBase, QColor("aqua"));
+ customPalette.setColor(QPalette::Base, QColor("azure"));
+ customPalette.setColor(QPalette::BrightText, QColor("beige"));
+ customPalette.setColor(QPalette::Button, QColor("bisque"));
+ customPalette.setColor(QPalette::ButtonText, QColor("chocolate"));
+ customPalette.setColor(QPalette::Dark, QColor("coral"));
+ customPalette.setColor(QPalette::Highlight, QColor("crimson"));
+ customPalette.setColor(QPalette::HighlightedText, QColor("fuchsia"));
+ customPalette.setColor(QPalette::Light, QColor("gold"));
+ customPalette.setColor(QPalette::Link, QColor("indigo"));
+ customPalette.setColor(QPalette::LinkVisited, QColor("ivory"));
+ customPalette.setColor(QPalette::Mid, QColor("khaki"));
+ customPalette.setColor(QPalette::Midlight, QColor("lavender"));
+ customPalette.setColor(QPalette::Shadow, QColor("linen"));
+ customPalette.setColor(QPalette::Text, QColor("moccasin"));
+ customPalette.setColor(QPalette::ToolTipBase, QColor("navy"));
+ customPalette.setColor(QPalette::ToolTipText, QColor("orchid"));
+ customPalette.setColor(QPalette::Window, QColor("plum"));
+ customPalette.setColor(QPalette::WindowText, QColor("salmon"));
+
+ QTest::newRow("Item:custom") << "palette-item-custom.qml" << customPalette;
+ QTest::newRow("Window:custom") << "palette-window-custom.qml" << customPalette;
+}
+
+void tst_QQuickPalette::qml()
+{
+ QFETCH(QString, testFile);
+ QFETCH(QPalette, expectedPalette);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl(testFile));
+
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
+
+ const QVariant var = object->property("palette");
+ QVERIFY(var.isValid());
+ COMPARE_PALETTES(var.value<QQuickPalette*>()->toQPalette(), expectedPalette);
+}
+
QTEST_MAIN(tst_QQuickPalette)
#include "tst_qquickpalette.moc"