Gui: correct the size and position of the expression (fx) icon

This commit is contained in:
Alfredo Monclus
2025-03-15 13:29:53 -03:00
committed by Kacper Donat
parent 9a48e7fcfd
commit cea9a4002e
2 changed files with 4 additions and 10 deletions

View File

@@ -302,13 +302,11 @@ void ExpressionWidget::makeLabel(QLineEdit* le)
/* Icon for f(x) */
QFontMetrics fm(le->font());
int frameWidth = le->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth);
iconHeight = fm.height() - frameWidth;
iconHeight = fm.height();
iconLabel = new ExpressionLabel(le);
iconLabel->setCursor(Qt::ArrowCursor);
QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight));
iconLabel->setPixmap(pixmap);
iconLabel->setStyleSheet(QStringLiteral("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2));
iconLabel->hide();
iconLabel->setExpressionText(QString());
}

View File

@@ -67,9 +67,6 @@ void ExpressionSpinBox::bind(const App::ObjectIdentifier &_path)
void ExpressionSpinBox::showIcon()
{
int frameWidth = spinbox->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth);
lineedit->setStyleSheet(QStringLiteral("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1));
iconLabel->show();
}
@@ -164,10 +161,9 @@ void ExpressionSpinBox::onChange()
void ExpressionSpinBox::resizeWidget()
{
int frameWidth = spinbox->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth);
QSize sz = iconLabel->sizeHint();
iconLabel->move(lineedit->rect().right() - frameWidth - sz.width(), lineedit->rect().center().y() - sz.height() / 2);
int margin = lineedit->style()->pixelMetric(QStyle::PM_LineEditIconMargin, nullptr, lineedit);
int iconWidth = iconLabel->width() + margin;
iconLabel->move(lineedit->width() - iconWidth, (lineedit->height() - iconLabel->height()) / 2);
updateExpression();
}