Skip to content

Commit

Permalink
limit fx dialog tabs by parent dialog (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
DSCaskey authored Aug 26, 2024
1 parent bd7bcc3 commit 061088e
Show file tree
Hide file tree
Showing 29 changed files with 70 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/app/seamly2d/core/vformulapropertyeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void VFormulaPropertyEditor::SetFormula(const VFormula& formula)
void VFormulaPropertyEditor::onToolButtonClicked()
{
EditFormulaDialog* dialog = new EditFormulaDialog(formula.getData(), formula.getToolId(),
qApp->getMainWindow());
ToolDialog, qApp->getMainWindow());
dialog->setCheckZero(formula.getCheckZero());
dialog->setPostfix(formula.getPostfix());
dialog->SetFormula(formula.GetFormula(FormulaType::FromUser));
Expand Down
2 changes: 1 addition & 1 deletion src/app/seamly2d/dialogs/dialogvariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ void DialogVariables::Fx()
const QTableWidgetItem *name = ui->variables_TableWidget->item(row, 0);
QSharedPointer<CustomVariable> variable = data->getVariable<CustomVariable>(name->text());

EditFormulaDialog *dialog = new EditFormulaDialog(variable->GetData(), NULL_ID, this);
EditFormulaDialog *dialog = new EditFormulaDialog(variable->GetData(), NULL_ID, VariableDialog, this);
dialog->setWindowTitle(tr("Edit variable"));
dialog->SetFormula(qApp->translateVariables()->TryFormulaFromUser(ui->formula_PlainTextEdit->toPlainText().replace("\n", " "),
qApp->Settings()->getOsSeparator()));
Expand Down
2 changes: 1 addition & 1 deletion src/app/seamlyme/tmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ void TMainWindow::Fx()
return;
}

EditFormulaDialog *dialog = new EditFormulaDialog(meash->GetData(), NULL_ID, this);
EditFormulaDialog *dialog = new EditFormulaDialog(meash->GetData(), NULL_ID, MeasurementDialog, this);
dialog->setWindowTitle(tr("Edit measurement"));
dialog->SetFormula(qApp->translateVariables()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText().replace("\n", " "),
true));
Expand Down
8 changes: 8 additions & 0 deletions src/libs/vmisc/def.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ class QGraphicsItem;

#define HANDLE_SIZE 12

// Bit flags to identify parent dialog type for the Edit Formula dialog and which tabs to hide
enum DialogSource : quint16
{
ToolDialog = 511, // 0000 0001 1111 1111
VariableDialog = 259, // 0000 0001 0000 0011
MeasurementDialog = 257 // 0000 0001 0000 0001
};

