From 8c95e691d6dff074364dc4994090abbbb2c24037 Mon Sep 17 00:00:00 2001 From: Axel Spoerl <axel.spoerl@qt.io> Date: Thu, 27 Jul 2023 12:01:34 +0200 Subject: [PATCH 111/147] 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> (cherry picked from commit a2ec43b8ebcbf8462928800a7db4f6af7e482b18) --- src/widgets/dialogs/qcolordialog.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index cb325be85c..30445fa069 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -804,6 +804,10 @@ QColorLuminancePicker::~QColorLuminancePicker() void QColorLuminancePicker::mouseMoveEvent(QMouseEvent *m) { + if (m->buttons() == Qt::NoButton) { + m->ignore(); + return; + } setVal(y2val(m->y())); } void QColorLuminancePicker::mousePressEvent(QMouseEvent *m) @@ -938,6 +942,10 @@ void QColorPicker::setCol(int h, int s) void QColorPicker::mouseMoveEvent(QMouseEvent *m) { QPoint p = m->pos() - contentsRect().topLeft(); + if (m->buttons() == Qt::NoButton) { + m->ignore(); + return; + } setCol(p); emit newCol(hue, sat); } -- 2.40.1