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::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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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;
}