From dea79014ef88f5365b25f2b511446ce0d38f8704 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Sat, 28 Jun 2025 19:59:26 +0200 Subject: [PATCH] Sketcher: Use generic tool hints table for DrawSketchHandlerArcOfParabola --- .../Gui/DrawSketchHandlerArcOfParabola.h | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerArcOfParabola.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerArcOfParabola.h index e84b1e100e..0dfe4c4170 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerArcOfParabola.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerArcOfParabola.h @@ -336,48 +336,35 @@ protected: private: std::list getToolHints() const override { - return lookupParabolaHints(Mode); + using enum Gui::InputHint::UserInput; + + return Gui::lookupHints( + Mode, + { + {.state = STATUS_SEEK_First, + .hints = + { + {QObject::tr("%1 pick focus point"), {MouseLeft}}, + }}, + {.state = STATUS_SEEK_Second, + .hints = + { + {QObject::tr("%1 pick axis point"), {MouseLeft}}, + }}, + {.state = STATUS_SEEK_Third, + .hints = + { + {QObject::tr("%1 pick starting point"), {MouseLeft}}, + }}, + {.state = STATUS_SEEK_Fourth, + .hints = + { + {QObject::tr("%1 pick end point"), {MouseLeft}}, + }}, + }); } - -private: - struct HintEntry - { - int mode; - std::list hints; - }; - - using HintTable = std::vector; - - static HintTable getParabolaHintTable(); - static std::list lookupParabolaHints(int mode); }; -DrawSketchHandlerArcOfParabola::HintTable DrawSketchHandlerArcOfParabola::getParabolaHintTable() -{ - return {// Structure: {mode, {hints...}} - {STATUS_SEEK_First, - {{QObject::tr("%1 pick focus point"), {Gui::InputHint::UserInput::MouseLeft}}}}, - {STATUS_SEEK_Second, - {{QObject::tr("%1 pick axis point"), {Gui::InputHint::UserInput::MouseLeft}}}}, - {STATUS_SEEK_Third, - {{QObject::tr("%1 pick starting point"), {Gui::InputHint::UserInput::MouseLeft}}}}, - {STATUS_SEEK_Fourth, - {{QObject::tr("%1 pick end point"), {Gui::InputHint::UserInput::MouseLeft}}}}}; -} - -std::list DrawSketchHandlerArcOfParabola::lookupParabolaHints(int mode) -{ - const auto parabolaHintTable = getParabolaHintTable(); - - auto it = std::find_if(parabolaHintTable.begin(), - parabolaHintTable.end(), - [mode](const HintEntry& entry) { - return entry.mode == mode; - }); - - return (it != parabolaHintTable.end()) ? it->hints : std::list {}; -} - } // namespace SketcherGui #endif // SKETCHERGUI_DrawSketchHandlerArcOfParabola_H