enum class Position : char
{
TopLeft = 0,
Expand Down
10 changes: 8 additions & 2 deletions src/libs/vtools/dialogs/support/edit_formula_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ template <class T> class QSharedPointer;
enum {ColumnName = 0, ColumnFullName};

//---------------------------------------------------------------------------------------------------------------------
EditFormulaDialog::EditFormulaDialog(const VContainer *data, const quint32 &toolId, QWidget *parent)
EditFormulaDialog::EditFormulaDialog(const VContainer *data, const quint32 &toolId, const quint16 &source,
QWidget *parent)
: DialogTool(data, toolId, parent)
, ui(new Ui::EditFormulaDialog)
, m_formula(QString())
Expand All @@ -117,6 +118,7 @@ EditFormulaDialog::EditFormulaDialog(const VContainer *data, const quint32 &tool
, m_checkLessThanZero(false)
, m_postfix(QString())
, m_restoreCursor(false)
, m_source(source)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
Expand Down Expand Up @@ -564,10 +566,14 @@ void EditFormulaDialog::initializeVariables()
connect(ui->menuTab_ListWidget, &QListWidget::currentRowChanged, this, ClearFilterFormulaInputs);
connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &EditFormulaDialog::measurements);

// Set the selection highlight rect larger than just the item text

for (int i = 0; i < ui->menuTab_ListWidget->count(); ++i)
{
// Set the selection highlight rect larger than just the item text
ui->menuTab_ListWidget->item(i)->setSizeHint(QSize(ui->menuTab_ListWidget->width(), 50));

// Set the visibility of tab item depending on source i.e., the parent dialog.
ui->menuTab_ListWidget->item(i)->setHidden(!(m_source & (1 << i)));
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/libs/vtools/dialogs/support/edit_formula_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ class EditFormulaDialog : public DialogTool
{
Q_OBJECT
public:
EditFormulaDialog(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
EditFormulaDialog(const VContainer *data, const quint32 &toolId,
const quint16 &source, QWidget *parent = nullptr);
virtual ~EditFormulaDialog() Q_DECL_OVERRIDE;

QString GetFormula() const;
Expand Down Expand Up @@ -135,6 +136,7 @@ private slots:
bool m_checkLessThanZero;
QString m_postfix;
bool m_restoreCursor;
quint16 m_source;

void initializeVariables();

Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialogalongline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void DialogAlongLine::PointChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogAlongLine::FXLength()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
6 changes: 3 additions & 3 deletions src/libs/vtools/dialogs/tools/dialogarc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ void DialogArc::F2Changed()
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::FXRadius()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(getRadius());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand All @@ -439,7 +439,7 @@ void DialogArc::FXRadius()
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::FXF1()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit first angle"));
dialog->SetFormula(getF1());
dialog->setPostfix(degreeSymbol);
Expand All @@ -453,7 +453,7 @@ void DialogArc::FXF1()
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::FXF2()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit second angle"));
dialog->SetFormula(getF2());
dialog->setPostfix(degreeSymbol);
Expand Down
6 changes: 3 additions & 3 deletions src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void DialogArcWithLength::LengthChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::FXRadius()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(GetRadius());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand All @@ -387,7 +387,7 @@ void DialogArcWithLength::FXRadius()
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::FXF1()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit the first angle"));
dialog->SetFormula(GetF1());
dialog->setPostfix(degreeSymbol);
Expand All @@ -401,7 +401,7 @@ void DialogArcWithLength::FXF1()
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::FXLength()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit the arc length"));
dialog->SetFormula(GetLength());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialogbisector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void DialogBisector::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogBisector::FXLength()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void DialogCurveIntersectAxis::DeployAngleTextEdit()
//---------------------------------------------------------------------------------------------------------------------
void DialogCurveIntersectAxis::FXAngle()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialogcutarc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void DialogCutArc::FormulaTextChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::FXLength()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialogcutspline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void DialogCutSpline::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::FXLength()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void DialogCutSplinePath::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::FXLength()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
10 changes: 5 additions & 5 deletions src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void DialogEllipticalArc::CheckAngles()
//---------------------------------------------------------------------------------------------------------------------
void DialogEllipticalArc::FXRadius1()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit radius1"));
dialog->SetFormula(GetRadius1());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand All @@ -541,7 +541,7 @@ void DialogEllipticalArc::FXRadius1()
//---------------------------------------------------------------------------------------------------------------------
void DialogEllipticalArc::FXRadius2()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit radius2"));
dialog->SetFormula(GetRadius2());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand All @@ -555,7 +555,7 @@ void DialogEllipticalArc::FXRadius2()
//---------------------------------------------------------------------------------------------------------------------
void DialogEllipticalArc::FXF1()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit first angle"));
dialog->SetFormula(GetF1());
dialog->setPostfix(degreeSymbol);
Expand All @@ -569,7 +569,7 @@ void DialogEllipticalArc::FXF1()
//---------------------------------------------------------------------------------------------------------------------
void DialogEllipticalArc::FXF2()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit second angle"));
dialog->SetFormula(GetF2());
dialog->setPostfix(degreeSymbol);
Expand All @@ -583,7 +583,7 @@ void DialogEllipticalArc::FXF2()
//---------------------------------------------------------------------------------------------------------------------
void DialogEllipticalArc::FXRotationAngle()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit rotation angle"));
dialog->SetFormula(GetRotationAngle());
dialog->setPostfix(degreeSymbol);
Expand Down
4 changes: 2 additions & 2 deletions src/libs/vtools/dialogs/tools/dialogendline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void DialogEndLine::DeployAngleTextEdit()
//---------------------------------------------------------------------------------------------------------------------
void DialogEndLine::FXAngle()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol);
Expand All @@ -203,7 +203,7 @@ void DialogEndLine::FXAngle()
//---------------------------------------------------------------------------------------------------------------------
void DialogEndLine::FXLength()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void DialogLineIntersectAxis::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::FXAngle()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol);
Expand Down
6 changes: 3 additions & 3 deletions src/libs/vtools/dialogs/tools/dialogmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void DialogMove::rotationChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::editAngleFormula()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol);
Expand All @@ -415,7 +415,7 @@ void DialogMove::editAngleFormula()
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::editLengthFormula()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetLength());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand All @@ -429,7 +429,7 @@ void DialogMove::editLengthFormula()
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::editRotationFormula()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit rotation"));
dialog->SetFormula(getRotation());
dialog->setPostfix(degreeSymbol);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialognormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void DialogNormal::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogNormal::FXLength()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void DialogPointOfContact::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::FXRadius()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(getRadius());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialogrotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void DialogRotation::angleChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::editAngleFormula()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void DialogShoulderPoint::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogShoulderPoint::FXLength()
{
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, ToolDialog, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
Expand Down
Loading

0 comments on commit 061088e

Please sign in to comment.