From 239173bcf2a76af1950e5825e2f511a71a95673c Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Sun, 18 May 2025 15:10:14 +0200 Subject: [PATCH] Draft: Add example tool hints --- src/Mod/Draft/draftguitools/gui_arcs.py | 30 +++++++++++++++++++ .../Draft/draftguitools/gui_base_original.py | 13 ++++++++ 2 files changed, 43 insertions(+) diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index 038038bb1d..dbc6e92411 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -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() diff --git a/src/Mod/Draft/draftguitools/gui_base_original.py b/src/Mod/Draft/draftguitools/gui_base_original.py index b9f10c8eb2..27789bc5a3 100644 --- a/src/Mod/Draft/draftguitools/gui_base_original.py +++ b/src/Mod/Draft/draftguitools/gui_base_original.py @@ -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.