@@ -1112,8 +1112,38 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
11121112
11131113 if ( width <= 0 ) width = height; // should not happen
11141114
1115- int plusWidth = 8 ; // +
1116- int arrowWidth = 9 ; // ->
1115+ QString iconsPath = QgsApplication::pkgDataPath () + " /grass/modules/" ;
1116+ QFileInfo iconsfi ( iconsPath );
1117+
1118+ int plusWidth = 8 ;
1119+ int arrowWidth = 9 ;
1120+
1121+ QString arrowPath = iconsPath + " grass_arrow.png" ;
1122+ QPixmap arrowPixmap;
1123+ iconsfi.setFile ( arrowPath );
1124+ if ( iconsfi.exists () && arrowPixmap.load ( arrowPath, " PNG" ) )
1125+ {
1126+ double scale = 1 . * height / arrowPixmap.height ();
1127+ arrowWidth = ( int )( scale * arrowPixmap.width () );
1128+
1129+ QImage img = arrowPixmap.toImage ();
1130+ img = img.scaled ( arrowWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
1131+ arrowPixmap = QPixmap::fromImage ( img );
1132+ }
1133+
1134+ QString plusPath = iconsPath + " grass_plus.png" ;
1135+ QPixmap plusPixmap;
1136+ iconsfi.setFile ( plusPath );
1137+ if ( iconsfi.exists () && plusPixmap.load ( plusPath, " PNG" ) )
1138+ {
1139+ double scale = 1 . * height / plusPixmap.height ();
1140+ plusWidth = ( int )( scale * plusPixmap.width () );
1141+
1142+ QImage img = plusPixmap.toImage ();
1143+ img = img.scaled ( plusWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
1144+ plusPixmap = QPixmap::fromImage ( img );
1145+ }
1146+
11171147 int buffer = 10 ; // buffer around a sign
11181148 if ( pixmaps.size () > 1 ) width += arrowWidth + 2 * buffer; // ->
11191149 if ( pixmaps.size () > 2 ) width += plusWidth + 2 * buffer; // +
@@ -1123,8 +1153,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
11231153 // pixmap.fill( QColor( 255, 255, 255 ) );
11241154 QPainter painter ( &pixmap );
11251155
1126- QColor color ( 255 , 255 , 255 );
1127- painter.setBrush ( QBrush ( color ) );
1156+ // QColor color( 255, 255, 255 );
1157+ // painter.setBrush( QBrush( color ) );
11281158
11291159 painter.setRenderHint ( QPainter::Antialiasing );
11301160
@@ -1134,25 +1164,13 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
11341164 if ( i == 1 && pixmaps.size () == 3 ) // +
11351165 {
11361166 pos += buffer;
1137-
1138- painter.setPen ( QPen ( color, 3 ) );
1139- painter.drawLine ( pos, height / 2 , pos + plusWidth, height / 2 );
1140- painter.drawLine ( pos + plusWidth / 2 , height / 2 - plusWidth / 2 , pos + plusWidth / 2 , height / 2 + plusWidth / 2 );
1167+ painter.drawPixmap ( pos, 0 , plusPixmap );
11411168 pos += buffer + plusWidth;
11421169 }
11431170 if (( i == 1 && pixmaps.size () == 2 ) || ( i == 2 && pixmaps.size () == 3 ) ) // ->
11441171 {
11451172 pos += buffer;
1146- painter.setPen ( QPen ( color, 3 ) );
1147- painter.drawLine ( pos, height / 2 , pos + arrowWidth - arrowWidth / 2 , height / 2 );
1148-
1149- QPolygon pa ( 3 );
1150- pa.setPoint ( 0 , pos + arrowWidth / 2 + 1 , height / 2 - arrowWidth / 2 );
1151- pa.setPoint ( 1 , pos + arrowWidth, height / 2 );
1152- pa.setPoint ( 2 , pos + arrowWidth / 2 + 1 , height / 2 + arrowWidth / 2 );
1153- painter.setPen ( QPen ( color, 1 ) );
1154- painter.drawPolygon ( pa );
1155-
1173+ painter.drawPixmap ( pos, 0 , arrowPixmap );
11561174 pos += buffer + arrowWidth;
11571175 }
11581176 painter.drawPixmap ( pos, 0 , pixmaps[i] );
0 commit comments