summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qcolordialog.cpp
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2023-07-27 12:01:34 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2023-07-28 06:47:06 +0000
commita2ec43b8ebcbf8462928800a7db4f6af7e482b18 (patch)
treecbd83d877aa116b452a62170a2909e5c51fea77d /src/widgets/dialogs/qcolordialog.cpp
parentd48f3b1ab48c05d12d95477bb5e6fbf28091cb5f (diff)
QColorDialog: Ignore mouse move events when no mouse button is pressed
mouseMoveEvent overrides in QColorLuminancePicker and QColorPicker have triggered value changes unconditionally. This happened under the assumption that the widget attribute WA_Hover is not set (which is the default behavior). In that case, mouseMoveEvents are only delivered if a button is pressed. If WA_Hover is set - e.g. by applying a style sheet - mouseMoveEvents get delivered also when no button is pressed. This leads to faulty behavior: The color and the luminance change, whenever the mouse is moved into the respective widget. Color/luminance are changed to the value representing the edge on which the mouse has left the area. This patch changes both mouseMoveEvent overrides. They return early to avoid hovering changing the colors of the luminance/color picker, but ignore() the event in case anything behind the picker needs hover. Since this is a purely graphical effect, an autotest was not added. Fixes: QTBUG-115516 Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I000d113a1c81c46799cbb5197bf9acb3849e7d3b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/widgets/dialogs/qcolordialog.cpp')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 69358b7484..8b3fb28c7d 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -780,6 +780,10 @@ QColorLuminancePicker::~QColorLuminancePicker()
void QColorLuminancePicker::mouseMoveEvent(QMouseEvent *m)
{
+ if (m->buttons() == Qt::NoButton) {
+ m->ignore();
+ return;
+ }
setVal(y2val(m->position().toPoint().y()));
}
void QColorLuminancePicker::mousePressEvent(QMouseEvent *m)
@@ -914,6 +918,10 @@ void QColorPicker::setCol(int h, int s)
void QColorPicker::mouseMoveEvent(QMouseEvent *m)
{
QPoint p = m->position().toPoint() - contentsRect().topLeft();
+ if (m->buttons() == Qt::NoButton) {
+ m->ignore();
+ return;
+ }
setCol(p);
emit newCol(hue, sat);
}