Beginner Project RFC for using mouse hover on UI dialogs

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Beginner Project RFC for using mouse hover on UI dialogs

Post by Kunda1 »

Currently in Sketcher when one clicks on the "Create a new sketch' icon the 'Sketch orientation' dialog appears.
sketcher-orientation-dialog.png
sketcher-orientation-dialog.png (24.2 KiB) Viewed 1481 times
When a user toggles the radio buttons the cube icon/vector changes states. What I'd like to propose is that when the user hovers the mouse over the radio buttons that the same effect occur but without needing to select said radiobutton.

Essentially, I'd like to:
1) ascertain if the FC devs and community would welcome this feature?
2) request some guidance coding this

I'm a programming newb but I have lurked on several different FOSS projects, including Scribus and QGIS.

I've taken a look at the code and have learned that 'Sketch orientation' dialog .ui[1] and .cpp[2] are probably the places I need to implement the code. I've also taken a look at Qt5 Stylesheets[3] & Qt5 list of psuedo states[4]

[1] https://github.com/FreeCAD/FreeCAD/blob ... alog.ui#L4
[2] https://github.com/FreeCAD/FreeCAD/blob ... Dialog.cpp
[3] http://doc.qt.io/Qt-5/stylesheet-syntax.html
[4] http://doc.qt.io/Qt-5/stylesheet-refere ... udo-states

More research in FC forums:
"Problems Styling in FC" viewtopic.php?f=10&t=12417&start=10
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Beginner Project RFC for using mouse hover on UI dialogs

Post by pablogil »

I don't think the stylesheet can't do more than change values for the radio buttons themselves.
FYI, if you want to change its properties while hovering with the mouse you have to do it the following way:

Code: Select all

QRadioButton:hover {
    color: blue;
    background-color: red;
}
I'm also attaching a simple stylesheet (.qss) with this code so that you can try it out:
1) unzip the file
2) Place the .qss file in the path that fits your OS:
OSX = /Users/[YOUR_USER_NAME]/Library/Preferences/FreeCAD/Gui/Stylesheets/
WINDOWS = C:/[INSTALLATION_PATH]/FreeCAD/data/Gui/Stylesheets/
LINUX = /home/[YOUR_USER_NAME]/.FreeCAD/Gui/Stylesheets/
Attachments
QRadioButton_hover.zip
(253 Bytes) Downloaded 64 times
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Beginner Project RFC for using mouse hover on UI dialogs

Post by Kunda1 »

Pyside question:
How to simulate a mouse click by hovering over a button?
Clue: need to workaround the mouseMoveEvent or directly a QHoverEvent
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Beginner Project RFC for using mouse hover on UI dialogs

Post by wandererfan »

Kunda1 wrote: Tue Oct 01, 2019 5:21 pm Clue: need to workaround the mouseMoveEvent or directly a QHoverEvent
Hover event has a type. On mouse over it is a "HoverEnter" type and as you move away, it is "HoverLeave" type. So, onHoverEnter() emulates the mouse click logic and onHoverLeave() puts it back the way it was.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Beginner Project RFC for using mouse hover on UI dialogs

Post by Kunda1 »

wandererfan wrote: Tue Oct 01, 2019 5:50 pm Hover event has a type. On mouse over it is a "HoverEnter" type and as you move away, it is "HoverLeave" type. So, onHoverEnter() emulates the mouse click logic and onHoverLeave() puts it back the way it was.
The idea is that the button remains depressed when we onHoverLeave() said the button (which also means that the graphic doesn't change). If we hover over another button (not the same one) it will trigger the previous button to deselect and the new button to be depressed and the associated orientation svg to change as well.

The next things is the activating the dialog by clicking on the depressed button (instead of clicking OK) which will accept the state. Obviously there is a need to think about the other components of the dialog like offset field and the reversed checkbox.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply