Use QObject::blockSignals if need block signal instead disconnect() each time.
--HG-- branch : develop
This commit is contained in:
parent
9435c9fe22
commit
318517d3d7
|
@ -96,9 +96,9 @@ void DialogHistory::cellClicked(int row, int column)
|
|||
cursorRow = row;
|
||||
item->setIcon(QIcon("://icon/32x32/put_after.png"));
|
||||
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
||||
disconnect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor);
|
||||
doc->blockSignals(true);
|
||||
doc->setCursor(id);
|
||||
connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor);
|
||||
doc->blockSignals(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -350,22 +350,21 @@ void DialogIncrements::FullUpdateFromFile()
|
|||
{
|
||||
if (qApp->patternType() == MeasurementsType::Individual)
|
||||
{
|
||||
disconnect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this,
|
||||
&DialogIncrements::MeasurementChanged);
|
||||
ui->tableWidgetMeasurements->blockSignals(true);
|
||||
}
|
||||
ui->tableWidgetMeasurements->clearContents();
|
||||
FillMeasurements();
|
||||
ui->tableWidgetMeasurements->horizontalHeader()->setStretchLastSection(true);
|
||||
if (qApp->patternType() == MeasurementsType::Individual)
|
||||
{
|
||||
connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementChanged);
|
||||
ui->tableWidgetMeasurements->blockSignals(false);
|
||||
}
|
||||
|
||||
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
|
||||
ui->tableWidgetIncrement->blockSignals(true);
|
||||
ui->tableWidgetIncrement->clearContents();
|
||||
FillIncrements();
|
||||
ui->tableWidgetIncrement->horizontalHeader()->setStretchLastSection(true);
|
||||
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
|
||||
ui->tableWidgetIncrement->blockSignals(false);
|
||||
|
||||
ui->tableWidgetLines->clearContents();
|
||||
FillLengthLines();
|
||||
|
@ -527,8 +526,7 @@ void DialogIncrements::OpenTable()
|
|||
void DialogIncrements::clickedToolButtonAdd()
|
||||
{
|
||||
ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason);
|
||||
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
|
||||
&DialogIncrements::IncrementChanged);
|
||||
ui->tableWidgetIncrement->blockSignals(true);
|
||||
qint32 currentRow = ui->tableWidgetIncrement->rowCount();
|
||||
ui->tableWidgetIncrement->insertRow( currentRow );
|
||||
|
||||
|
@ -579,8 +577,7 @@ void DialogIncrements::clickedToolButtonAdd()
|
|||
ui->tableWidgetIncrement->setItem(currentRow, 5, item);
|
||||
|
||||
ui->toolButtonRemove->setEnabled(true);
|
||||
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
|
||||
&DialogIncrements::IncrementChanged);
|
||||
ui->tableWidgetIncrement->blockSignals(false);
|
||||
emit haveLiteChange();
|
||||
}
|
||||
|
||||
|
@ -590,8 +587,7 @@ void DialogIncrements::clickedToolButtonAdd()
|
|||
*/
|
||||
void DialogIncrements::clickedToolButtonRemove()
|
||||
{
|
||||
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
|
||||
&DialogIncrements::IncrementChanged);
|
||||
ui->tableWidgetIncrement->blockSignals(true);
|
||||
|
||||
QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem();
|
||||
qint32 row = item->row();
|
||||
|
@ -613,8 +609,7 @@ void DialogIncrements::clickedToolButtonRemove()
|
|||
ui->toolButtonRemove->setEnabled(false);
|
||||
}
|
||||
|
||||
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
|
||||
&DialogIncrements::IncrementChanged);
|
||||
ui->tableWidgetIncrement->blockSignals(false);
|
||||
emit haveLiteChange();
|
||||
}
|
||||
|
||||
|
|
|
@ -354,9 +354,9 @@ void DialogArc::EvalF2()
|
|||
*/
|
||||
void DialogArc::ShowLineAngles()
|
||||
{
|
||||
disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
|
||||
ui->listWidget->blockSignals(true);
|
||||
ui->listWidget->clear();
|
||||
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
|
||||
ui->listWidget->blockSignals(false);
|
||||
const QMap<QString, VLineAngle *> lineAnglesTable = data->DataLineAngles();
|
||||
QMapIterator<QString, VLineAngle *> i(lineAnglesTable);
|
||||
while (i.hasNext())
|
||||
|
|
|
@ -179,16 +179,12 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t
|
|||
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
||||
ui.listWidget->addItem(item);
|
||||
ui.listWidget->setCurrentRow(ui.listWidget->count()-1);
|
||||
disconnect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogDetail::BiasXChanged);
|
||||
disconnect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogDetail::BiasYChanged);
|
||||
ui.doubleSpinBoxBiasX->blockSignals(true);
|
||||
ui.doubleSpinBoxBiasY->blockSignals(true);
|
||||
ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx()));
|
||||
ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy()));
|
||||
connect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogDetail::BiasXChanged);
|
||||
connect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogDetail::BiasYChanged);
|
||||
ui.doubleSpinBoxBiasX->blockSignals(false);
|
||||
ui.doubleSpinBoxBiasY->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -257,16 +257,11 @@ void DialogSplinePath::NewItem(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm
|
|||
*/
|
||||
void DialogSplinePath::DataPoint(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
|
||||
{
|
||||
disconnect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogSplinePath::currentPointChanged);
|
||||
disconnect(ui->doubleSpinBoxAngle1, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogSplinePath::Angle1Changed);
|
||||
disconnect(ui->doubleSpinBoxAngle2, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogSplinePath::Angle2Changed);
|
||||
disconnect(ui->doubleSpinBoxKasm1, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogSplinePath::KAsm1Changed);
|
||||
disconnect(ui->doubleSpinBoxKasm2, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogSplinePath::KAsm2Changed);
|
||||
ui->comboBoxPoint->blockSignals(true);
|
||||
ui->doubleSpinBoxAngle1->blockSignals(true);
|
||||
ui->doubleSpinBoxAngle2->blockSignals(true);
|
||||
ui->doubleSpinBoxKasm1->blockSignals(true);
|
||||
ui->doubleSpinBoxKasm2->blockSignals(true);
|
||||
|
||||
ChangeCurrentData(ui->comboBoxPoint, id);
|
||||
ui->doubleSpinBoxKasm1->setValue(kAsm1);
|
||||
|
@ -274,16 +269,11 @@ void DialogSplinePath::DataPoint(quint32 id, qreal kAsm1, qreal angle1, qreal kA
|
|||
ui->doubleSpinBoxAngle2->setValue(angle2);
|
||||
ui->doubleSpinBoxAngle1->setValue(angle1);
|
||||
|
||||
connect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogSplinePath::currentPointChanged);
|
||||
connect(ui->doubleSpinBoxAngle1, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogSplinePath::Angle1Changed);
|
||||
connect(ui->doubleSpinBoxAngle2, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogSplinePath::Angle2Changed);
|
||||
connect(ui->doubleSpinBoxKasm1, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogSplinePath::KAsm1Changed);
|
||||
connect(ui->doubleSpinBoxKasm2, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogSplinePath::KAsm2Changed);
|
||||
ui->comboBoxPoint->blockSignals(false);
|
||||
ui->doubleSpinBoxAngle1->blockSignals(false);
|
||||
ui->doubleSpinBoxAngle2->blockSignals(false);
|
||||
ui->doubleSpinBoxKasm1->blockSignals(false);
|
||||
ui->doubleSpinBoxKasm2->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -688,13 +688,9 @@ void DialogTool::ChangeColor(QWidget *widget, const QColor &color)
|
|||
void DialogTool::setPointId(QComboBox *box, quint32 &pointId, const quint32 &value)
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
disconnect(box, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this,
|
||||
&DialogTool::PointNameChanged);
|
||||
|
||||
box->blockSignals(true);
|
||||
setCurrentPointId(box, pointId, value);
|
||||
|
||||
connect(box, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this,
|
||||
&DialogTool::PointNameChanged);
|
||||
box->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -835,7 +831,7 @@ void DialogTool::EvalFormula()
|
|||
void DialogTool::SizeHeight()
|
||||
{
|
||||
SCASSERT(listWidget != nullptr);
|
||||
disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
||||
listWidget->blockSignals(true);
|
||||
listWidget->clear();
|
||||
|
||||
{
|
||||
|
@ -848,7 +844,7 @@ void DialogTool::SizeHeight()
|
|||
item->setFont(QFont("Times", 12, QFont::Bold));
|
||||
listWidget->addItem(item);
|
||||
|
||||
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
||||
listWidget->blockSignals(false);
|
||||
listWidget->setCurrentRow (0);
|
||||
}
|
||||
|
||||
|
@ -1057,7 +1053,7 @@ template <class key, class val>
|
|||
void DialogTool::ShowVariable(const QMap<key, val> var)
|
||||
{
|
||||
SCASSERT(listWidget != nullptr);
|
||||
disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
||||
listWidget->blockSignals(true);
|
||||
listWidget->clear();
|
||||
|
||||
QMapIterator<key, val> iMap(var);
|
||||
|
@ -1071,7 +1067,7 @@ void DialogTool::ShowVariable(const QMap<key, val> var)
|
|||
listWidget->addItem(item);
|
||||
}
|
||||
}
|
||||
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
||||
listWidget->blockSignals(false);
|
||||
listWidget->setCurrentRow (0);
|
||||
}
|
||||
|
||||
|
|
|
@ -191,8 +191,7 @@ void MainWindow::ActionNewPP()
|
|||
qDebug()<<"Error creating pattern piece with the name "<<patternPieceName<<".";
|
||||
return;
|
||||
}
|
||||
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &MainWindow::currentPPChanged);
|
||||
comboBoxDraws->blockSignals(true);
|
||||
comboBoxDraws->addItem(patternPieceName);
|
||||
|
||||
pattern->ClearGObjects();
|
||||
|
@ -218,8 +217,7 @@ void MainWindow::ActionNewPP()
|
|||
{
|
||||
comboBoxDraws->setCurrentIndex(0);
|
||||
}
|
||||
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&MainWindow::currentPPChanged);
|
||||
comboBoxDraws->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1386,12 +1384,10 @@ void MainWindow::FullParseFile()
|
|||
{
|
||||
patternPiece = comboBoxDraws->itemText(comboBoxDraws->currentIndex());
|
||||
}
|
||||
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &MainWindow::currentPPChanged);
|
||||
comboBoxDraws->blockSignals(true);
|
||||
comboBoxDraws->clear();
|
||||
comboBoxDraws->addItems(doc->getPatternPieces());
|
||||
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &MainWindow::currentPPChanged);
|
||||
comboBoxDraws->blockSignals(false);
|
||||
ui->actionPattern_properties->setEnabled(true);
|
||||
|
||||
qint32 index = comboBoxDraws->findText(patternPiece);
|
||||
|
|
|
@ -223,13 +223,13 @@ void VToolPoint::RefreshPointGeometry(const VPointF &point)
|
|||
this->setRect(rec);
|
||||
this->setPos(point.toQPointF());
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition);
|
||||
namePoint->blockSignals(true);
|
||||
QFont font = namePoint->font();
|
||||
font.setPointSize(static_cast<qint32>(namePoint->FontSize()/factor));
|
||||
namePoint->setFont(font);
|
||||
namePoint->setText(point.name());
|
||||
namePoint->setPos(QPointF(point.mx(), point.my()));
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition);
|
||||
namePoint->blockSignals(false);
|
||||
RefreshLine();
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
}
|
||||
|
|
|
@ -298,16 +298,14 @@ void VToolSpline::SaveDialog(QDomElement &domElement)
|
|||
VSpline spl = VSpline (point1, point4, dialogTool->getAngle1(), dialogTool->getAngle2(),
|
||||
dialogTool->getKAsm1(), dialogTool->getKAsm2(), dialogTool->getKCurve());
|
||||
|
||||
disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
controlPoints[0]->blockSignals(true);
|
||||
controlPoints[1]->blockSignals(true);
|
||||
|
||||
controlPoints[0]->setPos(spl.GetP2());
|
||||
controlPoints[1]->setPos(spl.GetP3());
|
||||
connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
|
||||
controlPoints[0]->blockSignals(false);
|
||||
controlPoints[1]->blockSignals(false);
|
||||
|
||||
spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->getKCurve());
|
||||
|
||||
|
@ -339,14 +337,12 @@ void VToolSpline::RefreshGeometry()
|
|||
controlPoint = spl->GetP3();
|
||||
emit RefreshLine(1, SplinePointPosition::LastPoint, controlPoint, splinePoint);
|
||||
|
||||
disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
controlPoints[0]->blockSignals(true);
|
||||
controlPoints[1]->blockSignals(true);
|
||||
|
||||
controlPoints[0]->setPos(spl->GetP2());
|
||||
controlPoints[1]->setPos(spl->GetP3());
|
||||
connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
|
||||
controlPoints[0]->blockSignals(false);
|
||||
controlPoints[1]->blockSignals(false);
|
||||
}
|
||||
|
|
|
@ -215,16 +215,15 @@ void VToolSplinePath::RefreshSplinePath(VSplinePath &splPath)
|
|||
{
|
||||
VSpline spl = splPath.GetSpline(i);
|
||||
qint32 j = i*2;
|
||||
disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
disconnect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
|
||||
controlPoints[j-2]->blockSignals(true);
|
||||
controlPoints[j-1]->blockSignals(true);
|
||||
|
||||
controlPoints[j-2]->setPos(spl.GetP2());
|
||||
controlPoints[j-1]->setPos(spl.GetP3());
|
||||
connect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
|
||||
controlPoints[j-2]->blockSignals(false);
|
||||
controlPoints[j-1]->blockSignals(false);
|
||||
|
||||
spl = VSpline (spl.GetP1(), controlPoints[j-2]->pos(), controlPoints[j-1]->pos(), spl.GetP4(),
|
||||
splPath.getKCurve());
|
||||
|
@ -391,15 +390,14 @@ void VToolSplinePath::RefreshGeometry()
|
|||
emit RefreshLine(i, SplinePointPosition::LastPoint, controlPoint, splinePoint);
|
||||
|
||||
qint32 j = i*2;
|
||||
disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
disconnect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
|
||||
controlPoints[j-2]->blockSignals(true);
|
||||
controlPoints[j-1]->blockSignals(true);
|
||||
|
||||
controlPoints[j-2]->setPos(spl.GetP2());
|
||||
controlPoints[j-1]->setPos(spl.GetP3());
|
||||
connect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
|
||||
controlPoints[j-2]->blockSignals(false);
|
||||
controlPoints[j-1]->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,12 +267,11 @@ void VNodePoint::RefreshPointGeometry(const VPointF &point)
|
|||
rec.translate(-rec.center().x(), -rec.center().y());
|
||||
this->setRect(rec);
|
||||
this->setPos(point.toQPointF());
|
||||
disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||
&VNodePoint::NameChangePosition);
|
||||
|
||||
namePoint->blockSignals(true);
|
||||
namePoint->setText(point.name());
|
||||
namePoint->setPos(QPointF(point.mx(), point.my()));
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||
&VNodePoint::NameChangePosition);
|
||||
namePoint->blockSignals(false);
|
||||
|
||||
RefreshLine();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user