Improve shortcuts

Shortcuts implementation now use QShortcut instead of using the raw key event.
Besides, hold spacebar to temporarily enter drag mode also implemented in this commit, this is very useful in zoom mode.
master
Jeremy Hu 2018-10-24 21:44:21 +08:00
parent 71ccb2b71f
commit ee20aff397
6 changed files with 402 additions and 225 deletions

View File

@ -266,6 +266,9 @@ HEADERS += src/tabwidget.h
SOURCES += src/flowlayout.cpp SOURCES += src/flowlayout.cpp
HEADERS += src/flowlayout.h HEADERS += src/flowlayout.h
SOURCES += src/shortcuts.cpp
HEADERS += src/shortcuts.h
SOURCES += src/main.cpp SOURCES += src/main.cpp
HEADERS += src/version.h HEADERS += src/version.h

49
src/shortcuts.cpp Normal file
View File

@ -0,0 +1,49 @@
#include <QShortcut>
#include <QObject>
#include "shortcuts.h"
#define defineKey(keyVal, funcName) do { \
auto key = new QShortcut(mainWindow); \
key->setKey(keyVal); \
QObject::connect(key, &QShortcut::activated, \
graphicsWidget, funcName); \
} while (false)
void initShortCuts(QMainWindow *mainWindow, SkeletonGraphicsWidget *graphicsWidget)
{
defineKey(Qt::Key_Delete, &SkeletonGraphicsWidget::shortcutDelete);
defineKey(Qt::Key_Backspace, &SkeletonGraphicsWidget::shortcutDelete);
defineKey(Qt::Key_A, &SkeletonGraphicsWidget::shortcutAddMode);
defineKey(Qt::CTRL + Qt::Key_Z, &SkeletonGraphicsWidget::shortcutUndo);
defineKey(Qt::CTRL + Qt::SHIFT + Qt::Key_Z, &SkeletonGraphicsWidget::shortcutRedo);
defineKey(Qt::CTRL + Qt::Key_Y, &SkeletonGraphicsWidget::shortcutRedo);
defineKey(Qt::Key_Z, &SkeletonGraphicsWidget::shortcutZlock);
defineKey(Qt::Key_Y, &SkeletonGraphicsWidget::shortcutYlock);
defineKey(Qt::CTRL + Qt::Key_X, &SkeletonGraphicsWidget::shortcutCut);
defineKey(Qt::Key_X, &SkeletonGraphicsWidget::shortcutXlock);
defineKey(Qt::CTRL + Qt::Key_C, &SkeletonGraphicsWidget::shortcutCopy);
defineKey(Qt::CTRL + Qt::Key_V, &SkeletonGraphicsWidget::shortcutPaste);
defineKey(Qt::CTRL + Qt::Key_S, &SkeletonGraphicsWidget::shortcutSave);
defineKey(Qt::Key_S, &SkeletonGraphicsWidget::shortcutSelectMode);
defineKey(Qt::Key_D, &SkeletonGraphicsWidget::shortcutDragMode);
defineKey(Qt::ALT + Qt::Key_Minus, &SkeletonGraphicsWidget::shortcutZoomRenderedModelByMinus10);
defineKey(Qt::Key_Minus, &SkeletonGraphicsWidget::shortcutZoomSelectedByMinus1);
defineKey(Qt::ALT + Qt::Key_Equal, &SkeletonGraphicsWidget::shortcutZoomRenderedModelBy10);
defineKey(Qt::Key_Equal, &SkeletonGraphicsWidget::shortcutZoomSelectedBy1);
defineKey(Qt::Key_Comma, &SkeletonGraphicsWidget::shortcutRotateSelectedByMinus1);
defineKey(Qt::Key_Period, &SkeletonGraphicsWidget::shortcutRotateSelectedBy1);
defineKey(Qt::Key_Left, &SkeletonGraphicsWidget::shortcutMoveSelectedToLeft);
defineKey(Qt::Key_Right, &SkeletonGraphicsWidget::shortcutMoveSelectedToRight);
defineKey(Qt::Key_Up, &SkeletonGraphicsWidget::shortcutMoveSelectedToUp);
defineKey(Qt::Key_Down, &SkeletonGraphicsWidget::shortcutMoveSelectedToDown);
defineKey(Qt::Key_BracketLeft, &SkeletonGraphicsWidget::shortcutScaleSelectedByMinus1);
defineKey(Qt::Key_BracketRight, &SkeletonGraphicsWidget::shortcutScaleSelectedBy1);
defineKey(Qt::Key_E, &SkeletonGraphicsWidget::shortcutSwitchProfileOnSelected);
defineKey(Qt::Key_H, &SkeletonGraphicsWidget::shortcutShowOrHideSelectedPart);
defineKey(Qt::Key_J, &SkeletonGraphicsWidget::shortcutEnableOrDisableSelectedPart);
defineKey(Qt::Key_L, &SkeletonGraphicsWidget::shortcutLockOrUnlockSelectedPart);
defineKey(Qt::Key_M, &SkeletonGraphicsWidget::shortcutXmirrorOnOrOffSelectedPart);
defineKey(Qt::Key_B, &SkeletonGraphicsWidget::shortcutSubdivedOrNotSelectedPart);
defineKey(Qt::Key_U, &SkeletonGraphicsWidget::shortcutRoundEndOrNotSelectedPart);
defineKey(Qt::Key_W, &SkeletonGraphicsWidget::shortcutWrapOrNotSelectedPart);
}

