Skip to content

Commit

Permalink
[ux] Show the color values in tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jun 21, 2016
1 parent be1244d commit 82e2add
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/gui/qgscolorbuttonv2.cpp
Expand Up @@ -161,6 +161,24 @@ void QgsColorButtonV2::setToNull()
setColor( QColor() );
}

bool QgsColorButtonV2::event( QEvent *e )
{
if ( e->type() == QEvent::ToolTip )
{
QString name = this->color().name();
int hue = this->color().hue();
int value = this->color().value();
int saturation = this->color().saturation();
QString info = QString( "HEX: %1 \n"
"RGB: %2 \n"
"HSV: %3,%4,%4" ).arg( name )
.arg( QgsSymbolLayerV2Utils::encodeColor( this->color() ) )
.arg( hue ).arg( value ).arg( saturation );
setToolTip( info );
}
return QToolButton::event( e );
}

void QgsColorButtonV2::setToNoColor()
{
if ( mAllowAlpha )
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgscolorbuttonv2.h
Expand Up @@ -318,6 +318,7 @@ class GUI_EXPORT QgsColorButtonV2 : public QToolButton

protected:

bool event( QEvent *e ) override;
void changeEvent( QEvent* e ) override;
void showEvent( QShowEvent* e ) override;
void resizeEvent( QResizeEvent *event ) override;
Expand Down

0 comments on commit 82e2add

Please sign in to comment.