From b3e4bf103153ebc8155cefd460bd9d303eea511d Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Tue, 6 Feb 2024 14:46:55 +0100 Subject: [PATCH] Sketcher: DSH: add two shortcuts for DSH to use. Fix a small syntax error in polygon/rotate. --- .../Gui/DrawSketchControllableHandler.h | 8 ++++++ src/Mod/Sketcher/Gui/DrawSketchController.h | 6 +++++ .../Gui/DrawSketchDefaultWidgetController.h | 24 ++++++++++++++++-- .../Sketcher/Gui/DrawSketchHandlerPolygon.h | 4 +-- .../Sketcher/Gui/DrawSketchHandlerRotate.h | 4 +-- .../Sketcher/Gui/DrawSketchHandlerTranslate.h | 25 ++++++++++++++++--- 6 files changed, 61 insertions(+), 10 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchControllableHandler.h b/src/Mod/Sketcher/Gui/DrawSketchControllableHandler.h index 7e6193d31a..2dd00ad373 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchControllableHandler.h +++ b/src/Mod/Sketcher/Gui/DrawSketchControllableHandler.h @@ -183,6 +183,14 @@ private: toolWidgetManager.secondKeyShortcut(); } + if (key == SoKeyboardEvent::R && !pressed && !this->isLastState()) { + toolWidgetManager.thirdKeyShortcut(); + } + + if (key == SoKeyboardEvent::F && !pressed && !this->isLastState()) { + toolWidgetManager.fourthKeyShortcut(); + } + if (key == SoKeyboardEvent::TAB && !pressed) { toolWidgetManager.tabShortcut(); } diff --git a/src/Mod/Sketcher/Gui/DrawSketchController.h b/src/Mod/Sketcher/Gui/DrawSketchController.h index 9381b3b92d..7e52186c41 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchController.h +++ b/src/Mod/Sketcher/Gui/DrawSketchController.h @@ -444,6 +444,12 @@ public: virtual void secondKeyShortcut() {} + virtual void thirdKeyShortcut() + {} + + virtual void fourthKeyShortcut() + {} + virtual void tabShortcut() { passFocusToNextOnViewParameter(); diff --git a/src/Mod/Sketcher/Gui/DrawSketchDefaultWidgetController.h b/src/Mod/Sketcher/Gui/DrawSketchDefaultWidgetController.h index 4df96a6b4c..30340e6507 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchDefaultWidgetController.h +++ b/src/Mod/Sketcher/Gui/DrawSketchDefaultWidgetController.h @@ -220,7 +220,7 @@ public: Q_UNUSED(onSketchPos) } - /** on first shortcut, it toggles the first checkbox if there is go. Must be specialised if + /** on first shortcut, it toggles the first checkbox if there is one. Must be specialised if * this is not intended */ void firstKeyShortcut() override { @@ -230,7 +230,7 @@ public: } } - /** on second shortcut, it toggles the second checkbox if there is go. Must be specialised if + /** on second shortcut, it toggles the second checkbox if there is one. Must be specialised if * this is not intended */ void secondKeyShortcut() override { @@ -240,6 +240,26 @@ public: } } + /** on third shortcut, it toggles the third checkbox if there is one. Must be specialised if + * this is not intended */ + void thirdKeyShortcut() override + { + if (nCheckbox >= 3) { + auto thirdchecked = toolWidget->getCheckboxChecked(WCheckbox::ThirdBox); + toolWidget->setCheckboxChecked(WCheckbox::ThirdBox, !thirdchecked); + } + } + + /** on fourth shortcut, it toggles the fourth checkbox if there is one. Must be specialised if + * this is not intended */ + void fourthKeyShortcut() override + { + if (nCheckbox >= 4) { + auto fourthchecked = toolWidget->getCheckboxChecked(WCheckbox::FourthBox); + toolWidget->setCheckboxChecked(WCheckbox::FourthBox, !fourthchecked); + } + } + //@} protected: diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerPolygon.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerPolygon.h index afac9a032b..d0fc81fb92 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerPolygon.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerPolygon.h @@ -286,7 +286,7 @@ template<> void DSHPolygonController::firstKeyShortcut() { auto value = toolWidget->getParameter(WParameter::First); - toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value + 1); + toolWidget->setParameterWithoutPassingFocus(WParameter::First, value + 1); } template<> @@ -294,7 +294,7 @@ void DSHPolygonController::secondKeyShortcut() { auto value = toolWidget->getParameter(WParameter::First); if (value > 3.0) { // NOLINT - toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value - 1); + toolWidget->setParameterWithoutPassingFocus(WParameter::First, value - 1); } } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerRotate.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerRotate.h index 1138d53096..1232f4e722 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerRotate.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerRotate.h @@ -456,7 +456,7 @@ template<> void DSHRotateController::firstKeyShortcut() { auto value = toolWidget->getParameter(WParameter::First); - toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value + 1); + toolWidget->setParameterWithoutPassingFocus(WParameter::First, value + 1); } template<> @@ -464,7 +464,7 @@ void DSHRotateController::secondKeyShortcut() { auto value = toolWidget->getParameter(WParameter::First); if (value > 0.0) { - toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value - 1); + toolWidget->setParameterWithoutPassingFocus(WParameter::First, value - 1); } } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerTranslate.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerTranslate.h index 6351fc9f5d..afa230c1ac 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerTranslate.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerTranslate.h @@ -448,7 +448,7 @@ template<> void DSHTranslateController::firstKeyShortcut() { auto value = toolWidget->getParameter(WParameter::First); - toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value + 1); + toolWidget->setParameterWithoutPassingFocus(WParameter::First, value + 1); } template<> @@ -456,7 +456,23 @@ void DSHTranslateController::secondKeyShortcut() { auto value = toolWidget->getParameter(WParameter::First); if (value > 0.0) { - toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value - 1); + toolWidget->setParameterWithoutPassingFocus(WParameter::First, value - 1); + } +} + +template<> +void DSHTranslateController::thirdKeyShortcut() +{ + auto value = toolWidget->getParameter(WParameter::Second); + toolWidget->setParameterWithoutPassingFocus(WParameter::Second, value + 1); +} + +template<> +void DSHTranslateController::fourthKeyShortcut() +{ + auto value = toolWidget->getParameter(WParameter::Second); + if (value > 1.0) { + toolWidget->setParameterWithoutPassingFocus(WParameter::Second, value - 1); } } @@ -495,8 +511,9 @@ void DSHTranslateController::configureToolWidget() toolWidget->setParameterLabel( WParameter::First, QApplication::translate("TaskSketcherTool_p3_translate", "Copies (+'U'/-'J')")); - toolWidget->setParameterLabel(WParameter::Second, - QApplication::translate("TaskSketcherTool_p5_translate", "Rows")); + toolWidget->setParameterLabel( + WParameter::Second, + QApplication::translate("TaskSketcherTool_p5_translate", "Rows (+'R'/-'F')")); toolWidget->setParameter(OnViewParameter::First, 0.0); toolWidget->setParameter(OnViewParameter::Second, 1.0);