8
src/shortcuts.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef SHORTCUTS_H
#define SHORTCUTS_H
#include <QMainWindow>
#include "skeletongraphicswidget.h"
void initShortCuts(QMainWindow *mainWindow, SkeletonGraphicsWidget *graphicsWidget);
#endif

View File

@ -35,6 +35,7 @@
#include "imageforever.h" #include "imageforever.h"
#include "spinnableawesomebutton.h" #include "spinnableawesomebutton.h"
#include "fbxfile.h" #include "fbxfile.h"
#include "shortcuts.h"
int SkeletonDocumentWindow::m_modelRenderWidgetInitialX = 16; int SkeletonDocumentWindow::m_modelRenderWidgetInitialX = 16;
int SkeletonDocumentWindow::m_modelRenderWidgetInitialY = 16; int SkeletonDocumentWindow::m_modelRenderWidgetInitialY = 16;
@ -888,6 +889,8 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
m_document->generateMaterialPreviews(); m_document->generateMaterialPreviews();
}); });
initShortCuts(this, m_graphicsWidget);
connect(this, &SkeletonDocumentWindow::initialized, m_document, &SkeletonDocument::uiReady); connect(this, &SkeletonDocumentWindow::initialized, m_document, &SkeletonDocument::uiReady);
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);

View File

