diff --git a/qad/widgets/evalspinbox.cpp b/qad/widgets/evalspinbox.cpp
index a0a297e..06dfb8b 100644
--- a/qad/widgets/evalspinbox.cpp
+++ b/qad/widgets/evalspinbox.cpp
@@ -4,6 +4,7 @@
#include
#include
#include
+#include
#include
#include
#include "qad_types.h"
@@ -67,10 +68,15 @@ void EvalSpinBox::resizeIcons() {
QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &so, lineEdit());
int m0, m1, m2, m3;
lineEdit()->getTextMargins(&m0, &m1, &m2, &m3);
- label->setGeometry(m0 + r.x() + 2, m1 + r.y() + (r.height() - fontMetrics().height() + 1) / 2, lineEdit()->width() - 2*tm - (is * 1.2) * ((status->isVisible() ? 1 : 0) + (cw->isVisible() ? 1 : 0)), lineEdit()->height() - 2*tm);
+ //label->setGeometry(m0 + r.x() + 2, m1 + r.y() + (r.height() - fontMetrics().height() + 1) / 2, lineEdit()->width() - 2*tm - (is * 1.2) * ((status->isVisible() ? 1 : 0) + (cw->isVisible() ? 1 : 0)), lineEdit()->height() - 2*tm);
+ int lwh = label->sizeHint().width();
+ label->setGeometry(lineEdit()->width() - m0 - lwh + r.x() - 2,
+ m1 + r.y() + (r.height() - fontMetrics().height() + 1) / 2,
+ lwh,// - 2*tm - (is * 1.2) * ((status->isVisible() ? 1 : 0) + (cw->isVisible() ? 1 : 0)),
+ lineEdit()->height() - 2*tm);
status->setGeometry(lineEdit()->width() - (is + tm) * (cw->isVisible() ? 2 : 1), tm, is, is);
cw->setGeometry(lineEdit()->width() - (is + tm) * 1, tm, is, is);
- lineEdit()->setTextMargins(0, 0, (is * 1.2) * ((status->isVisible() ? 1 : 0) + (cw->isVisible() ? 1 : 0)), 0);
+ lineEdit()->setTextMargins(m0, m1, (is * 1.2) * ((status->isVisible() ? 1 : 0) + (cw->isVisible() ? 1 : 0)), m3);
}
@@ -158,19 +164,24 @@ void EvalSpinBox::setExpression_() {
// qDebug() << eval.expression();
}
if (!label->isHidden()) {
+// if (eval.expression() != QString::number(value(), 'G', 10) && eval.expression() != QString::number(value(), 'G', 11) && eval.isCorrect())
+// label->setText("" + eval.expression() + " -> " + QString::number(value(), 'G', 10) + "
");
+// else
+// label->setText(eval.expression());
if (eval.expression() != QString::number(value(), 'G', 10) && eval.expression() != QString::number(value(), 'G', 11) && eval.isCorrect())
- label->setText("" + eval.expression() + " -> " + QString::number(value(), 'G', 10) + "
");
- else label->setText(eval.expression());
+ label->setText("-> " + QString::number(value(), 'G', 10) + "
");
+ else
+ label->setText("");
lineEdit()->blockSignals(true);
if (!eval.isCorrect()) {
lineEdit()->setStyleSheet("color: darkred;");
status->show();
} else {
- lineEdit()->setStyleSheet("color: black;");
+ lineEdit()->setStyleSheet("");
status->hide();
}
// lineEdit()->setText(eval.expression() + " -> " + QString::number(value(), 'G', 10));
- lineEdit()->setText("");
+ //lineEdit()->setText("");
lineEdit()->blockSignals(false);
}
@@ -213,7 +224,7 @@ double EvalSpinBox::value() const {
if (eval.isCorrect()) {
return eval.lastResult().real();
}
- return 0;
+ return 0.;
}
@@ -244,8 +255,8 @@ void EvalSpinBox::focusInEvent(QFocusEvent * event) {
label->hide();
status->show();
lineEdit()->blockSignals(true);
- lineEdit()->setStyleSheet("color: black;");
- if (eval.expression() != "0") lineEdit()->setText(eval.expression());
+ lineEdit()->setStyleSheet("");
+ //if (eval.expression() != "0") lineEdit()->setText(eval.expression());
lineEdit()->blockSignals(false);
QAbstractSpinBox::focusInEvent(event);
resizeIcons();
@@ -255,15 +266,20 @@ void EvalSpinBox::focusInEvent(QFocusEvent * event) {
void EvalSpinBox::focusOutEvent(QFocusEvent * event) {
QAbstractSpinBox::focusOutEvent(event);
// qDebug() << eval.expression() << QString::number(value(), 'G', 10);
+// if (eval.expression() != QString::number(value(), 'G', 10) && eval.expression() != QString::number(value(), 'G', 11) && eval.isCorrect())
+// label->setText("" + eval.expression() + " -> " + QString::number(value(), 'G', 10) + "
");
+// else
+// label->setText(eval.expression());
if (eval.expression() != QString::number(value(), 'G', 10) && eval.expression() != QString::number(value(), 'G', 11) && eval.isCorrect())
- label->setText("" + eval.expression() + " -> " + QString::number(value(), 'G', 10) + "
");
- else label->setText(eval.expression());
+ label->setText("
-> " + QString::number(value(), 'G', 10) + "
");
+ else
+ label->setText("");
label->show();
lineEdit()->blockSignals(true);
if (!eval.isCorrect()) lineEdit()->setStyleSheet("color: darkred;");
else status->hide();
// lineEdit()->setText(eval.expression() + " -> " + QString::number(value(), 'G', 10));
- lineEdit()->clear();
+ //lineEdit()->clear();
lineEdit()->blockSignals(false);
resizeIcons();
}
diff --git a/qad/widgets/evalspinbox.h b/qad/widgets/evalspinbox.h
index d192cf1..43ad094 100644
--- a/qad/widgets/evalspinbox.h
+++ b/qad/widgets/evalspinbox.h
@@ -63,12 +63,12 @@ private:
void changeEvent(QEvent * e);
void statusPaintEvent();
void cwPaintEvent();
- void resizeIcons();
private slots:
void clearMouseRelease(QMouseEvent * e);
void textChanged_(const QString & text);
void setExpression_();
+ void resizeIcons();
signals:
void valueChanged(double val);