Fix undo on part tree widget

master
Jeremy Hu 2019-10-21 21:51:57 +09:30
parent c2807195bd
commit 12a95f2e8e
4 changed files with 14 additions and 4 deletions

View File

@ -969,6 +969,7 @@ DocumentWindow::DocumentWindow() :
connect(partTreeWidget, &PartTreeWidget::showDescendantComponents, m_document, &Document::showDescendantComponents); connect(partTreeWidget, &PartTreeWidget::showDescendantComponents, m_document, &Document::showDescendantComponents);
connect(partTreeWidget, &PartTreeWidget::lockDescendantComponents, m_document, &Document::lockDescendantComponents); connect(partTreeWidget, &PartTreeWidget::lockDescendantComponents, m_document, &Document::lockDescendantComponents);
connect(partTreeWidget, &PartTreeWidget::unlockDescendantComponents, m_document, &Document::unlockDescendantComponents); connect(partTreeWidget, &PartTreeWidget::unlockDescendantComponents, m_document, &Document::unlockDescendantComponents);
connect(partTreeWidget, &PartTreeWidget::groupOperationAdded, m_document, &Document::saveSnapshot);
connect(partTreeWidget, &PartTreeWidget::addPartToSelection, graphicsWidget, &SkeletonGraphicsWidget::addPartToSelection); connect(partTreeWidget, &PartTreeWidget::addPartToSelection, graphicsWidget, &SkeletonGraphicsWidget::addPartToSelection);

View File

@ -9,7 +9,7 @@ IntNumberWidget::IntNumberWidget(QWidget *parent, bool singleLine) :
{ {
m_slider = new QSlider(Qt::Horizontal, this); m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setRange(0, 100); m_slider->setRange(0, 100);
m_slider->setFixedWidth(120); m_slider->setFixedWidth(240);
m_label = new QLabel(this); m_label = new QLabel(this);
m_label->setAlignment(Qt::AlignLeft); m_label->setAlignment(Qt::AlignLeft);

View File

@ -525,24 +525,28 @@ void PartTreeWidget::showContextMenu(const QPoint &pos)
moveToTopAction.setIcon(Theme::awesome()->icon(fa::angledoubleup)); moveToTopAction.setIcon(Theme::awesome()->icon(fa::angledoubleup));
connect(&moveToTopAction, &QAction::triggered, [=]() { connect(&moveToTopAction, &QAction::triggered, [=]() {
emit moveComponentToTop(component->id); emit moveComponentToTop(component->id);
emit groupOperationAdded();
}); });
moveToMenu->addAction(&moveToTopAction); moveToMenu->addAction(&moveToTopAction);
moveUpAction.setIcon(Theme::awesome()->icon(fa::angleup)); moveUpAction.setIcon(Theme::awesome()->icon(fa::angleup));
connect(&moveUpAction, &QAction::triggered, [=]() { connect(&moveUpAction, &QAction::triggered, [=]() {
emit moveComponentUp(component->id); emit moveComponentUp(component->id);
emit groupOperationAdded();
}); });
moveToMenu->addAction(&moveUpAction); moveToMenu->addAction(&moveUpAction);
moveDownAction.setIcon(Theme::awesome()->icon(fa::angledown)); moveDownAction.setIcon(Theme::awesome()->icon(fa::angledown));
connect(&moveDownAction, &QAction::triggered, [=]() { connect(&moveDownAction, &QAction::triggered, [=]() {
emit moveComponentDown(component->id); emit moveComponentDown(component->id);
emit groupOperationAdded();
}); });
moveToMenu->addAction(&moveDownAction); moveToMenu->addAction(&moveDownAction);
moveToBottomAction.setIcon(Theme::awesome()->icon(fa::angledoubledown)); moveToBottomAction.setIcon(Theme::awesome()->icon(fa::angledoubledown));
connect(&moveToBottomAction, &QAction::triggered, [=]() { connect(&moveToBottomAction, &QAction::triggered, [=]() {
emit moveComponentToBottom(component->id); emit moveComponentToBottom(component->id);
emit groupOperationAdded();
}); });
moveToMenu->addAction(&moveToBottomAction); moveToMenu->addAction(&moveToBottomAction);
@ -552,6 +556,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos)
moveToMenu->addAction(&moveToNewGroupAction); moveToMenu->addAction(&moveToNewGroupAction);
connect(&moveToNewGroupAction, &QAction::triggered, [=]() { connect(&moveToNewGroupAction, &QAction::triggered, [=]() {
emit createNewComponentAndMoveThisIn(component->id); emit createNewComponentAndMoveThisIn(component->id);
emit groupOperationAdded();
}); });
moveToMenu->addSeparator(); moveToMenu->addSeparator();
@ -572,6 +577,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos)
connect(action, &QAction::triggered, [=]() { connect(action, &QAction::triggered, [=]() {
for (const auto &componentId: componentIds) for (const auto &componentId: componentIds)
emit moveComponent(componentId, current->id); emit moveComponent(componentId, current->id);
emit groupOperationAdded();
}); });
groupsActions.push_back(action); groupsActions.push_back(action);
moveToMenu->addAction(action); moveToMenu->addAction(action);
@ -588,6 +594,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos)
connect(&deleteAction, &QAction::triggered, [=]() { connect(&deleteAction, &QAction::triggered, [=]() {
for (const auto &componentId: componentIds) for (const auto &componentId: componentIds)
emit removeComponent(componentId); emit removeComponent(componentId);
emit groupOperationAdded();
}); });
contextMenu.addAction(&deleteAction); contextMenu.addAction(&deleteAction);
} }

View File

@ -851,15 +851,17 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event)
if (SkeletonDocumentEditMode::Add == m_document->editMode) { if (SkeletonDocumentEditMode::Add == m_document->editMode) {
QPointF mouseScenePos = mouseEventScenePos(event); QPointF mouseScenePos = mouseEventScenePos(event);
m_cursorNodeItem->setOrigin(mouseScenePos); m_cursorNodeItem->setOrigin(mouseScenePos);
if (!m_cursorNodeItem->isVisible()) {
m_cursorNodeItem->show();
}
if (m_addFromNodeItem) { if (m_addFromNodeItem) {
m_cursorEdgeItem->setEndpoints(m_addFromNodeItem, m_cursorNodeItem); m_cursorEdgeItem->setEndpoints(m_addFromNodeItem, m_cursorNodeItem);
if (!m_cursorNodeItem->isVisible())
m_cursorNodeItem->setRadius(m_addFromNodeItem->radius());
if (!m_cursorEdgeItem->isVisible()) { if (!m_cursorEdgeItem->isVisible()) {
m_cursorEdgeItem->show(); m_cursorEdgeItem->show();
} }
} }
if (!m_cursorNodeItem->isVisible()) {
m_cursorNodeItem->show();
}
return true; return true;
} }