@ -43,7 +43,9 @@ SkeletonGraphicsWidget::SkeletonGraphicsWidget(const SkeletonDocument *document)
m_ikMover(nullptr), m_ikMover(nullptr),
m_deferredRemoveTimer(nullptr), m_deferredRemoveTimer(nullptr),
m_eventForwardingToModelWidget(false), m_eventForwardingToModelWidget(false),
m_modelWidget(nullptr) m_modelWidget(nullptr),
m_inTempDragMode(false),
m_modeBeforeEnterTempDragMode(SkeletonDocumentEditMode::Select)
{ {
setRenderHint(QPainter::Antialiasing, false); setRenderHint(QPainter::Antialiasing, false);
setBackgroundBrush(QBrush(QWidget::palette().color(QWidget::backgroundRole()), Qt::SolidPattern)); setBackgroundBrush(QBrush(QWidget::palette().color(QWidget::backgroundRole()), Qt::SolidPattern));
@ -627,6 +629,13 @@ void SkeletonGraphicsWidget::keyPressEvent(QKeyEvent *event)
QGraphicsView::keyPressEvent(event); QGraphicsView::keyPressEvent(event);
} }
void SkeletonGraphicsWidget::keyReleaseEvent(QKeyEvent *event)
{
if (keyRelease(event))
return;
QGraphicsView::keyReleaseEvent(event);
}
bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event) bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event)
{ {
if (m_dragStarted) { if (m_dragStarted) {
@ -1374,9 +1383,8 @@ void SkeletonGraphicsWidget::deleteSelected()
} }
} }
bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event) void SkeletonGraphicsWidget::shortcutDelete()
{ {
if (event->key() == Qt::Key_Delete || event->key() ==Qt::Key_Backspace) {
bool processed = false; bool processed = false;
if (!m_rangeSelectionSet.empty()) { if (!m_rangeSelectionSet.empty()) {
deleteSelected(); deleteSelected();
@ -1384,219 +1392,288 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
} }
if (processed) { if (processed) {
emit groupOperationAdded(); emit groupOperationAdded();
return true; return;
} }
} else if (event->key() == Qt::Key_A) { }
void SkeletonGraphicsWidget::shortcutAddMode()
{
if (SkeletonDocumentEditMode::Add == m_document->editMode) { if (SkeletonDocumentEditMode::Add == m_document->editMode) {
emit setEditMode(SkeletonDocumentEditMode::Select); emit setEditMode(SkeletonDocumentEditMode::Select);
} else { } else {
emit setEditMode(SkeletonDocumentEditMode::Add); emit setEditMode(SkeletonDocumentEditMode::Add);
} }
return true; }
} else if (event->key() == Qt::Key_Z) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { void SkeletonGraphicsWidget::shortcutUndo()
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) { {
emit redo();
return true;
} else {
emit undo(); emit undo();
return true;
} }
} else {
emit setZlockState(!m_document->zlocked); void SkeletonGraphicsWidget::shortcutRedo()
return true; {
}
} else if (event->key() == Qt::Key_Y) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
if (!QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) {
emit redo(); emit redo();
return true;
} }
} else {
emit setYlockState(!m_document->ylocked); void SkeletonGraphicsWidget::shortcutXlock()
return true; {
}
} else if (event->key() == Qt::Key_X) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
cut();
return true;
} else {
emit setXlockState(!m_document->xlocked); emit setXlockState(!m_document->xlocked);
return true;
} }
} else if (event->key() == Qt::Key_C) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { void SkeletonGraphicsWidget::shortcutYlock()
{
emit setYlockState(!m_document->ylocked);
}
void SkeletonGraphicsWidget::shortcutZlock()
{
emit setZlockState(!m_document->zlocked);
}
void SkeletonGraphicsWidget::shortcutCut()
{
cut();
}
void SkeletonGraphicsWidget::shortcutCopy()
{
copy(); copy();
return true;
} }
} else if (event->key() == Qt::Key_V) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { void SkeletonGraphicsWidget::shortcutPaste()
{
emit paste(); emit paste();
return true;
} }
} else if (event->key() == Qt::Key_S) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { void SkeletonGraphicsWidget::shortcutSave()
{
emit save(); emit save();
return true;
} else {
emit setEditMode(SkeletonDocumentEditMode::Select);
return true;
} }
} else if (event->key() == Qt::Key_D) {
void SkeletonGraphicsWidget::shortcutSelectMode()
{
emit setEditMode(SkeletonDocumentEditMode::Select);
}
void SkeletonGraphicsWidget::shortcutDragMode()
{
emit setEditMode(SkeletonDocumentEditMode::Drag); emit setEditMode(SkeletonDocumentEditMode::Drag);
return true; }
} else if (event->key() == Qt::Key_Minus) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier)) { void SkeletonGraphicsWidget::shortcutZoomRenderedModelByMinus10()
{
emit zoomRenderedModelBy(-10); emit zoomRenderedModelBy(-10);
return true; }
} else if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
void SkeletonGraphicsWidget::shortcutZoomSelectedByMinus1()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
zoomSelected(-1); zoomSelected(-1);
emit groupOperationAdded(); emit groupOperationAdded();
return true;
} }
} else if (event->key() == Qt::Key_Equal) { }
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier)) {
void SkeletonGraphicsWidget::shortcutZoomRenderedModelBy10()
{
emit zoomRenderedModelBy(10); emit zoomRenderedModelBy(10);
return true; }
} else if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
void SkeletonGraphicsWidget::shortcutZoomSelectedBy1()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
zoomSelected(1); zoomSelected(1);
emit groupOperationAdded(); emit groupOperationAdded();
return true;
} }
} else if (event->key() == Qt::Key_Comma) { }
void SkeletonGraphicsWidget::shortcutRotateSelectedByMinus1()
{
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) { }
void SkeletonGraphicsWidget::shortcutRotateSelectedBy1()
{
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) { }
void SkeletonGraphicsWidget::shortcutMoveSelectedToLeft()
{
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) { }
void SkeletonGraphicsWidget::shortcutMoveSelectedToRight()
{
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_Up) { }
void SkeletonGraphicsWidget::shortcutMoveSelectedToUp()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode) { if (SkeletonDocumentEditMode::Select == m_document->editMode) {
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) { }
void SkeletonGraphicsWidget::shortcutMoveSelectedToDown()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode) { if (SkeletonDocumentEditMode::Select == m_document->editMode) {
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) { }
void SkeletonGraphicsWidget::shortcutScaleSelectedByMinus1()
{
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) { }
void SkeletonGraphicsWidget::shortcutScaleSelectedBy1()
{
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_E) { }
void SkeletonGraphicsWidget::shortcutSwitchProfileOnSelected()
{
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) { }
void SkeletonGraphicsWidget::shortcutShowOrHideSelectedPart()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
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) { }
void SkeletonGraphicsWidget::shortcutEnableOrDisableSelectedPart()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
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) { }
void SkeletonGraphicsWidget::shortcutLockOrUnlockSelectedPart()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
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) { }
void SkeletonGraphicsWidget::shortcutXmirrorOnOrOffSelectedPart()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
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) { }
void SkeletonGraphicsWidget::shortcutSubdivedOrNotSelectedPart()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
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) { }
void SkeletonGraphicsWidget::shortcutRoundEndOrNotSelectedPart()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
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;
} }
} else if (event->key() == Qt::Key_W) { }
void SkeletonGraphicsWidget::shortcutWrapOrNotSelectedPart()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
bool partWrapped = part && part->wrapped; bool partWrapped = part && part->wrapped;
emit setPartWrapState(m_lastCheckedPart, !partWrapped); emit setPartWrapState(m_lastCheckedPart, !partWrapped);
emit groupOperationAdded(); emit groupOperationAdded();
}
}
bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
{
if (event->key() == Qt::Key_Space) {
if (SkeletonDocumentEditMode::ZoomIn == m_document->editMode ||
SkeletonDocumentEditMode::ZoomOut == m_document->editMode ||
SkeletonDocumentEditMode::Select == m_document->editMode ||
SkeletonDocumentEditMode::Add == m_document->editMode) {
m_inTempDragMode = true;
m_modeBeforeEnterTempDragMode = m_document->editMode;
emit setEditMode(SkeletonDocumentEditMode::Drag);
return true; return true;
} }
} }
return false;
}
bool SkeletonGraphicsWidget::keyRelease(QKeyEvent *event)
{
if (event->key() == Qt::Key_Space) {
if (m_inTempDragMode) {
m_inTempDragMode = false;
emit setEditMode(m_modeBeforeEnterTempDragMode);
return true;
}
}
return false; return false;
} }

