Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Snap statusbar #3228

Merged
merged 7 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Mod/Draft/DraftGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1893,8 +1893,7 @@ def getXPM(self,iconname,size=16):
return str(a)

def togglesnap(self):
if hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper.toggle()
FreeCADGui.doCommand('FreeCADGui.runCommand("Draft_Snap_Lock")')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the best way of doing it? I am not entirely sure what class calls which. To run this command, it must be defined first, but DraftGui is one of the early modules loaded. So, it's like calling something that will be defined later.

If this is the case, then DraftGui must be loaded after the gui_snaps commands are loaded.

As I can see, Draft_Snap_Lock basically calls Gui.Snapper.masterbutton.toggle(), so it looks very similar to Gui.Snapper.toggle().

Anyway, it's just a comment. As I said, DraftGui is quite complex because it is both the DraftToolBar, the snap toolbar, and the task panel interface for most commands.

Copy link
Contributor Author

@carlopav carlopav Apr 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I can see, Draft_Snap_Lock basically calls Gui.Snapper.masterbutton.toggle(), so it looks very similar to Gui.Snapper.toggle().

This was the previous behaviour. With proposed changes Draft_Snap_Lock just calls Gui.Snapper.toggle_snap('Lock') and sync the interface (toolbar and statusbar).
I wish the default behaviour to always interact with Snapper through Snaps commands to set the active_snaps. (EDIT and with current PR also Draft_Snap_Lock became exactly as other snaps seen from outside the Snapper)
Do you think we should modify something in the order the modules are loaded?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just not sure how it works really. I've never investigated deeply this behavior. But ideally we should try split DraftGui in discrete parts as much as possible.


def togglenearsnap(self):
if hasattr(FreeCADGui,"Snapper"):
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Draft/InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def QT_TRANSLATE_NOOP(context, text):
if hasattr(FreeCADGui, "draftToolBar"):
if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
FreeCADGui.addPreferencePage(":/ui/preferences-draft.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
FreeCADGui.addPreferencePage(":/ui/preferences-draftinterface.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
FreeCADGui.addPreferencePage(":/ui/preferences-draftsnap.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
FreeCADGui.addPreferencePage(":/ui/preferences-draftvisual.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
FreeCADGui.addPreferencePage(":/ui/preferences-drafttexts.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
Expand All @@ -140,7 +141,7 @@ def Deactivated(self):
if hasattr(FreeCADGui, "Snapper"):
FreeCADGui.Snapper.hide()
import draftutils.init_draft_statusbar as dsb
dsb.hide_draft_statusbar()
dsb.hide_draft_statusbar()
FreeCAD.Console.PrintLog("Draft workbench deactivated.\n")

def ContextMenu(self, recipient):
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Draft/Resources/Draft.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<file>translations/Draft_zh-CN.qm</file>
<file>translations/Draft_zh-TW.qm</file>
<file>ui/preferences-draft.ui</file>
<file>ui/preferences-draftinterface.ui</file>
<file>ui/preferences-draftsnap.ui</file>
<file>ui/preferences-drafttexts.ui</file>
<file>ui/preferences-draftvisual.ui</file>
Expand Down