Gui: fix Quantity spinbox margin without an icon (#20695)

* Gui: fix Quantity spinbox margin without an icon

* refactor: apply review suggestions

* refactor: reorder operations as suggested

---------

Co-authored-by: alfre <alfre@localhost.localdomain>
This commit is contained in:
Alfredo Monclus
2025-04-09 15:28:54 -03:00
committed by GitHub
parent 0cbb1c0fc3
commit 2727550e90
2 changed files with 18 additions and 8 deletions

View File

@@ -50,18 +50,17 @@ ExpressionSpinBox::ExpressionSpinBox(QAbstractSpinBox* sb)
: spinbox(sb)
{
lineedit = spinbox->findChild<QLineEdit*>();
// Set Margins
// https://forum.freecad.org/viewtopic.php?f=8&t=50615
// vertical margin, otherwise `,` is clipped to a `.` on some OSX versions
int margin = getMargin();
lineedit->setTextMargins(margin, margin, margin, margin);
lineedit->setAlignment(Qt::AlignVCenter);
makeLabel(lineedit);
QObject::connect(iconLabel, &ExpressionLabel::clicked, [this]() {
this->openFormulaDialog();
});
// Set Margins
// vertical to avoid this: https://forum.freecad.org/viewtopic.php?f=8&t=50615
// horizontal to avoid going under the icon
lineedit->setAlignment(Qt::AlignVCenter);
int iconWidth = iconLabel->sizeHint().width();
int margin = getMargin();
lineedit->setTextMargins(margin, margin, margin + iconWidth, margin);
}
ExpressionSpinBox::~ExpressionSpinBox() = default;