View File

@ -389,6 +389,7 @@ public:
bool mousePress(QMouseEvent *event); bool mousePress(QMouseEvent *event);
bool mouseDoubleClick(QMouseEvent *event); bool mouseDoubleClick(QMouseEvent *event);
bool keyPress(QKeyEvent *event); bool keyPress(QKeyEvent *event);
bool keyRelease(QKeyEvent *event);
bool checkSkeletonItem(QGraphicsItem *item, bool checked); bool checkSkeletonItem(QGraphicsItem *item, bool checked);
QUuid querySkeletonItemPartId(QGraphicsItem *item); QUuid querySkeletonItemPartId(QGraphicsItem *item);
static SkeletonProfile readSkeletonItemProfile(QGraphicsItem *item); static SkeletonProfile readSkeletonItemProfile(QGraphicsItem *item);
@ -403,12 +404,13 @@ public:
bool hasTwoDisconnectedNodesSelection(); bool hasTwoDisconnectedNodesSelection();
void setModelWidget(ModelWidget *modelWidget); void setModelWidget(ModelWidget *modelWidget);
protected: protected:
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event); void wheelEvent(QWheelEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event); void mouseDoubleClickEvent(QMouseEvent *event) override;
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
public slots: public slots:
void nodeAdded(QUuid nodeId); void nodeAdded(QUuid nodeId);
void edgeAdded(QUuid edgeId); void edgeAdded(QUuid edgeId);
@ -462,6 +464,39 @@ public slots:
void setSelectedNodesBoneMark(SkeletonBoneMark boneMark); void setSelectedNodesBoneMark(SkeletonBoneMark boneMark);
void timeToRemoveDeferredNodesAndEdges(); void timeToRemoveDeferredNodesAndEdges();
void switchSelectedXZ(); void switchSelectedXZ();
void shortcutDelete();
void shortcutAddMode();
void shortcutUndo();
void shortcutRedo();
void shortcutXlock();
void shortcutYlock();
void shortcutZlock();
void shortcutCut();
void shortcutCopy();
void shortcutPaste();
void shortcutSave();
void shortcutSelectMode();
void shortcutDragMode();
void shortcutZoomRenderedModelByMinus10();
void shortcutZoomSelectedByMinus1();
void shortcutZoomRenderedModelBy10();
void shortcutZoomSelectedBy1();
void shortcutRotateSelectedByMinus1();
void shortcutRotateSelectedBy1();
void shortcutMoveSelectedToLeft();
void shortcutMoveSelectedToRight();
void shortcutMoveSelectedToUp();
void shortcutMoveSelectedToDown();
void shortcutScaleSelectedByMinus1();
void shortcutScaleSelectedBy1();
void shortcutSwitchProfileOnSelected();
void shortcutShowOrHideSelectedPart();
void shortcutEnableOrDisableSelectedPart();
void shortcutLockOrUnlockSelectedPart();
void shortcutXmirrorOnOrOffSelectedPart();
void shortcutSubdivedOrNotSelectedPart();
void shortcutRoundEndOrNotSelectedPart();
void shortcutWrapOrNotSelectedPart();
private slots: private slots:
void turnaroundImageReady(); void turnaroundImageReady();
private: private:
@ -515,6 +550,8 @@ private: //need initalize
QTimer *m_deferredRemoveTimer; QTimer *m_deferredRemoveTimer;
bool m_eventForwardingToModelWidget; bool m_eventForwardingToModelWidget;
ModelWidget *m_modelWidget; ModelWidget *m_modelWidget;
bool m_inTempDragMode;
SkeletonDocumentEditMode m_modeBeforeEnterTempDragMode;
private: private:
QVector3D m_ikMoveTarget; QVector3D m_ikMoveTarget;
QUuid m_ikMoveEndEffectorId; QUuid m_ikMoveEndEffectorId;