triplus / ShortCuts

Shortcuts overlay for FreeCAD
10 stars 4 forks source link

seems broken on macos #4

Open evantill opened 5 years ago

evantill commented 5 years ago

Hi,

As explained in the README.md :

Shortcuts manager preferences are located under Tools -> Accessories -> Shortcuts. To invoke shortcuts overlay feature press the W key on the keyboard.

But I have no Accessories in Toolsmenu and W key does not work either (My keyboard is an AZERTY).

evantill commented 5 years ago

First time I was in French language. I have switch to English but same problem.

evantill commented 5 years ago

Maybe the menu is not found here:

https://github.com/triplus/ShortCuts/blob/19ca51e4ae29620afbfa3858cd98091b580be70c/ShortCuts_Gui.py#L450

evantill commented 5 years ago

On stackoverflow I have found this question about findChild of QMenu does is not working properly

evantill commented 5 years ago

opening Freecad from the terminal I have ths error message :

Traceback (most recent call last):
  File "/Users/username/Library/Preferences/FreeCAD/Mod/ShortCuts/ShortCuts_Gui.py", line 471, in onStart
    onWorkbench()
  File "/Users/username/Library/Preferences/FreeCAD/Mod/ShortCuts/ShortCuts_Gui.py", line 171, in onWorkbench
    workbench = Gui.activeWorkbench().__class__.__name__
AssertionError: No active workbench
evantill commented 5 years ago

https://github.com/triplus/ShortCuts/blob/19ca51e4ae29620afbfa3858cd98091b580be70c/ShortCuts_Gui.py#L467-L472

Moving accessoriesMenu() before onWorkbench() seems to work but I have no ideas if there are side effects.

What could I do next to help ?

triplus commented 5 years ago

Thanks for reporting the issue and providing verbose information. Could you please test two things:

1.) Install CommandPanel module (available in Addon manager). Start FreeCAD from the terminal to see if CommandPanel module will have the same issue, or it will start successfully. This info will likely help once i will restructure ShortCuts module (merge the manager and overlay functionality).

2.) If you add an additional line to ShortCuts_Gui.py like this:

def onStart():
    """Start shortcuts."""
    start = False
    try:
        mw.workbenchActivated
        Gui.activeWorkbench().__class__.__name__
        start = True
    except:
        pass

    if start:
        timer.stop()
        timer.deleteLater()
        onWorkbench()
        accessoriesMenu()
        mw.workbenchActivated.connect(onWorkbench)

Does the ShortCuts module start successfully after? Note that to activate the Overlay currently Shift+Q and not W is set by default. I forgot to change the instruction, when i made that change.

evantill commented 5 years ago

1.) Same problem with CommandPanel:

Traceback (most recent call last):
  File "/Users/username/Library/Preferences/FreeCAD/Mod/CommandPanel/CommandPanelGui.py", line 201, in onStart
    onWorkbench()
  File "/Users/username/Library/Preferences/FreeCAD/Mod/CommandPanel/CommandPanelGui.py", line 144, in onWorkbench
    workbench = Gui.activeWorkbench().__class__.__name__
AssertionError: No active workbench
evantill commented 5 years ago

2.) the error is now on the new line

Traceback (most recent call last):
  File "/Users/ericvantillard/Library/Preferences/FreeCAD/Mod/ShortCuts/ShortCuts_Gui.py", line 464, in onStart
    Gui.activeWorkbench().__class__.__name__
AssertionError: No active workbench
evantill commented 5 years ago

compare with :

https://github.com/FreeCAD/FreeCAD/blob/4079c9603fe988799fdf2bb871b13c64313467f9/src/Mod/Tux/PersistentToolbarsGui.py#L243

adding if mw.property("eventLoop"):seems to solve the problem.

triplus commented 5 years ago

Thanks for the feedback. OK therefore i will assume all modules can have such problems on macOS. As on Qt4 builds this likely isn't an issue, therefore i won't drop support for FreeCAD 0.16 just yet. That property was added for FreeCAD 0.17+.

Will go over all modules and add the appropriate changes (will do that today or tomorrow).

triplus commented 5 years ago

OK i have checked all the modules and adapted the ones benefiting from such improved start reliability. Could you please install all the modules (Addon manager) to see if all start successfully now on your side, or if some errors are still detected when starting FreeCAD:

Thanks.

evantill commented 5 years ago
triplus commented 5 years ago

Thanks for the feedback. Will have more time to take a more in-depth look tomorrow.

P.S. Note that i accidentally edited your last reply. Wanted to test if such list is rearrangeable and i guess it is! Didn't really expected it would be.

triplus commented 5 years ago

Note that i just updated the Autoload module and hopefully the issue is resolved.

evantill commented 5 years ago

I have tried Autoload:

evantill commented 5 years ago

Now when testing Toolbarstyle alone, it is visible in the accesories menu.

evantill commented 5 years ago

Glass seems to work:

freecad
triplus commented 5 years ago

Yes that is how currently Glass behaves on macOS. TabBar still produces display issues?

OK therefore i guess we are down to Autoload module and missing Accessories menu. As no errors are detected i can only guess a bit. Could you please remove all other modules, mentioned in this discussion, as they could interfere with the results. After do two tests:

In the first one comment out the loadModulesFirst() like:

