Skip to content
Permalink
Browse files
Change button color when picking around
So that we have a consistent behavior with the
Sample Color action.
  • Loading branch information
elpaso committed Feb 16, 2018
1 parent 948452b commit f334961
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
@@ -231,17 +231,7 @@ void QgsColorButton::mouseMoveEvent( QMouseEvent *e )
{
if ( mPickingColor )
{
//currently in color picker mode
if ( e->buttons() & Qt::LeftButton )
{
//if left button depressed, sample color under cursor and temporarily update button color
//to give feedback to user
QScreen *screen = findScreenAt( e->globalPos() );
if ( screen )
{
setButtonBackground( sampleColor( e->globalPos() ) );
}
}
setButtonBackground( sampleColor( e->globalPos() ) );
e->accept();
return;
}
@@ -294,7 +284,8 @@ void QgsColorButton::stopPicking( QPoint eventPos, bool samplingColor )

if ( !samplingColor )
{
//not sampling color, nothing more to do
//not sampling color, restore old color
setButtonBackground( mCurrentColor );
return;
}

@@ -686,6 +677,8 @@ void QgsColorButton::pasteColor()
void QgsColorButton::activatePicker()
{
//activate picker color
// Store current color
mCurrentColor = mColor;
QApplication::setOverrideCursor( QgsApplication::getThemeCursor( QgsApplication::Cursor::Sampler ) );
grabMouse();
grabKeyboard();
@@ -411,6 +411,10 @@ class GUI_EXPORT QgsColorButton : public QToolButton
QgsColorSchemeRegistry *mColorSchemeRegistry = nullptr;

QColor mDefaultColor;

//! Store current color when start picking
QColor mCurrentColor;

QString mContext;
bool mAllowOpacity = false;
bool mColorSet = false;

0 comments on commit f334961

Please sign in to comment.