mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[color picker] Clicking the previous color should reset to that color
This commit is contained in:
parent
fb7415c3ff
commit
fd92dd95aa
@ -421,6 +421,9 @@ class QgsColorPreviewWidget : QgsColorWidget
|
||||
//reimplemented to allow dragging colors
|
||||
void mousePressEvent( QMouseEvent* e );
|
||||
|
||||
//reimplemented to click colors
|
||||
void mouseReleaseEvent( QMouseEvent* e );
|
||||
|
||||
//reimplemented to allow dragging colors
|
||||
void mouseMoveEvent( QMouseEvent *e );
|
||||
|
||||
|
@ -1591,6 +1591,30 @@ void QgsColorPreviewWidget::mousePressEvent( QMouseEvent *e )
|
||||
QWidget::mousePressEvent( e );
|
||||
}
|
||||
|
||||
void QgsColorPreviewWidget::mouseReleaseEvent( QMouseEvent *e )
|
||||
{
|
||||
if (( e->pos() - mDragStartPosition ).manhattanLength() >= QApplication::startDragDistance() )
|
||||
{
|
||||
//mouse moved, so a drag. nothing to do here
|
||||
QWidget::mouseReleaseEvent( e );
|
||||
return;
|
||||
}
|
||||
|
||||
//work out which color was clicked
|
||||
QColor clickedColor = mCurrentColor;
|
||||
if ( mColor2.isValid() )
|
||||
{
|
||||
//two color sections, check if dragged color was the second color
|
||||
int verticalSplit = qRound( height() / 2.0 );
|
||||
if ( mDragStartPosition.y() >= verticalSplit )
|
||||
{
|
||||
clickedColor = mColor2;
|
||||
}
|
||||
}
|
||||
emit colorChanged( clickedColor );
|
||||
|
||||
}
|
||||
|
||||
void QgsColorPreviewWidget::mouseMoveEvent( QMouseEvent *e )
|
||||
{
|
||||
//handle dragging colors from button
|
||||
|
@ -632,6 +632,9 @@ class GUI_EXPORT QgsColorPreviewWidget : public QgsColorWidget
|
||||
//reimplemented to allow dragging colors
|
||||
void mousePressEvent( QMouseEvent* e );
|
||||
|
||||
//reimplemented to click colors
|
||||
void mouseReleaseEvent( QMouseEvent* e );
|
||||
|
||||
//reimplemented to allow dragging colors
|
||||
void mouseMoveEvent( QMouseEvent *e );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user