# loadModulesFirst()
timer = QtCore.QTimer()
timer.timeout.connect(onPreStart)
timer.start(500)

In the second test move accessoriesMenu() like this:

def onStart():
    """Start autoload."""
    start = False
    try:
        mw.workbenchActivated
        start = True
    except AttributeError:
        pass
    if start:
        timer.stop()
        timer.deleteLater()
        loadWorkbenches()
        accessoriesMenu()
        loadModulesLast()

Thanks.

evantill commented 5 years ago

TabBar seems ok

freecad
evantill commented 5 years ago

Sorry, no errors and no menu after executing the two tests for Autoload

triplus commented 5 years ago

OK, thanks for the feedback. Will look for clues again tomorrow.

Without using any modifications and after FreeCAD starts. If you switch to a different workbench first, still no Accessories menu? If you delete InitGui.py file from the Autoload module folder, start FreeCAD, and enter this in FreeCAD Python console:

import Autoload_Gui

I am guessing now Accessories menu is available?

evantill commented 5 years ago

in both case no menus and no errors

triplus commented 5 years ago

How about if you copy/paste the code in FreeCAD Python console:

https://raw.githubusercontent.com/triplus/Autoload/master/Autoload_Gui.py

evantill commented 5 years ago

In this case, no errors but no menu. But it's like the menu exits but is not displayed (findChildren return the menu)

>>> for act in toolsMenu.actions():
...     print(act.text())
... 
E&dit parameters ...

Save picture...
Scene inspector...
Dependency graph...
Project utility...

Measure distance

View turntable...
&Units calculator...

Cu&stomize...
&Addon manager
Accessories
evantill commented 5 years ago
toolsMenu.setVisible(True)

display the menu with the Accesories subMenu

tools_et_item-0
triplus commented 5 years ago

First thanks for the feedback and in general for staying around and testing things out. I updated all the modules with a potential fix and hopefully you will be able to confirm that.

evantill commented 5 years ago

I will check maybe tomorrow

evantill commented 5 years ago

I will try one by one and update the following list:

Autoload have issues. The menu does not appear. And if the menu already exist (enabled by an other module) it will disapear if Autoload is installed.

Notes:

  1. Need a restart of freecad after installing the module to activate it(and a restart after removing the module to uninstall it).
  2. After changing the workbench, the Accessories menu disappear.
triplus commented 5 years ago

OK therefore there is still some issue involved. If we focus on Autoload module only. Other modules not installed. Therefore on FreeCAD start there is Tools menu available but no Accessories menu item listed in it. If you enter this in Python console:

from PySide import QtGui
mw = Gui.getMainWindow()
a = mw.findChild(QtGui.QAction, "AccessoriesMenu")
a.setVisible(True)

Now Accessories menu should be made available in Tools menu? At least until you switch workbench. Or that doesn't happen and there is no error and no Accessories menu listed in Tools menu?

evantill commented 5 years ago

Second answer. No error and no accessories menu.

Maybe somthing related to native menu ?

tools_et_item-0

Note: the menu in upper left corner is displayed after calling

mw.menuBar().findChild(QtGui.QMenu,"&Tools").setVisible(True)
evantill commented 5 years ago

This test will work if Autoload is not installed. If Autoload is installed it will not work anymore.

from PySide import QtGui
mw = Gui.getMainWindow()

mb = mw.menuBar()

toolsMenu = mb.findChild(QtGui.QMenu, "&Tools")

m = QtGui.QMenu("Essai")
action = m.menuAction()
action.setObjectName("EssaiMenu")
toolsMenu.addAction(action)

I tried this after reading qt-change-application-qmenubar-contents-on-mac-os-x

triplus commented 5 years ago

Thanks for the verbose feedback. I need to test again everything discussed here and i think i have a general idea on what is likely going on. Yes on macOS menu bar can behave a bit differently. Will need to think about possible solution a bit more. Will likely do that over the weekend.

Could you do one more test. If you look in the Mod folder. Likely located:

/Users/user_name/Library/Preferences/FreeCAD/Mod

Make sure you delete the Autoload folder manually. After install it again (manually or by using Addon manager) and rename the folder to zAutoload. Any changes after FreeCAD gets started?

P.S. Thanks up front and i likely won't work on this again before weekend.

evantill commented 5 years ago

Any changes after FreeCAD gets started?

No, no errors and no menu.

triplus commented 5 years ago

Note that i am still working on this. This is what is causing the issue on macOS:

https://forum.freecadweb.org/viewtopic.php?f=10&t=30340&p=288292#p287972

Will wait if any obvious solution will be provided, if not i will move Accessories menu to menubar, top level, on macOS. In FreeCAD 0.19 development cycle a different solution is planned anyway, and should enable Accessories menu to be located in Tools menu on all platforms again.

triplus commented 5 years ago

I moved the Accessories menu to the menu bar (Autoload module). Could you please remove all other modules and just install Autoload module. To test things like if the Accessories menu is made available on FreeCAD start, if it's still there on workbench change. If everything will be working fine i will port other modules after confirmation.

triplus commented 5 years ago

Note that i moved Accessories menu from tools menu to the menu bar for all modules today. Hopefully this will resolve all discussed issues on macOS.

evantill commented 5 years ago

I will make feedback when I will work again with freecad (maybe end of week). Thank you for your work.