From 12a95f2e8eb6bb334fa22718829e3f657613c94d Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Mon, 21 Oct 2019 21:51:57 +0930 Subject: [PATCH] Fix undo on part tree widget --- src/documentwindow.cpp | 1 + src/intnumberwidget.cpp | 2 +- src/parttreewidget.cpp | 7 +++++++ src/skeletongraphicswidget.cpp | 8 +++++--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/documentwindow.cpp b/src/documentwindow.cpp index 389cd9b8..46c73851 100644 --- a/src/documentwindow.cpp +++ b/src/documentwindow.cpp @@ -969,6 +969,7 @@ DocumentWindow::DocumentWindow() : connect(partTreeWidget, &PartTreeWidget::showDescendantComponents, m_document, &Document::showDescendantComponents); connect(partTreeWidget, &PartTreeWidget::lockDescendantComponents, m_document, &Document::lockDescendantComponents); connect(partTreeWidget, &PartTreeWidget::unlockDescendantComponents, m_document, &Document::unlockDescendantComponents); + connect(partTreeWidget, &PartTreeWidget::groupOperationAdded, m_document, &Document::saveSnapshot); connect(partTreeWidget, &PartTreeWidget::addPartToSelection, graphicsWidget, &SkeletonGraphicsWidget::addPartToSelection); diff --git a/src/intnumberwidget.cpp b/src/intnumberwidget.cpp index 39c107c6..0764b684 100644 --- a/src/intnumberwidget.cpp +++ b/src/intnumberwidget.cpp @@ -9,7 +9,7 @@ IntNumberWidget::IntNumberWidget(QWidget *parent, bool singleLine) : { m_slider = new QSlider(Qt::Horizontal, this); m_slider->setRange(0, 100); - m_slider->setFixedWidth(120); + m_slider->setFixedWidth(240); m_label = new QLabel(this); m_label->setAlignment(Qt::AlignLeft); diff --git a/src/parttreewidget.cpp b/src/parttreewidget.cpp index 1e5b1cdc..739c7e6c 100644 --- a/src/parttreewidget.cpp +++ b/src/parttreewidget.cpp @@ -525,24 +525,28 @@ void PartTreeWidget::showContextMenu(const QPoint &pos) moveToTopAction.setIcon(Theme::awesome()->icon(fa::angledoubleup)); connect(&moveToTopAction, &QAction::triggered, [=]() { emit moveComponentToTop(component->id); + emit groupOperationAdded(); }); moveToMenu->addAction(&moveToTopAction); moveUpAction.setIcon(Theme::awesome()->icon(fa::angleup)); connect(&moveUpAction, &QAction::triggered, [=]() { emit moveComponentUp(component->id); + emit groupOperationAdded(); }); moveToMenu->addAction(&moveUpAction); moveDownAction.setIcon(Theme::awesome()->icon(fa::angledown)); connect(&moveDownAction, &QAction::triggered, [=]() { emit moveComponentDown(component->id); + emit groupOperationAdded(); }); moveToMenu->addAction(&moveDownAction); moveToBottomAction.setIcon(Theme::awesome()->icon(fa::angledoubledown)); connect(&moveToBottomAction, &QAction::triggered, [=]() { emit moveComponentToBottom(component->id); + emit groupOperationAdded(); }); moveToMenu->addAction(&moveToBottomAction); @@ -552,6 +556,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos) moveToMenu->addAction(&moveToNewGroupAction); connect(&moveToNewGroupAction, &QAction::triggered, [=]() { emit createNewComponentAndMoveThisIn(component->id); + emit groupOperationAdded(); }); moveToMenu->addSeparator(); @@ -572,6 +577,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos) connect(action, &QAction::triggered, [=]() { for (const auto &componentId: componentIds) emit moveComponent(componentId, current->id); + emit groupOperationAdded(); }); groupsActions.push_back(action); moveToMenu->addAction(action); @@ -588,6 +594,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos) connect(&deleteAction, &QAction::triggered, [=]() { for (const auto &componentId: componentIds) emit removeComponent(componentId); + emit groupOperationAdded(); }); contextMenu.addAction(&deleteAction); } diff --git a/src/skeletongraphicswidget.cpp b/src/skeletongraphicswidget.cpp index f2360fa5..c92516b1 100644 --- a/src/skeletongraphicswidget.cpp +++ b/src/skeletongraphicswidget.cpp @@ -851,15 +851,17 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event) if (SkeletonDocumentEditMode::Add == m_document->editMode) { QPointF mouseScenePos = mouseEventScenePos(event); m_cursorNodeItem->setOrigin(mouseScenePos); - if (!m_cursorNodeItem->isVisible()) { - m_cursorNodeItem->show(); - } if (m_addFromNodeItem) { m_cursorEdgeItem->setEndpoints(m_addFromNodeItem, m_cursorNodeItem); + if (!m_cursorNodeItem->isVisible()) + m_cursorNodeItem->setRadius(m_addFromNodeItem->radius()); if (!m_cursorEdgeItem->isVisible()) { m_cursorEdgeItem->show(); } } + if (!m_cursorNodeItem->isVisible()) { + m_cursorNodeItem->show(); + } return true; }