From 20e41aea0bea093a0e43256c7fe108105725f017 Mon Sep 17 00:00:00 2001 From: Paddle Date: Wed, 18 Oct 2023 16:05:36 +0200 Subject: [PATCH] EditableDatumLabel : Change the 'invisibleToMouse' to 'visibleToMouse' to avoid double negation. Also add parameter to startEdit to set this setting. Defaulting to false. So that we don't have to set manually again and again in tool settings. --- src/Gui/EditableDatumLabel.cpp | 10 +++++++--- src/Gui/EditableDatumLabel.h | 4 ++-- src/Gui/TaskView/TaskImage.cpp | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Gui/EditableDatumLabel.cpp b/src/Gui/EditableDatumLabel.cpp index 7f33e71e0c..ac40d13698 100644 --- a/src/Gui/EditableDatumLabel.cpp +++ b/src/Gui/EditableDatumLabel.cpp @@ -130,7 +130,7 @@ void EditableDatumLabel::deactivate() } } -void EditableDatumLabel::startEdit(double val, QObject* eventFilteringObj) +void EditableDatumLabel::startEdit(double val, QObject* eventFilteringObj, bool visibleToMouse) { QWidget* mdi = viewer->parentWidget(); @@ -147,6 +147,10 @@ void EditableDatumLabel::startEdit(double val, QObject* eventFilteringObj) spinBox->installEventFilter(eventFilteringObj); } + if (!visibleToMouse) { + setSpinboxVisibleToMouse(visibleToMouse); + } + spinBox->show(); setSpinboxValue(val); //Note: adjustSize apparently uses the Min/Max values to set the size. So if we don't set them to INT_MAX, the spinbox are much too big. @@ -340,9 +344,9 @@ void EditableDatumLabel::setLabelAutoDistanceReverse(bool val) autoDistanceReverse = val; } -void EditableDatumLabel::setSpinboxInvisibleToMouse(bool val) +void EditableDatumLabel::setSpinboxVisibleToMouse(bool val) { - spinBox->setAttribute(Qt::WA_TransparentForMouseEvents, val); + spinBox->setAttribute(Qt::WA_TransparentForMouseEvents, !val); } #include "moc_EditableDatumLabel.cpp" diff --git a/src/Gui/EditableDatumLabel.h b/src/Gui/EditableDatumLabel.h index c6fad407d2..d5cc18ed04 100644 --- a/src/Gui/EditableDatumLabel.h +++ b/src/Gui/EditableDatumLabel.h @@ -51,7 +51,7 @@ public: void activate(); void deactivate(); - void startEdit(double val, QObject* eventFilteringObj = nullptr); + void startEdit(double val, QObject* eventFilteringObj = nullptr, bool visibleToMouse = false); void stopEdit(); bool isInEdit(); double getValue(); @@ -68,7 +68,7 @@ public: void setLabelRange(double val); void setLabelRecommendedDistance(); void setLabelAutoDistanceReverse(bool val); - void setSpinboxInvisibleToMouse(bool val); + void setSpinboxVisibleToMouse(bool val); // NOLINTBEGIN SoDatumLabel* label; diff --git a/src/Gui/TaskView/TaskImage.cpp b/src/Gui/TaskView/TaskImage.cpp index d1ed313356..672832c3e0 100644 --- a/src/Gui/TaskView/TaskImage.cpp +++ b/src/Gui/TaskView/TaskImage.cpp @@ -529,7 +529,7 @@ void InteractiveScale::collectPoint(const SbVec3f& pos3d) midPoint = (points[0] + points[1]) / 2; - measureLabel->startEdit(getDistance(points[1]), this); + measureLabel->startEdit(getDistance(points[1]), this, true); Q_EMIT enableApplyBtn(); }