diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 3706005d5..f725dd054 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -2110,7 +2110,7 @@ void MainWindow::CancelTool() // https://bitbucket.org/dismine/valentina/issues/454/crash-using-crtl-z-while-using-line-tool undoAction->setEnabled(false); redoAction->setEnabled(false); - VInteractiveTool::m_suppressContextMenu = true; + VAbstractTool::m_suppressContextMenu = true; return; case Tool::BasePoint: case Tool::SinglePoint: @@ -2282,7 +2282,7 @@ void MainWindow::ArrowTool() currentTool = Tool::Arrow; emit EnableItemMove(true); emit ItemsSelection(SelectionType::ByMouseRelease); - VInteractiveTool::m_suppressContextMenu = false; + VAbstractTool::m_suppressContextMenu = false; // Only true for rubber band selection emit EnableLabelSelection(true); diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 1a224c2e6..f9cef3f7a 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -1665,9 +1665,12 @@ void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &par Q_UNUSED(e) return;// Just ignore } - initData.data->UpdateGObject(initData.id, - new VPointF(static_cast(*point), point->name(), mx, my, initData.idObject, - Draw::Modeling)); + + QSharedPointer p(new VPointF(static_cast(*point), point->name(), mx, my, initData.idObject, + Draw::Modeling)); + p->SetShowLabel(GetParametrBool(domElement, AttrShowLabel, trueStr)); + + initData.data->UpdateGObject(initData.id, p); VNodePoint::Create(initData); } catch (const VExceptionBadId &e) diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index b78e02e07..c2196989e 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -42,6 +42,7 @@ schema/pattern/v0.6.5.xsd schema/pattern/v0.6.6.xsd schema/pattern/v0.7.0.xsd + schema/pattern/v0.7.1.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.7.1.xsd b/src/libs/ifc/schema/pattern/v0.7.1.xsd new file mode 100644 index 000000000..be36bad7b --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.7.1.xsd @@ -0,0 +1,1043 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 57c04f356..fa3b0abad 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -58,8 +58,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.0"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.0.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.1"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.1.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -258,6 +258,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000606): return QStringLiteral("://schema/pattern/v0.6.6.xsd"); case (0x000700): + return QStringLiteral("://schema/pattern/v0.7.0.xsd"); + case (0x000701): return CurrentSchema; default: InvalidVersion(ver); @@ -434,6 +436,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000700), m_convertedFileName); V_FALLTHROUGH case (0x000700): + ToV0_7_1(); + ValidateXML(XSDSchema(0x000701), m_convertedFileName); + V_FALLTHROUGH + case (0x000701): break; default: InvalidVersion(m_ver); @@ -451,7 +457,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 0), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 1), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -925,6 +931,16 @@ void VPatternConverter::ToV0_7_0() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_7_1() +{ + // TODO. Delete if minimal supported version is 0.7.1 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 1), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.7.1")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 72ce8452d..6da60a0f8 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -53,7 +53,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 0); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 1); protected: virtual int MinVer() const Q_DECL_OVERRIDE; @@ -113,6 +113,7 @@ private: void ToV0_6_5(); void ToV0_6_6(); void ToV0_7_0(); + void ToV0_7_1(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index 247690da5..89f94ae02 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -100,7 +100,7 @@ void VAbstractOperation::ChangeLabelPosition(quint32 id, const QPointF &pos) point->setMy(pos.y()); item->RefreshPointGeometry(*(point.data())); - if (QGraphicsScene *sc = scene()) + if (QGraphicsScene *sc = item->scene()) { VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), item); } @@ -136,6 +136,10 @@ void VAbstractOperation::SetLabelVisible(quint32 id, bool visible) const QSharedPointer point = VAbstractTool::data.GeometricObject(id); point->SetShowLabel(visible); item->RefreshPointGeometry(*point); + if (QGraphicsScene *sc = item->scene()) + { + VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), item); + } } } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp index cc5cfef51..3432468f8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp @@ -147,12 +147,20 @@ void VToolDoublePoint::SetLabelVisible(quint32 id, bool visible) const QSharedPointer point = VAbstractTool::data.GeometricObject(p1id); point->SetShowLabel(visible); firstPoint->RefreshPointGeometry(*point); + if (QGraphicsScene *sc = firstPoint->scene()) + { + VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), firstPoint); + } } else if (p2id == id) { const QSharedPointer point = VAbstractTool::data.GeometricObject(p2id); point->SetShowLabel(visible); secondPoint->RefreshPointGeometry(*point); + if (QGraphicsScene *sc = secondPoint->scene()) + { + VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), secondPoint); + } } } @@ -229,7 +237,7 @@ void VToolDoublePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) point->setMy(pos.y()); firstPoint->RefreshPointGeometry(*(point.data())); - if (QGraphicsScene *sc = scene()) + if (QGraphicsScene *sc = firstPoint->scene()) { VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), firstPoint); } @@ -241,7 +249,7 @@ void VToolDoublePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) point->setMy(pos.y()); secondPoint->RefreshPointGeometry(*(point.data())); - if (QGraphicsScene *sc = scene()) + if (QGraphicsScene *sc = secondPoint->scene()) { VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), secondPoint); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index 76dafd22c..c975e7a6e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -137,6 +137,10 @@ void VToolSinglePoint::SetLabelVisible(quint32 id, bool visible) const QSharedPointer point = VAbstractTool::data.GeometricObject(id); point->SetShowLabel(visible); RefreshPointGeometry(*point); + if (QGraphicsScene *sc = scene()) + { + VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + } } } diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 87f0f34a4..39c33d1f5 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -262,10 +262,3 @@ bool VDrawTool::IsLabelVisible(quint32 id) const Q_UNUSED(id) return false; } - -//--------------------------------------------------------------------------------------------------------------------- -void VDrawTool::SetLabelVisible(quint32 id, bool visible) -{ - Q_UNUSED(id) - Q_UNUSED(visible) -} diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index b39f5d33b..9d2f231d6 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -68,7 +68,6 @@ public: virtual void SetTypeLine(const QString &value); virtual bool IsLabelVisible(quint32 id) const; - virtual void SetLabelVisible(quint32 id, bool visible); signals: void ChangedToolSelection(bool selected, quint32 object, quint32 tool); diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index 7ce3fa03a..4125a1ae3 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -56,6 +58,8 @@ #include "../vdatatool.h" #include "vabstractnode.h" #include "../../undocommands/label/movelabel.h" +#include "../../undocommands/label/showlabel.h" +#include "../vtoolseamallowance.h" const QString VNodePoint::ToolType = QStringLiteral("modeling"); @@ -75,7 +79,7 @@ VNodePoint::VNodePoint(const VAbstractNodeInitData &initData, QObject *qoParent, connect(m_namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, [this](QGraphicsSceneContextMenuEvent *event) { - emit ShowContextMenu(event); + contextMenuEvent(event); }); RefreshPointGeometry(*VAbstractTool::data.GeometricObject(initData.id)); ToolCreation(initData.typeCreation); @@ -147,6 +151,21 @@ void VNodePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) } } +//--------------------------------------------------------------------------------------------------------------------- +void VNodePoint::SetLabelVisible(quint32 id, bool visible) +{ + if (m_id == id) + { + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); + point->SetShowLabel(visible); + RefreshPointGeometry(*point); + if (QGraphicsScene *sc = scene()) + { + VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void VNodePoint::PointChoosed() { @@ -176,6 +195,7 @@ void VNodePoint::AddToFile() doc->SetAttribute(domElement, AttrIdObject, idNode); doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); + doc->SetAttribute(domElement, AttrShowLabel, point->IsShowLabel()); if (idTool != NULL_ID) { doc->SetAttribute(domElement, AttrIdTool, idTool); @@ -241,7 +261,55 @@ void VNodePoint::HideNode() //--------------------------------------------------------------------------------------------------------------------- void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { - emit ShowContextMenu(event); + if (m_suppressContextMenu) + { + return; + } + + if (VToolSeamAllowance *piece = qgraphicsitem_cast(parentItem())) + { + QMenu menu; + QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options")); + + QAction *inLayoutOption = menu.addAction(tr("In layout")); + inLayoutOption->setCheckable(true); + const VPiece detail = VAbstractTool::data.GetPiece(piece->getId()); + inLayoutOption->setChecked(detail.IsInLayout()); + + QAction *actionShowLabel = menu.addAction(tr("Show label")); + actionShowLabel->setCheckable(true); + actionShowLabel->setChecked(VAbstractTool::data.GeometricObject(m_id)->IsShowLabel()); + + QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); + piece->referens() > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true); + + QAction *selectedAction = menu.exec(event->screenPos()); + if (selectedAction == actionOption) + { + emit ShowOptions(); + } + else if (selectedAction == inLayoutOption) + { + emit ToggleInLayout(selectedAction->isChecked()); + } + else if (selectedAction == actionRemove) + { + try + { + emit Delete(); + } + catch(const VExceptionToolWasDeleted &e) + { + Q_UNUSED(e); + return;//Leave this method immediately!!! + } + //Leave this method immediately after call!!! + } + else if (selectedAction == actionShowLabel) + { + qApp->getUndoStack()->push(new ShowLabel(doc, m_id, selectedAction->isChecked())); + } + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.h b/src/libs/vtools/tools/nodeDetails/vnodepoint.h index ee550ab94..25186dd68 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.h +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.h @@ -58,14 +58,11 @@ public: virtual QString getTagName() const Q_DECL_OVERRIDE; virtual void ChangeLabelPosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE; - + virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE; signals: - /** - * @brief ShowContextMenu emit when need show tool context menu. - * @param event context menu event. - */ - void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); - + void ShowOptions(); + void ToggleInLayout(bool checked); + void Delete(); public slots: virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; void NameChangePosition(const QPointF &pos); diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 75d99cfa7..4143cb82b 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -81,6 +81,7 @@ template class QSharedPointer; +bool VAbstractTool::m_suppressContextMenu = false; const QString VAbstractTool::AttrInUse = QStringLiteral("inUse"); //--------------------------------------------------------------------------------------------------------------------- @@ -375,6 +376,13 @@ void VAbstractTool::ChangeLabelPosition(quint32 id, const QPointF &pos) Q_UNUSED(pos) } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractTool::SetLabelVisible(quint32 id, bool visible) +{ + Q_UNUSED(id) + Q_UNUSED(visible) +} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractTool::ToolSelectionType(const SelectionType &type) { diff --git a/src/libs/vtools/tools/vabstracttool.h b/src/libs/vtools/tools/vabstracttool.h index bb2c0fce1..f704b2165 100644 --- a/src/libs/vtools/tools/vabstracttool.h +++ b/src/libs/vtools/tools/vabstracttool.h @@ -89,6 +89,7 @@ public: virtual ~VAbstractTool() Q_DECL_OVERRIDE; quint32 getId() const; + static bool m_suppressContextMenu; static const QString AttrInUse; static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data); @@ -109,7 +110,7 @@ public: virtual QString getTagName() const =0; virtual void ShowVisualization(bool show) =0; virtual void ChangeLabelPosition(quint32 id, const QPointF &pos); - + virtual void SetLabelVisible(quint32 id, bool visible); public slots: /** * @brief FullUpdateFromFile update tool data form file. diff --git a/src/libs/vtools/tools/vinteractivetool.cpp b/src/libs/vtools/tools/vinteractivetool.cpp index d4fe7a4c3..e0359e0c6 100644 --- a/src/libs/vtools/tools/vinteractivetool.cpp +++ b/src/libs/vtools/tools/vinteractivetool.cpp @@ -28,8 +28,6 @@ #include "vinteractivetool.h" -bool VInteractiveTool::m_suppressContextMenu = false; - //--------------------------------------------------------------------------------------------------------------------- VInteractiveTool::VInteractiveTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent) : VAbstractTool(doc, data, id, parent), diff --git a/src/libs/vtools/tools/vinteractivetool.h b/src/libs/vtools/tools/vinteractivetool.h index d5d9a4da0..3a7147bf0 100644 --- a/src/libs/vtools/tools/vinteractivetool.h +++ b/src/libs/vtools/tools/vinteractivetool.h @@ -43,8 +43,6 @@ public: void DialogLinkDestroy(); - static bool m_suppressContextMenu; - public slots: virtual void FullUpdateFromGuiOk(int result); virtual void FullUpdateFromGuiApply(); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index cadaaf430..d157270eb 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1159,28 +1159,17 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) QAction *selectedAction = menu.exec(event->screenPos()); if (selectedAction == actionOption) { - QSharedPointer dialog = - QSharedPointer(new DialogSeamAllowance(getData(), m_id, qApp->getMainWindow())); - dialog->EnableApply(true); - 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(); + ShowOptions(); } else if (selectedAction == inLayoutOption) { - TogglePieceInLayout *togglePrint = new TogglePieceInLayout(m_id, selectedAction->isChecked(), - &(VAbstractTool::data), doc); - connect(togglePrint, &TogglePieceInLayout::UpdateList, doc, &VAbstractPattern::CheckInLayoutList); - qApp->getUndoStack()->push(togglePrint); + ToggleInLayout(selectedAction->isChecked()); } else if (selectedAction == actionRemove) { try { - DeleteToolWithConfirm(); + DeleteFromMenu(); } catch(const VExceptionToolWasDeleted &e) { @@ -1381,6 +1370,34 @@ void VToolSeamAllowance::SaveDialogChange(const QString &undoText) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::ShowOptions() +{ + QSharedPointer dialog = + QSharedPointer(new DialogSeamAllowance(getData(), m_id, qApp->getMainWindow())); + dialog->EnableApply(true); + 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(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::ToggleInLayout(bool checked) +{ + TogglePieceInLayout *togglePrint = new TogglePieceInLayout(m_id, checked, &(VAbstractTool::data), doc); + connect(togglePrint, &TogglePieceInLayout::UpdateList, doc, &VAbstractPattern::CheckInLayoutList); + qApp->getUndoStack()->push(togglePrint); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::DeleteFromMenu() +{ + DeleteToolWithConfirm(); +} + //--------------------------------------------------------------------------------------------------------------------- VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData& labelData, qreal &rotationAngle, qreal &labelWidth, qreal &labelHeight, QPointF &pos) @@ -1596,8 +1613,11 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc if (tool->parent() != parent) { - connect(tool, &VNodePoint::ShowContextMenu, parent, &VToolSeamAllowance::contextMenuEvent); - connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(tool, &VNodePoint::ShowOptions, parent, &VToolSeamAllowance::ShowOptions, Qt::UniqueConnection); + connect(tool, &VNodePoint::ToggleInLayout, parent, &VToolSeamAllowance::ToggleInLayout, + Qt::UniqueConnection); + connect(tool, &VNodePoint::Delete, parent, &VToolSeamAllowance::DeleteFromMenu, Qt::UniqueConnection); + connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem, Qt::UniqueConnection); tool->setParentItem(parent); tool->SetParentType(ParentType::Item); tool->SetExluded(node.IsExcluded()); diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 55aea4aae..889e1a9c4 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -159,6 +159,11 @@ protected: virtual void SetDialog() Q_DECL_FINAL; virtual void SaveDialogChange(const QString &undoText = QString()) Q_DECL_FINAL; +private slots: + void ShowOptions(); + void ToggleInLayout(bool checked); + void DeleteFromMenu(); + private: Q_DISABLE_COPY(VToolSeamAllowance) diff --git a/src/libs/vtools/undocommands/label/showlabel.cpp b/src/libs/vtools/undocommands/label/showlabel.cpp index 11608d698..87e76c6f0 100644 --- a/src/libs/vtools/undocommands/label/showlabel.cpp +++ b/src/libs/vtools/undocommands/label/showlabel.cpp @@ -82,11 +82,10 @@ void ShowLabel::Do(bool visible) { doc->SetAttribute(domElement, AttrShowLabel, visible); - if (VDrawTool *tool = qobject_cast(VAbstractPattern::getTool(nodeId))) + if (VAbstractTool *tool = qobject_cast(VAbstractPattern::getTool(nodeId))) { tool->SetLabelVisible(nodeId, visible); } - VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView()); } else {