Draft: improved IsActive behavior (#14103)

Related issue: #14061.
This commit is contained in:
Roy-043
2024-05-18 11:38:38 +02:00
committed by GitHub
parent e50ef22e7b
commit df49763d3f
12 changed files with 104 additions and 140 deletions

View File

@@ -36,6 +36,7 @@ import FreeCADGui as Gui
import WorkingPlane
from draftguitools import gui_base
from draftutils import gui_utils
from draftutils.translate import translate
@@ -54,7 +55,6 @@ class ToggleGrid(gui_base.GuiCommandSimplest):
def GetResources(self):
"""Set icon, menu and tooltip."""
return {"Pixmap": "Draft_Grid",
"Accel": "G, R",
"MenuText": QT_TRANSLATE_NOOP("Draft_ToggleGrid", "Toggle grid"),
@@ -62,6 +62,10 @@ class ToggleGrid(gui_base.GuiCommandSimplest):
"Toggles the Draft grid on and off."),
"CmdType": "ForEdit"}
def IsActive(self):
"""Return True when this command should be available."""
return bool(gui_utils.get_3d_view())
def Activated(self):
"""Execute when the command is called."""
super().Activated()