Allow borderimage .sci source to be a quoted filename
authorChris Adams <christopher.adams@nokia.com>
Mon, 8 Aug 2011 05:00:29 +0000 (15:00 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 17 Aug 2011 01:49:58 +0000 (03:49 +0200)
Previously, attempting to set the source property of a border image
via a .sci file to a quoted filename would fail.  This commit adds
support for quoted source filenames.

Task-number: QTBUG-20709
Change-Id: Ida54ef42bc07081457fd945bb279f3cc82c26e10
Reviewed-on: http://codereview.qt.nokia.com/2724
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Damian Jansen <damian.jansen@nokia.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>

src/declarative/items/qsgscalegrid.cpp
src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp
tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci [new file with mode: 0644]
tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp
tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci [new file with mode: 0644]
tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp

index a9eb080..e1b76c4 100644 (file)
@@ -164,6 +164,8 @@ QSGGridScaledImage::QSGGridScaledImage(QIODevice *data)
     _l = l; _r = r; _t = t; _b = b;
 
     _pix = imgFile;
+    if (_pix.startsWith(QLatin1Char('"')) && _pix.endsWith(QLatin1Char('"')))
+        _pix = _pix.mid(1, _pix.size() - 2); // remove leading/trailing quotes.
 }
 
 QSGBorderImage::TileMode QSGGridScaledImage::stringToRule(const QString &s)
index 83a94ec..bcdf92c 100644 (file)
@@ -167,6 +167,8 @@ QDeclarative1GridScaledImage::QDeclarative1GridScaledImage(QIODevice *data)
     _l = l; _r = r; _t = t; _b = b;
 
     _pix = imgFile;
+    if (_pix.startsWith(QLatin1Char('"')) && _pix.endsWith(QLatin1Char('"')))
+        _pix = _pix.mid(1, _pix.size() - 2); // remove leading/trailing quotes.
 }
 
 QDeclarative1BorderImage::TileMode QDeclarative1GridScaledImage::stringToRule(const QString &s)
diff --git a/tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci b/tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci
new file mode 100644 (file)
index 0000000..294f3cf
--- /dev/null
@@ -0,0 +1,7 @@
+border.left:10
+border.top:20
+border.right:30
+border.bottom:40
+horizontalTileRule:Round
+verticalTileRule:Repeat
+source:"colors.png"
index 75cc6a0..d1fe084 100644 (file)
@@ -324,8 +324,10 @@ void tst_qsgborderimage::sciSource_data()
     QTest::addColumn<bool>("valid");
 
     QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true;
+    QTest::newRow("local quoted filename") << QUrl::fromLocalFile(SRCDIR "/data/colors-round-quotes.sci").toString() << true;
     QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false;
     QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
+    QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
     QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
     QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
 }
diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci
new file mode 100644 (file)
index 0000000..294f3cf
--- /dev/null
@@ -0,0 +1,7 @@
+border.left:10
+border.top:20
+border.right:30
+border.bottom:40
+horizontalTileRule:Round
+verticalTileRule:Repeat
+source:"colors.png"
index d563146..9ef2aae 100644 (file)
@@ -333,8 +333,10 @@ void tst_qdeclarativeborderimage::sciSource_data()
     QTest::addColumn<bool>("valid");
 
     QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true;
+    QTest::newRow("local quoted filename") << QUrl::fromLocalFile(SRCDIR "/data/colors-round-quotes.sci").toString() << true;
     QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false;
     QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
+    QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
     QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
     QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
 }