Add more shortcuts for part manipulation.

H: (H)idden
J: (J)join
L: (L)ock
B: (B)ox
M: (M)irror

When xyz pressed without ctrl modifer:
X: X-axis
Y: Y-axis
Z: Z-axis
master
Jeremy Hu 2018-04-18 11:14:48 +08:00
parent a7d45a9458
commit b0bdfe3742
4 changed files with 60 additions and 1 deletions

View File

@ -401,6 +401,16 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
connect(graphicsWidget, &SkeletonGraphicsWidget::partChecked, m_document, &SkeletonDocument::partChecked); connect(graphicsWidget, &SkeletonGraphicsWidget::partChecked, m_document, &SkeletonDocument::partChecked);
connect(graphicsWidget, &SkeletonGraphicsWidget::partUnchecked, m_document, &SkeletonDocument::partUnchecked); connect(graphicsWidget, &SkeletonGraphicsWidget::partUnchecked, m_document, &SkeletonDocument::partUnchecked);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartLockState, m_document, &SkeletonDocument::setPartLockState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartVisibleState, m_document, &SkeletonDocument::setPartVisibleState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartSubdivState, m_document, &SkeletonDocument::setPartSubdivState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartDisableState, m_document, &SkeletonDocument::setPartDisableState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartXmirrorState, m_document, &SkeletonDocument::setPartXmirrorState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setXlockState, m_document, &SkeletonDocument::setXlockState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setYlockState, m_document, &SkeletonDocument::setYlockState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setZlockState, m_document, &SkeletonDocument::setZlockState);
connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &SkeletonDocumentWindow::changeTurnaround); connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &SkeletonDocumentWindow::changeTurnaround);
connect(graphicsWidget, &SkeletonGraphicsWidget::save, this, &SkeletonDocumentWindow::save); connect(graphicsWidget, &SkeletonGraphicsWidget::save, this, &SkeletonDocumentWindow::save);
connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &SkeletonDocumentWindow::open); connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &SkeletonDocumentWindow::open);

View File

@ -999,16 +999,22 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
} else { } else {
emit undo(); emit undo();
} }
} else {
emit setZlockState(!m_document->zlocked);
} }
} else if (event->key() == Qt::Key_Y) { } else if (event->key() == Qt::Key_Y) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
if (!QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) { if (!QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) {
emit redo(); emit redo();
} }
} else {
emit setYlockState(!m_document->ylocked);
} }
} else if (event->key() == Qt::Key_X) { } else if (event->key() == Qt::Key_X) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
cut(); cut();
} else {
emit setXlockState(!m_document->xlocked);
} }
} else if (event->key() == Qt::Key_C) { } else if (event->key() == Qt::Key_C) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
@ -1100,6 +1106,41 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) { if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
switchProfileOnRangeSelection(); switchProfileOnRangeSelection();
} }
} else if (event->key() == Qt::Key_H) {
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
bool partVisible = part && part->visible;
emit setPartVisibleState(m_lastCheckedPart, !partVisible);
emit groupOperationAdded();
}
} else if (event->key() == Qt::Key_J) {
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
bool partDisabled = part && part->disabled;
emit setPartDisableState(m_lastCheckedPart, !partDisabled);
emit groupOperationAdded();
}
} else if (event->key() == Qt::Key_L) {
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
bool partLocked = part && part->locked;
emit setPartLockState(m_lastCheckedPart, !partLocked);
emit groupOperationAdded();
}
} else if (event->key() == Qt::Key_M) {
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
bool partXmirrored = part && part->xMirrored;
emit setPartXmirrorState(m_lastCheckedPart, !partXmirrored);
emit groupOperationAdded();
}
} else if (event->key() == Qt::Key_B) {
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
bool partSubdived = part && part->subdived;
emit setPartSubdivState(m_lastCheckedPart, !partSubdived);
emit groupOperationAdded();
}
} }
return false; return false;
} }

View File

@ -357,6 +357,14 @@ signals:
void moveOriginBy(float x, float y, float z); void moveOriginBy(float x, float y, float z);
void partChecked(QUuid partId); void partChecked(QUuid partId);
void partUnchecked(QUuid partId); void partUnchecked(QUuid partId);
void setPartLockState(QUuid partId, bool locked);
void setPartVisibleState(QUuid partId, bool visible);
void setPartSubdivState(QUuid partId, bool subdived);
void setPartDisableState(QUuid partId, bool disabled);
void setPartXmirrorState(QUuid partId, bool mirrored);
void setXlockState(bool locked);
void setYlockState(bool locked);
void setZlockState(bool locked);
public: public:
SkeletonGraphicsWidget(const SkeletonDocument *document); SkeletonGraphicsWidget(const SkeletonDocument *document);
std::map<QUuid, std::pair<SkeletonGraphicsNodeItem *, SkeletonGraphicsNodeItem *>> nodeItemMap; std::map<QUuid, std::pair<SkeletonGraphicsNodeItem *, SkeletonGraphicsNodeItem *>> nodeItemMap;

View File

@ -41,8 +41,8 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
miniTopToolLayout->setSpacing(0); miniTopToolLayout->setSpacing(0);
miniTopToolLayout->setContentsMargins(0, 0, 0, 0); miniTopToolLayout->setContentsMargins(0, 0, 0, 0);
miniTopToolLayout->addWidget(m_visibleButton); miniTopToolLayout->addWidget(m_visibleButton);
miniTopToolLayout->addWidget(m_lockButton);
miniTopToolLayout->addWidget(m_disableButton); miniTopToolLayout->addWidget(m_disableButton);
miniTopToolLayout->addWidget(m_lockButton);
miniTopToolLayout->addStretch(); miniTopToolLayout->addStretch();
QHBoxLayout *miniBottomToolLayout = new QHBoxLayout; QHBoxLayout *miniBottomToolLayout = new QHBoxLayout;