Draft: Add example tool hints

This commit is contained in:
Kacper Donat
2025-05-18 15:10:14 +02:00
parent 9baeb6e9e6
commit 239173bcf2
2 changed files with 43 additions and 0 deletions

View File

@@ -291,6 +291,36 @@ class Arc(gui_base_original.Creator):
self.step = 4
self.drawArc()
self.updateHints()
def getHints(self):
hint_global = Gui.InputHint(translate("draft", "%1 toggle global"), Gui.UserInput.KeyG)
hint_continue = Gui.InputHint(translate("draft", "%1 toggle continue"), Gui.UserInput.KeyN)
if self.step == 0:
return [
Gui.InputHint(translate("draft", "%1 pick center"), Gui.UserInput.MouseLeft),
hint_global,
hint_continue,
]
elif self.step == 1:
return [
Gui.InputHint(translate("draft", "%1 pick radius"), Gui.UserInput.MouseLeft),
hint_continue,
]
elif self.step == 2:
return [
Gui.InputHint(translate("draft", "%1 pick staring angle"), Gui.UserInput.MouseLeft),
hint_continue,
]
elif self.step == 3:
return [
Gui.InputHint(translate("draft", "%1 pick aperture"), Gui.UserInput.MouseLeft),
hint_continue,
]
else:
return []
def drawArc(self):
"""Actually draw the arc object."""
rot, sup, pts, fil = self.getStrings()

View File

@@ -136,6 +136,17 @@ class DraftTool:
_toolmsg("{}".format(16*"-"))
_toolmsg("GuiCommand: {}".format(self.featureName))
# update hints after the tool is fully initialized
QtCore.QTimer.singleShot(0, self.updateHints)
def updateHints(self):
Gui.HintManager.show(*self.getHints())
def getHints(self):
return [
Gui.InputHint("%1 constrain", Gui.UserInput.KeyShift)
]
def end_callbacks(self, call):
try:
self.view.removeEventCallback("SoEvent", call)
@@ -184,6 +195,8 @@ class DraftTool:
todo.ToDo.delayCommit(self.commitList)
self.commitList = []
Gui.HintManager.hide()
def commit(self, name, func):
"""Store actions in the commit list to be run later.