diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-02-15 10:51:51 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-02-18 15:56:27 +0000 |
commit | 6f264b755501fd322d1e357187b42120210a7ba3 (patch) | |
tree | 0ea8915de1e41bed87c62deffa19d61a0e6ff288 /tests/auto/qml/qqmlqt | |
parent | 3fcb6ccac0baa34b820534184f863884e072cfb2 (diff) |
Add Qt.hsva() function
This is more convenient than the alternative hsla() function in many
cases as color pickers in other applications default to the HSV color
space e.g. GIMP, kcolorchooser.
[ChangeLog][QtQml] Added Qt.hsva() function
Change-Id: Id5c1a78173757bf9842b164d90b31682e9a41749
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests/auto/qml/qqmlqt')
-rw-r--r-- | tests/auto/qml/qqmlqt/data/hsva.qml | 11 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/tst_qqmlqt.cpp | 23 |
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlqt/data/hsva.qml b/tests/auto/qml/qqmlqt/data/hsva.qml new file mode 100644 index 0000000000..4b73bf12eb --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/hsva.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +QtObject { + property color test1: Qt.hsva(1, 0, 0, 0.8); + property color test2: Qt.hsva(1, 0.5, 0.3); + property color test3: Qt.hsva(1, 1); + property color test4: Qt.hsva(1, 1, 1, 1, 1); + property color test5: Qt.hsva(1.2, 1.3, 1.4, 1.5); + property color test6: Qt.hsva(-0.1, -0.2, -0.3, -0.4); +} + diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index a881cdab80..671f7b5e73 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -61,6 +61,7 @@ private slots: void enums(); void rgba(); void hsla(); + void hsva(); void colorEqual(); void rect(); void point(); @@ -155,6 +156,28 @@ void tst_qqmlqt::hsla() delete object; } +void tst_qqmlqt::hsva() +{ + QQmlComponent component(&engine, testFileUrl("hsva.qml")); + + QString warning1 = component.url().toString() + ":6: Error: Qt.hsva(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.hsva(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHsvF(1, 0, 0, 0.8)); + QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHsvF(1, 0.5, 0.3, 1)); + QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHsvF(1, 1, 1, 1)); + QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromHsvF(0, 0, 0, 0)); + + delete object; +} + void tst_qqmlqt::colorEqual() { QQmlComponent component(&engine, testFileUrl("colorEqual.qml")); |