diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2017-06-14 10:58:38 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-06-24 21:24:53 +0000 |
commit | 8dd8acf8bbfde548756ccde52cb14c848f2d8739 (patch) | |
tree | a9941d71d6439b14541f28cd0bc93bdc7f1cadb9 /tests/auto/gui/image/qiconhighdpi | |
parent | d9206926d88b779495cc32c3cfec6bcc53021546 (diff) |
qt_findAtNxFile(): account for .9 (9-patch image) extensions
Currently a file with a .9.png extension will only have its @2x variant
found if it follows this format:
foo.9@2x.png
Since ".9" should be considered part of the file suffix, it should
ideally be able to look like this and still be picked up:
foo@2x.9.png
This patch makes qt_findAtNxFile() account for .9.* extensions.
This is needed for the image-based style support in Qt Quick Controls
2, which uses 9-patch images.
qmlbench benchmark results using
benchmarks\auto\creation\quick.image\delegates_image.qml with
QT_SCALE_FACTOR=2 show no difference in performance after this patch
is applied.
[ChangeLog][QtGui] High DPI variants of 9-patch images can now be
loaded using the following syntax: "foo@2x.9.png"
Change-Id: I6d1384113bef21b4fe85a104ee6b16869c93b077
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/gui/image/qiconhighdpi')
-rw-r--r-- | tests/auto/gui/image/qiconhighdpi/icons/misc/button.9.png | bin | 0 -> 329 bytes | |||
-rw-r--r-- | tests/auto/gui/image/qiconhighdpi/icons/misc/button@2x.9.png | bin | 0 -> 616 bytes | |||
-rw-r--r-- | tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp | 19 | ||||
-rw-r--r-- | tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.qrc | 2 |
4 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qiconhighdpi/icons/misc/button.9.png b/tests/auto/gui/image/qiconhighdpi/icons/misc/button.9.png Binary files differnew file mode 100644 index 0000000000..1a560a1d74 --- /dev/null +++ b/tests/auto/gui/image/qiconhighdpi/icons/misc/button.9.png diff --git a/tests/auto/gui/image/qiconhighdpi/icons/misc/button@2x.9.png b/tests/auto/gui/image/qiconhighdpi/icons/misc/button@2x.9.png Binary files differnew file mode 100644 index 0000000000..f010dc55c7 --- /dev/null +++ b/tests/auto/gui/image/qiconhighdpi/icons/misc/button@2x.9.png diff --git a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp index ce7f68a0a6..51892cca04 100644 --- a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp +++ b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp @@ -39,6 +39,7 @@ private slots: void initTestCase(); void fromTheme_data(); void fromTheme(); + void ninePatch(); }; tst_QIconHighDpi::tst_QIconHighDpi() @@ -182,6 +183,24 @@ void tst_QIconHighDpi::fromTheme() QCOMPARE(pixmap.devicePixelRatio(), expectedDpr); } +void tst_QIconHighDpi::ninePatch() +{ + const QIcon icon(":/icons/misc/button.9.png"); + const int dpr = qCeil(qApp->devicePixelRatio()); + + switch (dpr) { + case 1: + QCOMPARE(icon.availableSizes().size(), 1); + QCOMPARE(icon.availableSizes().at(0), QSize(42, 42)); + break; + case 2: + QCOMPARE(icon.availableSizes().size(), 2); + QCOMPARE(icon.availableSizes().at(0), QSize(42, 42)); + QCOMPARE(icon.availableSizes().at(1), QSize(82, 82)); + break; + } +} + int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); diff --git a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.qrc b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.qrc index 80b5e38ee6..5cc1c6d9b1 100644 --- a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.qrc +++ b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.qrc @@ -4,5 +4,7 @@ <file>icons/testtheme/22x22/actions/appointment-new.png</file> <file>icons/testtheme/index.theme</file> <file>icons/testtheme/22x22@2/actions/appointment-new.png</file> + <file>icons/misc/button.9.png</file> + <file>icons/misc/button@2x.9.png</file> </qresource> </RCC> |