Core: Switch widget from 'ExpressionLineEdit' to 'ExpressionTextEdit'
+ minor dialog layout adjustments
This commit is contained in:
@@ -79,22 +79,22 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path,
|
||||
initializeVarSets();
|
||||
|
||||
// Connect signal(s)
|
||||
connect(ui->expression, &ExpressionLineEdit::textChanged,
|
||||
connect(ui->expression, &ExpressionTextEdit::textChanged,
|
||||
this, &DlgExpressionInput::textChanged);
|
||||
connect(discardBtn, &QPushButton::clicked,
|
||||
this, &DlgExpressionInput::setDiscarded);
|
||||
|
||||
if (expression) {
|
||||
ui->expression->setText(QString::fromStdString(expression->toString()));
|
||||
ui->expression->setPlainText(QString::fromStdString(expression->toString()));
|
||||
}
|
||||
else {
|
||||
QVariant text = parent->property("text");
|
||||
if (text.canConvert<QString>()) {
|
||||
ui->expression->setText(text.toString());
|
||||
ui->expression->setPlainText(text.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// Set document object on line edit to create auto completer
|
||||
// Set document object on text edit to create auto completer
|
||||
DocumentObject * docObj = path.getDocumentObject();
|
||||
ui->expression->setDocumentObject(docObj);
|
||||
|
||||
@@ -114,7 +114,7 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path,
|
||||
setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
}
|
||||
else {
|
||||
ui->expression->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
ui->expression->setMinimumHeight(50);
|
||||
ui->horizontalSpacer_3->changeSize(0, 2);
|
||||
ui->verticalLayout->setContentsMargins(9, 9, 9, 9);
|
||||
this->adjustSize();
|
||||
@@ -360,8 +360,10 @@ void DlgExpressionInput::checkExpression(const QString& text)
|
||||
|
||||
static const bool NoCheckExpr = false;
|
||||
|
||||
void DlgExpressionInput::textChanged(const QString &text)
|
||||
void DlgExpressionInput::textChanged()
|
||||
{
|
||||
const QString& text = ui->expression->toPlainText();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
okBtn->setDisabled(true);
|
||||
discardBtn->setDefault(true);
|
||||
@@ -371,17 +373,6 @@ void DlgExpressionInput::textChanged(const QString &text)
|
||||
okBtn->setDefault(true);
|
||||
|
||||
try {
|
||||
//resize the input field according to text size
|
||||
QFontMetrics fm(ui->expression->font());
|
||||
int width = QtTools::horizontalAdvance(fm, text) + 15;
|
||||
if (width < minimumWidth)
|
||||
ui->expression->setMinimumWidth(minimumWidth);
|
||||
else
|
||||
ui->expression->setMinimumWidth(width);
|
||||
|
||||
if(this->width() < ui->expression->minimumWidth())
|
||||
setMinimumWidth(ui->expression->minimumWidth());
|
||||
|
||||
checkExpression(text);
|
||||
if (varSetsVisible) {
|
||||
// If varsets are visible, check whether the varset info also
|
||||
@@ -917,7 +908,7 @@ void DlgExpressionInput::updateVarSetInfo(bool checkExpr)
|
||||
if (checkExpr) {
|
||||
// We have to check the text of the expression as well
|
||||
try {
|
||||
checkExpression(ui->expression->text());
|
||||
checkExpression(ui->expression->toPlainText());
|
||||
}
|
||||
catch (Base::Exception&) {
|
||||
okBtn->setEnabled(false);
|
||||
|
||||
Reference in New Issue
Block a user