Gui: Add support for hints in status bar

This commit is contained in:
Kacper Donat
2025-03-23 15:34:14 +01:00
parent 548af02619
commit aa47949f80
26 changed files with 1210 additions and 5 deletions

View File

@@ -160,7 +160,10 @@ private:
bool onModeChanged() override
{
DrawSketchHandler::resetPositionText();
DrawSketchHandler::updateHint();
toolWidgetManager.onHandlerModeChanged();
if (DSDefaultHandler::onModeChanged()) {
// If onModeChanged returns false, then the handler has been purged.
toolWidgetManager.afterHandlerModeChanged();

View File

@@ -96,6 +96,17 @@ public:
SNAP_MODE_45Degree
};
std::list<Gui::InputHint> getToolHints() const override
{
using UserInput = Gui::InputHint::UserInput;
return {
{QWidget::tr("%1 change mode"), {UserInput::KeyM}},
{QWidget::tr("%1 start drawing"), {UserInput::MouseLeft}},
{QWidget::tr("%1 stop drawing"), {UserInput::MouseRight}},
};
}
void registerPressedKey(bool pressed, int key) override
{
if (Mode == STATUS_SEEK_Second && key == SoKeyboardEvent::M && pressed

View File

@@ -74,6 +74,29 @@ public:
{}
~DrawSketchHandlerPolygon() override = default;
std::list<Gui::InputHint> getToolHints() const override
{
using UserInput = Gui::InputHint::UserInput;
switch (state()) {
case SelectMode::SeekFirst:
return {
{QWidget::tr("%1 pick polygon center"), {UserInput::MouseLeft}},
{QWidget::tr("%1/%2 increase / decrease number of sides"),
{UserInput::KeyU, UserInput::KeyJ}},
};
case SelectMode::SeekSecond:
return {
{QWidget::tr("%1 pick rotation and size"), {UserInput::MouseMove}},
{QWidget::tr("%1 confirm"), {UserInput::MouseLeft}},
{QWidget::tr("%1/%2 increase / decrease number of sides"),
{UserInput::KeyU, UserInput::KeyJ}},
};
default:
return {};
}
}
private:
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
{