Fix direction key conflict with zoom function
parent
623dda6ecf
commit
134078fc05
|
@ -572,8 +572,9 @@ void SkeletonGraphicsWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void SkeletonGraphicsWidget::keyPressEvent(QKeyEvent *event)
|
void SkeletonGraphicsWidget::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
|
if (keyPress(event))
|
||||||
|
return;
|
||||||
QGraphicsView::keyPressEvent(event);
|
QGraphicsView::keyPressEvent(event);
|
||||||
keyPress(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event)
|
bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event)
|
||||||
|
@ -1285,22 +1286,6 @@ void SkeletonGraphicsWidget::deleteSelected()
|
||||||
if (nullptr == m_deferredRemoveTimer) {
|
if (nullptr == m_deferredRemoveTimer) {
|
||||||
timeToRemoveDeferredNodesAndEdges();
|
timeToRemoveDeferredNodesAndEdges();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (!m_rangeSelectionSet.empty()) {
|
|
||||||
emit batchChangeBegin();
|
|
||||||
std::set<QUuid> nodeIdSet;
|
|
||||||
std::set<QUuid> edgeIdSet;
|
|
||||||
readSkeletonNodeAndEdgeIdSetFromRangeSelection(&nodeIdSet, &edgeIdSet);
|
|
||||||
for (const auto &id: edgeIdSet) {
|
|
||||||
emit removeEdge(id);
|
|
||||||
}
|
|
||||||
for (const auto &id: nodeIdSet) {
|
|
||||||
emit removeNode(id);
|
|
||||||
}
|
|
||||||
emit batchChangeEnd();
|
|
||||||
emit groupOperationAdded();
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
|
@ -1326,74 +1311,94 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
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();
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
emit undo();
|
emit undo();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit setZlockState(!m_document->zlocked);
|
emit setZlockState(!m_document->zlocked);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} 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();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit setYlockState(!m_document->ylocked);
|
emit setYlockState(!m_document->ylocked);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} 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();
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
emit setXlockState(!m_document->xlocked);
|
emit setXlockState(!m_document->xlocked);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} 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)) {
|
||||||
copy();
|
copy();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_V) {
|
} else if (event->key() == Qt::Key_V) {
|
||||||
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
|
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
|
||||||
emit paste();
|
emit paste();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_S) {
|
} else if (event->key() == Qt::Key_S) {
|
||||||
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
|
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
|
||||||
emit save();
|
emit save();
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
emit setEditMode(SkeletonDocumentEditMode::Select);
|
emit setEditMode(SkeletonDocumentEditMode::Select);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_D) {
|
} else if (event->key() == Qt::Key_D) {
|
||||||
emit setEditMode(SkeletonDocumentEditMode::Drag);
|
emit setEditMode(SkeletonDocumentEditMode::Drag);
|
||||||
|
return true;
|
||||||
} else if (event->key() == Qt::Key_Minus) {
|
} else if (event->key() == Qt::Key_Minus) {
|
||||||
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier)) {
|
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier)) {
|
||||||
emit zoomRenderedModelBy(-10);
|
emit zoomRenderedModelBy(-10);
|
||||||
|
return true;
|
||||||
} else if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
} else if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
||||||
zoomSelected(-1);
|
zoomSelected(-1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_Equal) {
|
} else if (event->key() == Qt::Key_Equal) {
|
||||||
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier)) {
|
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier)) {
|
||||||
emit zoomRenderedModelBy(10);
|
emit zoomRenderedModelBy(10);
|
||||||
|
return true;
|
||||||
} else if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
} else if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
||||||
zoomSelected(1);
|
zoomSelected(1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_Comma) {
|
} else if (event->key() == Qt::Key_Comma) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
||||||
rotateSelected(-1);
|
rotateSelected(-1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_Period) {
|
} else if (event->key() == Qt::Key_Period) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
||||||
rotateSelected(1);
|
rotateSelected(1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_Left) {
|
} else if (event->key() == Qt::Key_Left) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode) {
|
||||||
if (m_checkedOriginItem) {
|
if (m_checkedOriginItem) {
|
||||||
moveCheckedOrigin(-1, 0);
|
moveCheckedOrigin(-1, 0);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
} else if (hasSelection()) {
|
} else if (hasSelection()) {
|
||||||
moveSelected(-1, 0);
|
moveSelected(-1, 0);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_Right) {
|
} else if (event->key() == Qt::Key_Right) {
|
||||||
|
@ -1401,9 +1406,11 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
if (m_checkedOriginItem) {
|
if (m_checkedOriginItem) {
|
||||||
moveCheckedOrigin(1, 0);
|
moveCheckedOrigin(1, 0);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
} else if (hasSelection()) {
|
} else if (hasSelection()) {
|
||||||
moveSelected(1, 0);
|
moveSelected(1, 0);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_Up) {
|
} else if (event->key() == Qt::Key_Up) {
|
||||||
|
@ -1411,9 +1418,11 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
if (m_checkedOriginItem) {
|
if (m_checkedOriginItem) {
|
||||||
moveCheckedOrigin(0, -1);
|
moveCheckedOrigin(0, -1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
} else if (hasSelection()) {
|
} else if (hasSelection()) {
|
||||||
moveSelected(0, -1);
|
moveSelected(0, -1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_Down) {
|
} else if (event->key() == Qt::Key_Down) {
|
||||||
|
@ -1421,24 +1430,29 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
if (m_checkedOriginItem) {
|
if (m_checkedOriginItem) {
|
||||||
moveCheckedOrigin(0, 1);
|
moveCheckedOrigin(0, 1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
} else if (hasSelection()) {
|
} else if (hasSelection()) {
|
||||||
moveSelected(0, 1);
|
moveSelected(0, 1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_BracketLeft) {
|
} else if (event->key() == Qt::Key_BracketLeft) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
||||||
scaleSelected(-1);
|
scaleSelected(-1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_BracketRight) {
|
} else if (event->key() == Qt::Key_BracketRight) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
||||||
scaleSelected(1);
|
scaleSelected(1);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_Tab) {
|
} else if (event->key() == Qt::Key_Tab) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
|
||||||
switchProfileOnRangeSelection();
|
switchProfileOnRangeSelection();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_H) {
|
} else if (event->key() == Qt::Key_H) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
||||||
|
@ -1446,6 +1460,7 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
bool partVisible = part && part->visible;
|
bool partVisible = part && part->visible;
|
||||||
emit setPartVisibleState(m_lastCheckedPart, !partVisible);
|
emit setPartVisibleState(m_lastCheckedPart, !partVisible);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_J) {
|
} else if (event->key() == Qt::Key_J) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
||||||
|
@ -1453,6 +1468,7 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
bool partDisabled = part && part->disabled;
|
bool partDisabled = part && part->disabled;
|
||||||
emit setPartDisableState(m_lastCheckedPart, !partDisabled);
|
emit setPartDisableState(m_lastCheckedPart, !partDisabled);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_L) {
|
} else if (event->key() == Qt::Key_L) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
||||||
|
@ -1460,6 +1476,7 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
bool partLocked = part && part->locked;
|
bool partLocked = part && part->locked;
|
||||||
emit setPartLockState(m_lastCheckedPart, !partLocked);
|
emit setPartLockState(m_lastCheckedPart, !partLocked);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_M) {
|
} else if (event->key() == Qt::Key_M) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
||||||
|
@ -1467,6 +1484,7 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
bool partXmirrored = part && part->xMirrored;
|
bool partXmirrored = part && part->xMirrored;
|
||||||
emit setPartXmirrorState(m_lastCheckedPart, !partXmirrored);
|
emit setPartXmirrorState(m_lastCheckedPart, !partXmirrored);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_B) {
|
} else if (event->key() == Qt::Key_B) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
||||||
|
@ -1474,6 +1492,7 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
bool partSubdived = part && part->subdived;
|
bool partSubdived = part && part->subdived;
|
||||||
emit setPartSubdivState(m_lastCheckedPart, !partSubdived);
|
emit setPartSubdivState(m_lastCheckedPart, !partSubdived);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if (event->key() == Qt::Key_U) {
|
} else if (event->key() == Qt::Key_U) {
|
||||||
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
|
||||||
|
@ -1481,6 +1500,7 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
|
||||||
bool partRounded = part && part->rounded;
|
bool partRounded = part && part->rounded;
|
||||||
emit setPartRoundState(m_lastCheckedPart, !partRounded);
|
emit setPartRoundState(m_lastCheckedPart, !partRounded);
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue