26645: Undo/redo buttons' hovered state and of disabled controls #27296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: #26645
Partially resolves #26232: tooltips on disabled controls will appear when those are hovered.
Supersedes PR#26671 which became a mess after rebasing.
Key points:
&& root.enabledto the condition for the "HOVERED" and "PRESSED" states.enabled: root.enabledfrom the MouseArea-s since it has side effects. See below.&& root.enabledin the variousonContainsMouseChangedhandlers.Disabling the MouseArea together with a button has side effects when the button is disabled upon its own click. This is the case with the Undo and Redo buttons when there are no more actions to undo/redo. In particular
containsMouseandpressedof the MouseArea remaintruewhen the button and its MouseArea get disabled. This means that the "HOVERED" state will remain active. This could be worked around by adding&& mouseArea.enabledto the condition of the "HOVERED" state.However, there is more:
containsMousewill continue to betrueeven if the mouse then leaves the now disabled button. Let's say this is the Undo button and it becomes disabled on click since there are no more actions to undo. The user moves the mouse away from it and over the Redo button.containsMouseof the Undo button's MouseArea continues to betruesince both the button and the MouseArea are now disabled and the MouseArea does not react to any mouse events any more. If the Redo button is now clicked, this will re-enable the Undo button and its MouseArea. The Undo button's "HOVERED" state will fire even though the mouse is hovering the Redo button.The conclusion we (Casper and I) came to is we should not be disabling the MouseArea. Instead we should be checking root.Enabled where necessary. This also mkes tooltips on disabled controls appear again on hover: #26232.
The disabling of the MouseArea-s was done for #25697.
Commit 1 fixes the hover state specifically for the Undo/Redo buttons (this story).
Commit 2 takes care of the other controls.
I have tested what I could.
QA: #25697 will have to be retested.
TBH, I find it a bit clumsy having to check
root.enabledevery time but adding a new property to the MouseArea-s - something likeisHovered: containsMouse && parent.enabled- isn't good enough either because I am sure everyone is used to the traditional properties of the MouseArea...