Skip to content

Commit

Permalink
Use a hacky generic icon for 3d symbols in style manager for now
Browse files Browse the repository at this point in the history
Because implementing proper thumbnails is a considerable task in itself...
  • Loading branch information
nyalldawson committed Jul 29, 2020
1 parent a3e1d0c commit d30a44d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/core/symbology/qgsstylemodel.cpp
Expand Up @@ -316,9 +316,28 @@ QVariant QgsStyleModel::data( const QModelIndex &index, int role ) const
return icon;
}

case QgsStyle::Symbol3DEntity:
{
// hack for now -- we just use a generic "3d icon" svg file.
// TODO - render proper thumbnails

// use cached icon if possible
QIcon icon = mIconCache[ entityType ].value( name );
if ( !icon.isNull() )
return icon;

if ( mAdditionalSizes.isEmpty() )
icon.addFile( QgsApplication::defaultThemePath() + QDir::separator() + QStringLiteral( "3d.svg" ), QSize( 24, 24 ) );
for ( const QSize &s : mAdditionalSizes )
{
icon.addFile( QgsApplication::defaultThemePath() + QDir::separator() + QStringLiteral( "3d.svg" ), s );
}
mIconCache[ entityType ].insert( name, icon );
return icon;
}

case QgsStyle::TagEntity:
case QgsStyle::SmartgroupEntity:
case QgsStyle::Symbol3DEntity:
return QVariant();
}
break;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsstylemodel.py
Expand Up @@ -630,7 +630,7 @@ def test_mixed_style(self):
# decorations
self.assertIsNone(model.data(model.index(-1, 0), Qt.DecorationRole))
self.assertIsNone(model.data(model.index(0, 1), Qt.DecorationRole))
self.assertIsNone(model.data(model.index(17, 0), Qt.DecorationRole))
self.assertIsNone(model.data(model.index(20, 0), Qt.DecorationRole))
self.assertFalse(model.data(model.index(0, 0), Qt.DecorationRole).isNull())
self.assertFalse(model.data(model.index(5, 0), Qt.DecorationRole).isNull())
self.assertFalse(model.data(model.index(8, 0), Qt.DecorationRole).isNull())
Expand Down

0 comments on commit d30a44d

Please sign in to comment.