Set QSS-parsed gradients' coordinate system to ObjectBoundingMode
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 16 Jun 2010 14:21:52 +0000 (16:21 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 16 Jun 2010 14:21:52 +0000 (16:21 +0200)
In this mode, gradient coordinates are relative to the bounding rect of the object
to be drawn. Thus, gradients can be specified between (0,0) and (1,1) in stylesheets
and will do The Right Thing™ regardless of the object's size.
This is also what Qt uses for its widgets.

src/uisupport/qssparser.cpp

index b91aef4..06e4db2 100644 (file)
@@ -466,6 +466,7 @@ QBrush QssParser::parseBrush(const QString &str, bool *ok) {
       return QBrush();
     }
     QLinearGradient gradient(x1, y1, x2, y2);
       return QBrush();
     }
     QLinearGradient gradient(x1, y1, x2, y2);
+    gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
     gradient.setStops(stops);
     if(ok)
       *ok = true;
     gradient.setStops(stops);
     if(ok)
       *ok = true;
@@ -487,6 +488,7 @@ QBrush QssParser::parseBrush(const QString &str, bool *ok) {
       return QBrush();
     }
     QConicalGradient gradient(cx, cy, angle);
       return QBrush();
     }
     QConicalGradient gradient(cx, cy, angle);
+    gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
     gradient.setStops(stops);
     if(ok)
       *ok = true;
     gradient.setStops(stops);
     if(ok)
       *ok = true;
@@ -510,6 +512,7 @@ QBrush QssParser::parseBrush(const QString &str, bool *ok) {
       return QBrush();
     }
     QRadialGradient gradient(cx, cy, radius, fx, fy);
       return QBrush();
     }
     QRadialGradient gradient(cx, cy, radius, fx, fy);
+    gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
     gradient.setStops(stops);
     if(ok)
       *ok = true;
     gradient.setStops(stops);
     if(ok)
       *ok = true;