Skip to content
Permalink
Browse files

Also show a preview tooltip for symbol buttons

  • Loading branch information
nyalldawson committed Oct 2, 2018
1 parent 8f78beb commit 62d6c8c625dfc7fa4a513084e300cf8794b39fc8
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/gui/qgssymbolbutton.cpp
@@ -470,6 +470,15 @@ void QgsSymbolButton::updatePreview( const QColor &color, QgsSymbol *tempSymbol
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( previewSymbol.get(), currentIconSize );
setIconSize( currentIconSize );
setIcon( icon );

// set tooltip
// create very large preview image
int size = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 20 );
QPixmap pm = QgsSymbolLayerUtils::symbolPreviewPixmap( previewSymbol.get(), QSize( size, size ), size / 20 );
QByteArray data;
QBuffer buffer( &data );
pm.save( &buffer, "PNG", 100 );
setToolTip( QStringLiteral( "<img src='data:image/png;base64, %3'>" ).arg( QString( data.toBase64() ) ) );
}

bool QgsSymbolButton::colorFromMimeData( const QMimeData *mimeData, QColor &resultColor, bool &hasAlpha )

0 comments on commit 62d6c8c

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