From acea58f85f9e0fc898a1eea69f0c384537f01191 Mon Sep 17 00:00:00 2001 From: Pieter Hijma Date: Sun, 20 Jul 2025 09:51:05 +0200 Subject: [PATCH] Gui: Improve layout expression dialog for varsets According to #17075 --- src/Gui/Dialogs/DlgExpressionInput.cpp | 40 +++--- src/Gui/Dialogs/DlgExpressionInput.h | 2 +- src/Gui/Dialogs/DlgExpressionInput.ui | 170 ++++++++++--------------- 3 files changed, 89 insertions(+), 123 deletions(-) diff --git a/src/Gui/Dialogs/DlgExpressionInput.cpp b/src/Gui/Dialogs/DlgExpressionInput.cpp index 70f384ebd7..d907362751 100644 --- a/src/Gui/Dialogs/DlgExpressionInput.cpp +++ b/src/Gui/Dialogs/DlgExpressionInput.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "Dialogs/DlgExpressionInput.h" @@ -50,6 +51,9 @@ using namespace App; using namespace Gui::Dialog; +FC_LOG_LEVEL_INIT("DlgExpressionInput", true, true) + + bool DlgExpressionInput::varSetsVisible = false; DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path, @@ -204,9 +208,6 @@ bool DlgExpressionInput::typeOkForVarSet() void DlgExpressionInput::initializeVarSets() { - ui->labelInfoActive->setAlignment(Qt::AlignTop | Qt::AlignLeft); - ui->labelInfoActive->setWordWrap(true); - #if QT_VERSION >= QT_VERSION_CHECK(6,7,0) connect(ui->checkBoxVarSets, &QCheckBox::checkStateChanged, this, &DlgExpressionInput::onCheckVarSets); @@ -441,7 +442,6 @@ static bool isNamePropOk(const QString& nameProp, App::DocumentObject* obj, std::string name = nameProp.toStdString(); if (name.empty()) { - message << "Provide a name for the property."; return false; } @@ -688,21 +688,22 @@ static bool isNameGroupOk(const QString& nameGroup, return true; } -void DlgExpressionInput::reportVarSetInfo(const char* message) +void DlgExpressionInput::reportVarSetInfo(const std::string& message) { - ui->labelInfoActive->setText(QString::fromUtf8(message)); + if (!message.empty()) { + FC_ERR(message); + } } bool DlgExpressionInput::reportGroup(QString& nameGroup) { if (nameGroup.isEmpty()) { - reportVarSetInfo("Provide a group."); return true; } std::stringstream message; if (!isNameGroupOk(nameGroup, message)) { - reportVarSetInfo(message.str().c_str()); + reportVarSetInfo(message.str()); return true; } @@ -718,7 +719,7 @@ bool DlgExpressionInput::reportName(QTreeWidgetItem* item) App::DocumentObject* obj = doc->getObject(nameVarSet.toUtf8()); std::stringstream message; if (!isNamePropOk(nameProp, obj, message)) { - reportVarSetInfo(message.str().c_str()); + reportVarSetInfo(message.str()); return true; } @@ -743,17 +744,17 @@ void DlgExpressionInput::updateVarSetInfo(bool checkExpr) return; } - QString nameProp = ui->lineEditPropNew->text(); - QString labelVarSet = getValue(selected, ROLE_VARSET_LABEL); - QString nameDoc = getValue(selected, ROLE_DOC); - std::stringstream message; - message << "Adding property " << nameProp.toStdString() << std::endl - << "of type " << getType() << std::endl - << "to variable set " << labelVarSet.toStdString() << std::endl - << "in group " << nameGroup.toStdString() << std::endl - << "in document " << nameDoc.toStdString() << "."; + // QString nameProp = ui->lineEditPropNew->text(); + // QString labelVarSet = getValue(selected, ROLE_VARSET_LABEL); + // QString nameDoc = getValue(selected, ROLE_DOC); + // std::stringstream message; + // message << "Adding property " << nameProp.toStdString() << std::endl + // << "of type " << getType() << std::endl + // << "to variable set " << labelVarSet.toStdString() << std::endl + // << "in group " << nameGroup.toStdString() << std::endl + // << "in document " << nameDoc.toStdString() << "."; - reportVarSetInfo(message.str().c_str()); + // reportVarSetInfo(message.str().c_str()); if (checkExpr) { // We have to check the text of the expression as well try { @@ -767,7 +768,6 @@ void DlgExpressionInput::updateVarSetInfo(bool checkExpr) } else { okBtn->setEnabled(false); - reportVarSetInfo("Select a variable set."); } } diff --git a/src/Gui/Dialogs/DlgExpressionInput.h b/src/Gui/Dialogs/DlgExpressionInput.h index 7f6f20220a..2c714750e6 100644 --- a/src/Gui/Dialogs/DlgExpressionInput.h +++ b/src/Gui/Dialogs/DlgExpressionInput.h @@ -94,7 +94,7 @@ private: void checkExpression(const QString& text); void setupVarSets(); std::string getType(); - void reportVarSetInfo(const char* message); + void reportVarSetInfo(const std::string& message); bool reportName(QTreeWidgetItem* item); bool reportGroup(QString& nameGroup); void updateVarSetInfo(bool checkExpr = true); diff --git a/src/Gui/Dialogs/DlgExpressionInput.ui b/src/Gui/Dialogs/DlgExpressionInput.ui index 705ea44a45..04d261470f 100644 --- a/src/Gui/Dialogs/DlgExpressionInput.ui +++ b/src/Gui/Dialogs/DlgExpressionInput.ui @@ -7,7 +7,7 @@ 0 0 414 - 272 + 291 @@ -32,89 +32,6 @@ 0 - - - - Variable Sets - - - - - - - - - - - Group - - - - - - - - 0 - 0 - - - - - 0 - 70 - - - - - - - - - - - Variable set - - - - - - - - - - Info - - - - - - - New property - - - - - - - - 0 - 0 - - - - - - - - - - - - - Show variable sets - - - @@ -131,10 +48,10 @@ true - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -202,7 +119,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -235,7 +152,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -250,31 +167,81 @@ - - - Qt::Horizontal + + + + 0 + 0 + - - - 0 - 20 - + + QDialogButtonBox::StandardButton::Ok|QDialogButtonBox::StandardButton::Reset - + - - - QDialogButtonBox::Reset|QDialogButtonBox::Ok + + + Add to variable set... + + + + + + + + + + + + + 0 + 0 + + + + + + + + Name: + + + + + + + Variable Set: + + + + + + + Group: + + + + + + + + + + + + + + - Qt::Vertical + Qt::Orientation::Vertical @@ -296,7 +263,6 @@ expression buttonBox - checkBoxVarSets