diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2020-03-27 13:58:13 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2020-04-02 09:26:40 +0100 |
commit | 19850f129881a04c36c51859454bf71ed688f28a (patch) | |
tree | 710468d765071c2cffd983a9165b36feae5346e6 /tests/auto/qml/qqmlqt/data | |
parent | b3d28f72862433f54033d1b744715a5699c1ee59 (diff) |
Implement modifying colors using methods
Instead of having to use Qt.tint, Qt.lighter or Qt.lighter you can now
directly use these on colors (e.g. color.tint("red")).
Also adds Qt.color to explicitly convert color strings into actual color
objects.
[ChangeLog][QML][General] Added Qt.color to turn color strings
into color objects
[ChangeLog][Quick][General] Make Qt.tint, Qt.lighter and
Qt.darker methods that can directly operate on color objects
Task-number: QTBUG-77635
Change-Id: Ie10ced7ba7f1dc10afdebbcbc8664d74cd6efccf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlqt/data')
-rw-r--r-- | tests/auto/qml/qqmlqt/data/color.qml | 10 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/data/darker.qml | 6 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/data/lighter.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/data/tint.qml | 5 |
4 files changed, 25 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlqt/data/color.qml b/tests/auto/qml/qqmlqt/data/color.qml new file mode 100644 index 0000000000..89e2216ce5 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/color.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.color("red") + property variant test2: Qt.color("#ff00ff00") + property variant test3: Qt.color("taint") // Taint is not a valid color + property variant test4: Qt.color(0.5) + property variant test5: Qt.color() + property variant test6: Qt.color("blue", 0) +} diff --git a/tests/auto/qml/qqmlqt/data/darker.qml b/tests/auto/qml/qqmlqt/data/darker.qml index ce6dea0dfe..0e96990219 100644 --- a/tests/auto/qml/qqmlqt/data/darker.qml +++ b/tests/auto/qml/qqmlqt/data/darker.qml @@ -8,5 +8,9 @@ QtObject { property variant test5: Qt.darker("perfectred"); // Non-existent color property variant test6: Qt.darker(10); property variant test7: Qt.darker(Qt.rgba(1, 0.8, 0.3), 2.8, 10) -} + property variant testColor1: Qt.rgba(1, 0.8, 0.3).darker() + property variant testColor3: Qt.rgba(1, 0.8, 0.3).darker(2.8) + property variant testColor4: Qt.color("red").darker(); + property variant testColor7: Qt.rgba(1, 0.8, 0.3).darker(2.8, 10); +} diff --git a/tests/auto/qml/qqmlqt/data/lighter.qml b/tests/auto/qml/qqmlqt/data/lighter.qml index bf57e08004..fcae1fbc52 100644 --- a/tests/auto/qml/qqmlqt/data/lighter.qml +++ b/tests/auto/qml/qqmlqt/data/lighter.qml @@ -8,4 +8,9 @@ QtObject { property variant test5: Qt.lighter("perfectred"); // Non-existent color property variant test6: Qt.lighter(10); property variant test7: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 1.8, 5) + + property variant testColor1: Qt.rgba(1, 0.8, 0.3).lighter() + property variant testColor3: Qt.rgba(1, 0.8, 0.3).lighter(1.8) + property variant testColor4: Qt.color("red").lighter(); + property variant testColor7: Qt.rgba(1, 0.8, 0.3).lighter(1.8, 5) } diff --git a/tests/auto/qml/qqmlqt/data/tint.qml b/tests/auto/qml/qqmlqt/data/tint.qml index 816e6e9b08..6faed1f39b 100644 --- a/tests/auto/qml/qqmlqt/data/tint.qml +++ b/tests/auto/qml/qqmlqt/data/tint.qml @@ -6,4 +6,9 @@ QtObject { property color test3: Qt.tint("red", Qt.rgba(0, 0, 1, 0.5)); property color test4: Qt.tint("red", Qt.rgba(0, 0, 1, 0.5), 10); property color test5: Qt.tint("red") + + property color testColor1: Qt.color("red").tint("blue"); + property color testColor2: Qt.rgba(1, 0, 0).tint(Qt.rgba(0, 0, 0, 0)); + property color testColor3: Qt.color("red").tint(Qt.rgba(0, 0, 1, 0.5)); + property color testColor5: Qt.color("red").tint() } |