File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -421,6 +421,9 @@ class QgsColorPreviewWidget : QgsColorWidget
421
421
//reimplemented to allow dragging colors
422
422
void mousePressEvent( QMouseEvent* e );
423
423
424
+ //reimplemented to click colors
425
+ void mouseReleaseEvent( QMouseEvent* e );
426
+
424
427
//reimplemented to allow dragging colors
425
428
void mouseMoveEvent( QMouseEvent *e );
426
429
Original file line number Diff line number Diff line change @@ -1591,6 +1591,30 @@ void QgsColorPreviewWidget::mousePressEvent( QMouseEvent *e )
1591
1591
QWidget::mousePressEvent ( e );
1592
1592
}
1593
1593
1594
+ void QgsColorPreviewWidget::mouseReleaseEvent ( QMouseEvent *e )
1595
+ {
1596
+ if (( e->pos () - mDragStartPosition ).manhattanLength () >= QApplication::startDragDistance () )
1597
+ {
1598
+ // mouse moved, so a drag. nothing to do here
1599
+ QWidget::mouseReleaseEvent ( e );
1600
+ return ;
1601
+ }
1602
+
1603
+ // work out which color was clicked
1604
+ QColor clickedColor = mCurrentColor ;
1605
+ if ( mColor2 .isValid () )
1606
+ {
1607
+ // two color sections, check if dragged color was the second color
1608
+ int verticalSplit = qRound ( height () / 2.0 );
1609
+ if ( mDragStartPosition .y () >= verticalSplit )
1610
+ {
1611
+ clickedColor = mColor2 ;
1612
+ }
1613
+ }
1614
+ emit colorChanged ( clickedColor );
1615
+
1616
+ }
1617
+
1594
1618
void QgsColorPreviewWidget::mouseMoveEvent ( QMouseEvent *e )
1595
1619
{
1596
1620
// handle dragging colors from button
Original file line number Diff line number Diff line change @@ -632,6 +632,9 @@ class GUI_EXPORT QgsColorPreviewWidget : public QgsColorWidget
632
632
// reimplemented to allow dragging colors
633
633
void mousePressEvent ( QMouseEvent* e );
634
634
635
+ // reimplemented to click colors
636
+ void mouseReleaseEvent ( QMouseEvent* e );
637
+
635
638
// reimplemented to allow dragging colors
636
639
void mouseMoveEvent ( QMouseEvent *e );
637
640
You can’t perform that action at this time.
0 commit comments