From 11a71d46e342aebc9c88a0d8c61fbc851f7f3e61 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Thu, 23 Jul 2015 01:34:35 +0300 Subject: [PATCH] PartDesignGui: move signal connections in several parameter dialogs after ui initialization --- .../PartDesign/Gui/TaskChamferParameters.cpp | 19 +++--- .../PartDesign/Gui/TaskDraftParameters.cpp | 30 +++++----- .../PartDesign/Gui/TaskFilletParameters.cpp | 18 +++--- src/Mod/PartDesign/Gui/TaskPadParameters.cpp | 60 +++++++------------ .../PartDesign/Gui/TaskPocketParameters.cpp | 52 ++++++---------- .../Gui/TaskThicknessParameters.cpp | 31 +++++----- 6 files changed, 90 insertions(+), 120 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index e9c06b54b..604b95d9e 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -57,15 +57,6 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QW proxy = new QWidget(this); ui = new Ui_TaskChamferParameters(); ui->setupUi(proxy); - QMetaObject::connectSlotsByName(this); - - connect(ui->chamferDistance, SIGNAL(valueChanged(double)), - this, SLOT(onLengthChanged(double))); - connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefAdd(bool))); - connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefRemove(bool))); - this->groupLayout()->addWidget(proxy); PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); @@ -82,6 +73,16 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QW { ui->listWidgetReferences->addItem(QString::fromStdString(*i)); } + + QMetaObject::connectSlotsByName(this); + + connect(ui->chamferDistance, SIGNAL(valueChanged(double)), + this, SLOT(onLengthChanged(double))); + connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefAdd(bool))); + connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefRemove(bool))); + // Create context menu QAction* action = new QAction(tr("Remove"), this); ui->listWidgetReferences->addAction(action); diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index 0eb2c5981..cc8956fce 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -57,20 +57,6 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView,QWidge proxy = new QWidget(this); ui = new Ui_TaskDraftParameters(); ui->setupUi(proxy); - QMetaObject::connectSlotsByName(this); - - connect(ui->draftAngle, SIGNAL(valueChanged(double)), - this, SLOT(onAngleChanged(double))); - connect(ui->checkReverse, SIGNAL(toggled(bool)), - this, SLOT(onReversedChanged(bool))); - connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefAdd(bool))); - connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefRemove(bool))); - connect(ui->buttonPlane, SIGNAL(toggled(bool)), - this, SLOT(onButtonPlane(bool))); - connect(ui->buttonLine, SIGNAL(toggled(bool)), - this, SLOT(onButtonLine(bool))); this->groupLayout()->addWidget(proxy); @@ -91,6 +77,22 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView,QWidge { ui->listWidgetReferences->addItem(QString::fromStdString(*i)); } + + QMetaObject::connectSlotsByName(this); + + connect(ui->draftAngle, SIGNAL(valueChanged(double)), + this, SLOT(onAngleChanged(double))); + connect(ui->checkReverse, SIGNAL(toggled(bool)), + this, SLOT(onReversedChanged(bool))); + connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefAdd(bool))); + connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefRemove(bool))); + connect(ui->buttonPlane, SIGNAL(toggled(bool)), + this, SLOT(onButtonPlane(bool))); + connect(ui->buttonLine, SIGNAL(toggled(bool)), + this, SLOT(onButtonLine(bool))); + // Create context menu QAction* action = new QAction(tr("Remove"), this); ui->listWidgetReferences->addAction(action); diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 9a7d3beb9..748a0257c 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -56,14 +56,6 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWid proxy = new QWidget(this); ui = new Ui_TaskFilletParameters(); ui->setupUi(proxy); - QMetaObject::connectSlotsByName(this); - - connect(ui->filletRadius, SIGNAL(valueChanged(double)), - this, SLOT(onLengthChanged(double))); - connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefAdd(bool))); - connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefRemove(bool))); this->groupLayout()->addWidget(proxy); @@ -81,6 +73,16 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWid { ui->listWidgetReferences->addItem(QString::fromStdString(*i)); } + + QMetaObject::connectSlotsByName(this); + + connect(ui->filletRadius, SIGNAL(valueChanged(double)), + this, SLOT(onLengthChanged(double))); + connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefAdd(bool))); + connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefRemove(bool))); + // Create context menu QAction* action = new QAction(tr("Remove"), this); ui->listWidgetReferences->addAction(action); diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index d90d18d05..ec0c46049 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -61,39 +61,9 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg proxy = new QWidget(this); ui = new Ui_TaskPadParameters(); ui->setupUi(proxy); - QMetaObject::connectSlotsByName(this); - - connect(ui->lengthEdit, SIGNAL(valueChanged(double)), - this, SLOT(onLengthChanged(double))); - connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)), - this, SLOT(onMidplane(bool))); - connect(ui->checkBoxReversed, SIGNAL(toggled(bool)), - this, SLOT(onReversed(bool))); - connect(ui->lengthEdit2, SIGNAL(valueChanged(double)), - this, SLOT(onLength2Changed(double))); - connect(ui->spinOffset, SIGNAL(valueChanged(double)), - this, SLOT(onOffsetChanged(double))); - connect(ui->changeMode, SIGNAL(currentIndexChanged(int)), - this, SLOT(onModeChanged(int))); - connect(ui->buttonFace, SIGNAL(clicked()), - this, SLOT(onButtonFace())); - connect(ui->lineFaceName, SIGNAL(textEdited(QString)), - this, SLOT(onFaceName(QString))); - connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), - this, SLOT(onUpdateView(bool))); this->groupLayout()->addWidget(proxy); - // Temporarily prevent unnecessary feature recomputes - ui->lengthEdit->blockSignals(true); - ui->lengthEdit2->blockSignals(true); - ui->spinOffset->blockSignals(true); - ui->checkBoxMidplane->blockSignals(true); - ui->checkBoxReversed->blockSignals(true); - ui->buttonFace->blockSignals(true); - ui->lineFaceName->blockSignals(true); - ui->changeMode->blockSignals(true); - // set the history path ui->lengthEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadLength")); ui->lengthEdit2->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadLength2")); @@ -150,16 +120,26 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg ui->changeMode->insertItem(4, tr("Two dimensions")); ui->changeMode->setCurrentIndex(index); - // activate and de-activate dialog elements as appropriate - ui->lengthEdit->blockSignals(false); - ui->lengthEdit2->blockSignals(false); - ui->spinOffset->blockSignals(false); - ui->checkBoxMidplane->blockSignals(false); - ui->checkBoxReversed->blockSignals(false); - ui->buttonFace->blockSignals(false); - ui->lineFaceName->blockSignals(false); - ui->changeMode->blockSignals(false); - updateUI(index); + QMetaObject::connectSlotsByName(this); + + connect(ui->lengthEdit, SIGNAL(valueChanged(double)), + this, SLOT(onLengthChanged(double))); + connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)), + this, SLOT(onMidplane(bool))); + connect(ui->checkBoxReversed, SIGNAL(toggled(bool)), + this, SLOT(onReversed(bool))); + connect(ui->lengthEdit2, SIGNAL(valueChanged(double)), + this, SLOT(onLength2Changed(double))); + connect(ui->spinOffset, SIGNAL(valueChanged(double)), + this, SLOT(onOffsetChanged(double))); + connect(ui->changeMode, SIGNAL(currentIndexChanged(int)), + this, SLOT(onModeChanged(int))); + connect(ui->buttonFace, SIGNAL(clicked()), + this, SLOT(onButtonFace())); + connect(ui->lineFaceName, SIGNAL(textEdited(QString)), + this, SLOT(onFaceName(QString))); + connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), + this, SLOT(onUpdateView(bool))); // if it is a newly created object use the last value of the history if(newObj){ diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp index 0976ba8dc..4c9e7dfa2 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp @@ -61,36 +61,9 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge proxy = new QWidget(this); ui = new Ui_TaskPocketParameters(); ui->setupUi(proxy); - QMetaObject::connectSlotsByName(this); - - connect(ui->pocketLength, SIGNAL(valueChanged(double)), - this, SLOT(onLengthChanged(double))); - connect(ui->spinOffset, SIGNAL(valueChanged(double)), - this, SLOT(onOffsetChanged(double))); - connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)), - this, SLOT(onMidplaneChanged(bool))); - connect(ui->checkBoxReversed, SIGNAL(toggled(bool)), - this, SLOT(onReversedChanged(bool))); - connect(ui->changeMode, SIGNAL(currentIndexChanged(int)), - this, SLOT(onModeChanged(int))); - connect(ui->buttonFace, SIGNAL(pressed()), - this, SLOT(onButtonFace())); - connect(ui->lineFaceName, SIGNAL(textEdited(QString)), - this, SLOT(onFaceName(QString))); - connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), - this, SLOT(onUpdateView(bool))); this->groupLayout()->addWidget(proxy); - // Temporarily prevent unnecessary feature recomputes - ui->pocketLength->blockSignals(true); - ui->spinOffset->blockSignals(true); - ui->checkBoxMidplane->blockSignals(true); - ui->checkBoxReversed->blockSignals(true); - ui->buttonFace->blockSignals(true); - ui->lineFaceName->blockSignals(true); - ui->changeMode->blockSignals(true); - // Get the feature data PartDesign::Pocket* pcPocket = static_cast(vp->getObject()); double l = pcPocket->Length.getValue(); @@ -135,13 +108,24 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge // Bind input fields to properties ui->pocketLength->bind(pcPocket->Length); - ui->pocketLength->blockSignals(false); - ui->spinOffset->blockSignals(false); - ui->checkBoxMidplane->blockSignals(false); - ui->checkBoxReversed->blockSignals(false); - ui->buttonFace->blockSignals(false); - ui->lineFaceName->blockSignals(false); - ui->changeMode->blockSignals(false); + QMetaObject::connectSlotsByName(this); + + connect(ui->pocketLength, SIGNAL(valueChanged(double)), + this, SLOT(onLengthChanged(double))); + connect(ui->spinOffset, SIGNAL(valueChanged(double)), + this, SLOT(onOffsetChanged(double))); + connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)), + this, SLOT(onMidplaneChanged(bool))); + connect(ui->checkBoxReversed, SIGNAL(toggled(bool)), + this, SLOT(onReversedChanged(bool))); + connect(ui->changeMode, SIGNAL(currentIndexChanged(int)), + this, SLOT(onModeChanged(int))); + connect(ui->buttonFace, SIGNAL(pressed()), + this, SLOT(onButtonFace())); + connect(ui->lineFaceName, SIGNAL(textEdited(QString)), + this, SLOT(onFaceName(QString))); + connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), + this, SLOT(onUpdateView(bool))); ui->checkBoxReversed->setVisible(true); diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 4b3a66bfd..8a4b244f5 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -56,21 +56,6 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie proxy = new QWidget(this); ui = new Ui_TaskThicknessParameters(); ui->setupUi(proxy); - QMetaObject::connectSlotsByName(this); - - connect(ui->Value, SIGNAL(valueChanged(double)), - this, SLOT(onValueChanged(double))); - connect(ui->checkReverse, SIGNAL(toggled(bool)), - this, SLOT(onReversedChanged(bool))); - connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefAdd(bool))); - connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefRemove(bool))); - connect(ui->modeComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(onModeChanged(int))); - connect(ui->joinComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(onJoinTypeChanged(int))); - this->groupLayout()->addWidget(proxy); PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); @@ -90,6 +75,22 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie { ui->listWidgetReferences->addItem(QString::fromStdString(*i)); } + + QMetaObject::connectSlotsByName(this); + + connect(ui->Value, SIGNAL(valueChanged(double)), + this, SLOT(onValueChanged(double))); + connect(ui->checkReverse, SIGNAL(toggled(bool)), + this, SLOT(onReversedChanged(bool))); + connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefAdd(bool))); + connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefRemove(bool))); + connect(ui->modeComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(onModeChanged(int))); + connect(ui->joinComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(onJoinTypeChanged(int))); + // Create context menu QAction* action = new QAction(tr("Remove"), this); ui->listWidgetReferences->addAction(action);