Skip to content

Commit d425cbe

Browse files
author
brushtyler
committed
Improving the appearance of GRASS toolbox - take 2
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14594 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2a462df commit d425cbe

File tree

6 files changed

+50
-26
lines changed

6 files changed

+50
-26
lines changed

src/plugins/grass/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ FILE (GLOB GMLS *.gml)
173173
INSTALL (FILES ${GMLS} images/world.png
174174
DESTINATION ${QGIS_DATA_DIR}/grass)
175175

176+
INSTALL (FILES themes/gis/grass_arrow.png themes/gis/grass_plus.png
177+
DESTINATION ${QGIS_DATA_DIR}/grass/modules)
178+
176179
INSTALL(TARGETS qgis.g.browser
177180
RUNTIME DESTINATION ${QGIS_LIBEXEC_DIR}/grass/bin
178181
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE

src/plugins/grass/qgsgrassmodule.cpp

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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] );

src/plugins/grass/qgsgrasstools.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ QgsGrassTools::QgsGrassTools( QgisInterface *iface,
7979

8080
mListView->setModel( mModelProxy );
8181
mListView->setItemDelegateForColumn( 0, new QgsDetailedItemDelegate() );
82-
mListView->setUniformItemSizes( false );
82+
//mListView->setUniformItemSizes( false );
8383
//mListView2 = new QListView(this);
8484
//mDockWidget = new QDockWidget(tr("Grass Tools"), 0);
8585
//mDockWidget->setWidget(mListView2);
@@ -315,7 +315,7 @@ void QgsGrassTools::addModules( QTreeWidgetItem *parent, QDomElement &element )
315315
myData.setDetail( label );
316316
myData.setIcon( pixmap );
317317
myData.setCheckable( false );
318-
myData.setRenderAsWidget( true );
318+
myData.setRenderAsWidget( false );
319319
QVariant myVariant = qVariantFromValue( myData );
320320
mypDetailItem->setData( myVariant, Qt::UserRole );
321321
mModelTools->appendRow( mypDetailItem );

src/plugins/grass/qgsgrasstoolsbase.ui

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>400</width>
10-
<height>300</height>
9+
<width>350</width>
10+
<height>350</height>
1111
</rect>
1212
</property>
13+
<property name="minimumSize">
14+
<size>
15+
<width>350</width>
16+
<height>350</height>
17+
</size>
18+
</property>
1319
<property name="windowTitle">
1420
<string>Grass Tools</string>
1521
</property>
1622
<layout class="QGridLayout">
1723
<item row="0" column="0">
1824
<widget class="QTabWidget" name="mTabWidget">
1925
<property name="currentIndex">
20-
<number>0</number>
26+
<number>1</number>
2127
</property>
2228
<widget class="QWidget" name="modulesTree">
2329
<attribute name="title">
@@ -51,9 +57,6 @@
5157
<layout class="QGridLayout">
5258
<item row="0" column="0">
5359
<widget class="QListView" name="mListView">
54-
<property name="alternatingRowColors">
55-
<bool>true</bool>
56-
</property>
5760
<property name="wordWrap">
5861
<bool>true</bool>
5962
</property>
636 Bytes
Loading
1.38 KB
Loading

0 commit comments

Comments
 (0)