From 1c0dced61d1e44324e8bc53e8903569865a1b7c5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 9 Nov 2016 16:27:55 +0200 Subject: [PATCH] Apply button now works. --HG-- branch : feature --- src/libs/vtools/tools/vtoolseamallowance.cpp | 31 ++++++++++++++------ src/libs/vtools/tools/vtoolseamallowance.h | 4 ++- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 5dc59d2d6..04dd71ced 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -302,19 +302,17 @@ void VToolSeamAllowance::FullUpdateFromGuiOk(int result) { if (result == QDialog::Accepted) { - SCASSERT(not m_dialog.isNull()); - DialogSeamAllowance *dialogTool = qobject_cast(m_dialog.data()); - SCASSERT(dialogTool != nullptr); - const VPiece newDet = dialogTool->GetPiece(); - const VPiece oldDet = VAbstractTool::data.GetPiece(id); - - SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, id, this->scene()); - connect(saveCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); - qApp->getUndoStack()->push(saveCommand); + SaveDialogChange(); } delete m_dialog; } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::FullUpdateFromGuiApply() +{ + SaveDialogChange(); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::EnableToolMove(bool move) { @@ -536,6 +534,7 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) m_dialog = dialog; m_dialog->setModal(true); connect(m_dialog.data(), &DialogTool::DialogClosed, this, &VToolSeamAllowance::FullUpdateFromGuiOk); + connect(m_dialog.data(), &DialogTool::DialogApplied, this, &VToolSeamAllowance::FullUpdateFromGuiApply); SetDialog(); m_dialog->show(); } @@ -668,6 +667,20 @@ void VToolSeamAllowance::RefreshGeometry() this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::SaveDialogChange() +{ + SCASSERT(not m_dialog.isNull()); + DialogSeamAllowance *dialogTool = qobject_cast(m_dialog.data()); + SCASSERT(dialogTool != nullptr); + const VPiece newDet = dialogTool->GetPiece(); + const VPiece oldDet = VAbstractTool::data.GetPiece(id); + + SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, id, this->scene()); + connect(saveCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); + qApp->getUndoStack()->push(saveCommand); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::DeleteTool(bool ask) { diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 7e57059aa..5a3f6d4e9 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -83,6 +83,7 @@ public: public slots: virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; virtual void FullUpdateFromGuiOk(int result); + void FullUpdateFromGuiApply(); void EnableToolMove(bool move); virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; @@ -119,7 +120,8 @@ private: VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VMainGraphicsScene *scene, const QString &m_drawName, QGraphicsItem * parent = nullptr); - void RefreshGeometry (); + void RefreshGeometry(); + void SaveDialogChange(); template Tool* InitTool(VMainGraphicsScene *scene, const VPieceNode &node);