Sketcher: Use generic tool hints table for DrawSketchHandlerScale

This commit is contained in:
Kacper Donat
2025-06-28 19:59:30 +02:00
parent 276a44c1e3
commit 05eb702f87

View File

@@ -135,7 +135,22 @@ public:
std::list<Gui::InputHint> getToolHints() const override
{
return lookupScaleHints(state());
using enum Gui::InputHint::UserInput;
return Gui::lookupHints<SelectMode>(
state(),
{
{.state = SelectMode::SeekFirst,
.hints =
{
{QObject::tr("%1 pick reference point"), {MouseLeft}},
}},
{.state = SelectMode::SeekSecond,
.hints =
{
{QObject::tr("%1 set scale factor"), {MouseLeft}},
}},
});
}
private:
@@ -235,18 +250,6 @@ private:
bool allowOriginConstraint; // Conserve constraints with origin
double refLength, length, scaleFactor;
struct HintEntry
{
SelectMode state;
std::list<Gui::InputHint> hints;
};
using HintTable = std::vector<HintEntry>;
static HintTable getScaleHintTable();
static std::list<Gui::InputHint> lookupScaleHints(SelectMode state);
void deleteOriginalGeos()
{
std::stringstream stream;
@@ -487,30 +490,6 @@ private:
}
};
DrawSketchHandlerScale::HintTable DrawSketchHandlerScale::getScaleHintTable()
{
using enum Gui::InputHint::UserInput;
return {
{.state = SelectMode::SeekFirst,
.hints = {{QObject::tr("%1 pick reference point", "Sketcher Scale: hint"), {MouseLeft}}}},
{.state = SelectMode::SeekSecond,
.hints = {{QObject::tr("%1 set reference length", "Sketcher Scale: hint"), {MouseLeft}}}},
{.state = SelectMode::SeekThird,
.hints = {{QObject::tr("%1 set scale factor", "Sketcher Scale: hint"), {MouseLeft}}}}};
}
std::list<Gui::InputHint> DrawSketchHandlerScale::lookupScaleHints(SelectMode state)
{
const auto scaleHintTable = getScaleHintTable();
auto it = std::ranges::find_if(scaleHintTable, [state](const HintEntry& entry) {
return entry.state == state;
});
return (it != scaleHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
}
template<>
auto DSHScaleControllerBase::getState(int labelindex) const
{