Skip to content
Permalink
Browse files

Improving the appearance of GRASS toolbox - take 2

git-svn-id: http://svn.osgeo.org/qgis/trunk@14594 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler
brushtyler committed Nov 13, 2010
1 parent 46ea9d3 commit c0bd0c0a737285699201d7008160a4afe4ec7134
@@ -173,6 +173,9 @@ FILE (GLOB GMLS *.gml)
INSTALL (FILES ${GMLS} images/world.png
DESTINATION ${QGIS_DATA_DIR}/grass)

INSTALL (FILES themes/gis/grass_arrow.png themes/gis/grass_plus.png
DESTINATION ${QGIS_DATA_DIR}/grass/modules)

INSTALL(TARGETS qgis.g.browser
RUNTIME DESTINATION ${QGIS_LIBEXEC_DIR}/grass/bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
@@ -1112,8 +1112,38 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )

if ( width <= 0 ) width = height; //should not happen

int plusWidth = 8; // +
int arrowWidth = 9; // ->
QString iconsPath = QgsApplication::pkgDataPath() + "/grass/modules/";
QFileInfo iconsfi( iconsPath );

int plusWidth = 8;
int arrowWidth = 9;

QString arrowPath = iconsPath + "grass_arrow.png";
QPixmap arrowPixmap;
iconsfi.setFile( arrowPath );
if ( iconsfi.exists() && arrowPixmap.load( arrowPath, "PNG" ) )
{
double scale = 1. * height / arrowPixmap.height();
arrowWidth = ( int )( scale * arrowPixmap.width() );

QImage img = arrowPixmap.toImage();
img = img.scaled( arrowWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
arrowPixmap = QPixmap::fromImage( img );
}

QString plusPath = iconsPath + "grass_plus.png";
QPixmap plusPixmap;
iconsfi.setFile( plusPath );
if ( iconsfi.exists() && plusPixmap.load( plusPath, "PNG" ) )
{
double scale = 1. * height / plusPixmap.height();
plusWidth = ( int )( scale * plusPixmap.width() );

QImage img = plusPixmap.toImage();
img = img.scaled( plusWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
plusPixmap = QPixmap::fromImage( img );
}

int buffer = 10; // buffer around a sign
if ( pixmaps.size() > 1 ) width += arrowWidth + 2 * buffer; // ->
if ( pixmaps.size() > 2 ) width += plusWidth + 2 * buffer; // +
@@ -1123,8 +1153,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
//pixmap.fill( QColor( 255, 255, 255 ) );
QPainter painter( &pixmap );

QColor color( 255, 255, 255 );
painter.setBrush( QBrush( color ) );
//QColor color( 255, 255, 255 );
//painter.setBrush( QBrush( color ) );

painter.setRenderHint( QPainter::Antialiasing );

@@ -1134,25 +1164,13 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
if ( i == 1 && pixmaps.size() == 3 ) // +
{
pos += buffer;

painter.setPen( QPen( color, 3 ) );
painter.drawLine( pos, height / 2, pos + plusWidth, height / 2 );
painter.drawLine( pos + plusWidth / 2, height / 2 - plusWidth / 2, pos + plusWidth / 2, height / 2 + plusWidth / 2 );
painter.drawPixmap( pos, 0, plusPixmap );
pos += buffer + plusWidth;
}
if (( i == 1 && pixmaps.size() == 2 ) || ( i == 2 && pixmaps.size() == 3 ) ) // ->
{
pos += buffer;
painter.setPen( QPen( color, 3 ) );
painter.drawLine( pos, height / 2, pos + arrowWidth - arrowWidth / 2, height / 2 );

QPolygon pa( 3 );
pa.setPoint( 0, pos + arrowWidth / 2 + 1, height / 2 - arrowWidth / 2 );
pa.setPoint( 1, pos + arrowWidth, height / 2 );
pa.setPoint( 2, pos + arrowWidth / 2 + 1, height / 2 + arrowWidth / 2 );
painter.setPen( QPen( color, 1 ) );
painter.drawPolygon( pa );

painter.drawPixmap( pos, 0, arrowPixmap );
pos += buffer + arrowWidth;
}
painter.drawPixmap( pos, 0, pixmaps[i] );
@@ -79,7 +79,7 @@ QgsGrassTools::QgsGrassTools( QgisInterface *iface,

mListView->setModel( mModelProxy );
mListView->setItemDelegateForColumn( 0, new QgsDetailedItemDelegate() );
mListView->setUniformItemSizes( false );
//mListView->setUniformItemSizes( false );
//mListView2 = new QListView(this);
//mDockWidget = new QDockWidget(tr("Grass Tools"), 0);
//mDockWidget->setWidget(mListView2);
@@ -315,7 +315,7 @@ void QgsGrassTools::addModules( QTreeWidgetItem *parent, QDomElement &element )
myData.setDetail( label );
myData.setIcon( pixmap );
myData.setCheckable( false );
myData.setRenderAsWidget( true );
myData.setRenderAsWidget( false );
QVariant myVariant = qVariantFromValue( myData );
mypDetailItem->setData( myVariant, Qt::UserRole );
mModelTools->appendRow( mypDetailItem );
@@ -6,18 +6,24 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>350</width>
<height>350</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>350</height>
</size>
</property>
<property name="windowTitle">
<string>Grass Tools</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="mTabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="modulesTree">
<attribute name="title">
@@ -51,9 +57,6 @@
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QListView" name="mListView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
Binary file not shown.
Binary file not shown.

0 comments on commit c0bd0c0

Please sign in to comment.
You can’t perform that action at this time.