Navigation Menu

Skip to content

Commit

Permalink
Also show a preview tooltip for symbol buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 2, 2018
1 parent 8f78beb commit 62d6c8c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/gui/qgssymbolbutton.cpp
Expand Up @@ -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 )
Expand Down

0 comments on commit 62d6c8c

Please sign in to comment.