Question about some of the FreeCAD QMenus

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
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Question about some of the FreeCAD QMenus

Post by triplus »

During the CommandPanel module development i have developed a rather customizable Preferences dialog, for people being able to rather easily set (groups of) commands. This will get reused in other modules, such as the PieMenu. From a beginning, there was a plan i will add customizable support to the navigation cube menu. @nyholku looks like it is not around anymore, but at that time he did add a QMenu, with an object name set, that i can search for and use as a front-end. Today i explored this a bit further and did notice, that a QMenu gets created for each navigation cube:

https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L1391

Therefore instead of finding the menu once, different set of detections needs to be used, during the whole FreeCAD session. It's not all that problematic, but i was wondering if one of the C++ gurus would be prepared to change this behavior in a way, one (global) QMenu would be created and reused by all navigation cubes?

P.S. In addition i took a quick look, as i always wondered, but its rather unclear to me ATM. How many QMenus are there used in FreeCAD for 3D Viewport and Tree view context menu purposes? Is there a single menu, more of them, created once, more times ...
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Question about some of the FreeCAD QMenus

Post by triplus »

An update. For navigation cube purposes, dealing with more menus, it looks like that should be a non issue. Detection can be done in a rather elegant and straightforward way, with a document observer. As for context menus, i took an additional look and i guess now i understand on how they get populated, Workbench.cpp and View or Tree being a recipient for menu items. Not yet 100% sure, where and how the actual QMenus are created, maybe Tree.cpp and ContextMenu.cpp. Will have to take a closer look next time. They are not direct main window children.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Question about some of the FreeCAD QMenus

Post by triplus »

For now i will likely completely shift the focus to the initial goal, navigation cube menu support. Small teaser:
WIP.png
WIP.png (23.66 KiB) Viewed 324 times
Will officially announce the module in a couple of days.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Question about some of the FreeCAD QMenus

Post by triplus »

Post Reply