[ Fixed ] Draft GUI: Shortcuts do not display in sub-menus?

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft GUI: Shortcuts do not display in sub-menus?

Post by Roy_043 »

Found this on the Qt website:
https://forum.qt.io/topic/15107/solved-action-shortcut-not-triggering-unless-action-is-placed-in-a-toolbar wrote:A shortcut should be triggered if it has a valid parent widget and this parent widget receives events (id est it is not hidden).
The proposed fix works. That is, the shortcuts work, but they are still not displayed in the menu.
To test change the Activated function in InitGui.py to:

Code: Select all

    def Activated(self):
        """When entering the workbench."""
        if hasattr(FreeCADGui, "draftToolBar"):
            FreeCADGui.draftToolBar.Activated()
        if hasattr(FreeCADGui, "Snapper"):
            FreeCADGui.Snapper.show()
            import draftutils.init_draft_statusbar as dsb
            dsb.show_draft_statusbar()
        FreeCAD.Console.PrintLog("Draft workbench activated.\n")
 
        # Workaround for shortcuts not working for tools in sub menus.
        from PySide import QtGui
        mw = FreeCADGui.getMainWindow()
        for a in mw.findChildren(QtGui.QAction):
            if a.shortcut().toString():
                mw.addAction(a)
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft GUI: Shortcuts do not display in sub-menus?

Post by Roy_043 »

OK, forget about that workaround, we should just create normal submenus here. Then the shortcuts are displayed and work fine. Problem is that the Draft menus are also used by the Arch and BIM workbenches. And the BIM WB has to work with V0.19 and V0.20. I'll try to do a PR.
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft GUI: Shortcuts do not display in sub-menus?

Post by Roy_043 »

First PR:
https://github.com/FreeCAD/FreeCAD/pull/5072

To fix this will be a step-by-step process. So several PR's will follow.

I have also improved the order of the utilities menu and changed the order of the utilities toolbar to match. Hope that's ok. :mrgreen:
Attachments
draft-utilities-menu-and-toolbar-new.png
draft-utilities-menu-and-toolbar-new.png (21.72 KiB) Viewed 1460 times
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Fixed ] Draft GUI: Shortcuts do not display in sub-menus?

Post by Roy_043 »

Merged.
Post Reply