From 121e4ed03cb3d06c64a9c207a3a32619af18c405 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 26 Oct 2022 00:43:33 +0200 Subject: [PATCH] Gui: don't make QuantitySpinBox dependent on implementation details of its base class --- src/Gui/QuantitySpinBox.cpp | 5 ++++- src/Gui/QuantitySpinBox.h | 1 + src/Gui/SpinBox.cpp | 5 +++++ src/Gui/SpinBox.h | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 3c6e472fce..3851e1b63b 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -337,8 +337,11 @@ QuantitySpinBox::~QuantitySpinBox() void QuantitySpinBox::bind(const App::ObjectIdentifier &_path) { - ExpressionBinding::bind(_path); + ExpressionSpinBox::bind(_path); +} +void QuantitySpinBox::showIcon() +{ iconLabel->show(); } diff --git a/src/Gui/QuantitySpinBox.h b/src/Gui/QuantitySpinBox.h index f2db970f2b..10bd9d4a33 100644 --- a/src/Gui/QuantitySpinBox.h +++ b/src/Gui/QuantitySpinBox.h @@ -145,6 +145,7 @@ protected Q_SLOTS: protected: void setExpression(std::shared_ptr expr) override; void openFormulaDialog() override; + void showIcon() override; StepEnabled stepEnabled() const override; void showEvent(QShowEvent * event) override; void hideEvent(QHideEvent * event) override; diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index 4c24c9db19..177f2d6151 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -65,6 +65,11 @@ void ExpressionSpinBox::bind(const App::ObjectIdentifier &_path) { ExpressionBinding::bind(_path); + showIcon(); +} + +void ExpressionSpinBox::showIcon() +{ int frameWidth = spinbox->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); lineedit->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); diff --git a/src/Gui/SpinBox.h b/src/Gui/SpinBox.h index a81d0a454c..cb1f2dcb1d 100644 --- a/src/Gui/SpinBox.h +++ b/src/Gui/SpinBox.h @@ -60,6 +60,7 @@ protected: void onChange() override; virtual void setNumberExpression(App::NumberExpression*) = 0; + virtual void showIcon(); void resizeWidget(); bool handleKeyEvent(const QString&);