Update shortcuts for bone graphics view

master
huxingyi 2020-12-19 18:24:39 +09:30
parent eae1253242
commit d42904dfff
5 changed files with 72 additions and 72 deletions

View File

@ -323,9 +323,6 @@ 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/trianglesourcenoderesolve.cpp SOURCES += src/trianglesourcenoderesolve.cpp
HEADERS += src/trianglesourcenoderesolve.h HEADERS += src/trianglesourcenoderesolve.h

View File

@ -41,7 +41,6 @@
#include "imageforever.h" #include "imageforever.h"
#include "spinnableawesomebutton.h" #include "spinnableawesomebutton.h"
#include "fbxfile.h" #include "fbxfile.h"
#include "shortcuts.h"
#include "floatnumberwidget.h" #include "floatnumberwidget.h"
#include "scriptwidget.h" #include "scriptwidget.h"
#include "variablesxml.h" #include "variablesxml.h"
@ -1142,8 +1141,7 @@ DocumentWindow::DocumentWindow()
connect(m_document, &Document::skeletonChanged, this, &DocumentWindow::generateSilhouetteImage); connect(m_document, &Document::skeletonChanged, this, &DocumentWindow::generateSilhouetteImage);
connect(m_shapeGraphicsWidget, &SkeletonGraphicsWidget::loadedTurnaroundImageChanged, this, &DocumentWindow::generateSilhouetteImage); connect(m_shapeGraphicsWidget, &SkeletonGraphicsWidget::loadedTurnaroundImageChanged, this, &DocumentWindow::generateSilhouetteImage);
initShortCuts(this, m_shapeGraphicsWidget); initializeShortcuts();
//initShortCuts(this, m_boneGraphicsWidget);
connect(this, &DocumentWindow::initialized, m_document, &Document::uiReady); connect(this, &DocumentWindow::initialized, m_document, &Document::uiReady);
connect(this, &DocumentWindow::initialized, this, &DocumentWindow::autoRecover); connect(this, &DocumentWindow::initialized, this, &DocumentWindow::autoRecover);
@ -2459,7 +2457,72 @@ void DocumentWindow::silhouetteImageReady()
generateSilhouetteImage(); generateSilhouetteImage();
} }
QShortcut *DocumentWindow::createShortcut(QKeySequence key)
{
auto shortcutIt = m_shortcutMap.find(key);
if (shortcutIt != m_shortcutMap.end())
return shortcutIt->second;
QShortcut *shortcut = new QShortcut(this);
shortcut->setKey(key);
m_shortcutMap.insert({key, shortcut});
return shortcut;
}
#define defineShortcut(keyVal, widget, funcName) \
QObject::connect(createShortcut(keyVal), &QShortcut::activated, widget, funcName)
void DocumentWindow::initializeToolShortcuts(SkeletonGraphicsWidget *graphicsWidget)
{
defineShortcut(Qt::Key_A, graphicsWidget, &SkeletonGraphicsWidget::shortcutAddMode);
defineShortcut(Qt::CTRL + Qt::Key_A, graphicsWidget, &SkeletonGraphicsWidget::shortcutSelectAll);
defineShortcut(Qt::CTRL + Qt::Key_Z, graphicsWidget, &SkeletonGraphicsWidget::shortcutUndo);
defineShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Z, graphicsWidget, &SkeletonGraphicsWidget::shortcutRedo);
defineShortcut(Qt::CTRL + Qt::Key_Y, graphicsWidget, &SkeletonGraphicsWidget::shortcutRedo);
defineShortcut(Qt::Key_Z, graphicsWidget, &SkeletonGraphicsWidget::shortcutZlock);
defineShortcut(Qt::Key_Y, graphicsWidget, &SkeletonGraphicsWidget::shortcutYlock);
defineShortcut(Qt::Key_X, graphicsWidget, &SkeletonGraphicsWidget::shortcutXlock);
defineShortcut(Qt::Key_S, graphicsWidget, &SkeletonGraphicsWidget::shortcutSelectMode);
defineShortcut(Qt::Key_D, graphicsWidget, &SkeletonGraphicsWidget::shortcutPaintMode);
defineShortcut(Qt::Key_R, graphicsWidget, &SkeletonGraphicsWidget::shortcutToggleRotation);
defineShortcut(Qt::Key_O, graphicsWidget, &SkeletonGraphicsWidget::shortcutToggleFlatShading);
defineShortcut(Qt::Key_W, graphicsWidget, &SkeletonGraphicsWidget::shortcutToggleWireframe);
defineShortcut(Qt::Key_Escape, graphicsWidget, &SkeletonGraphicsWidget::shortcutEscape);
}
void DocumentWindow::initializeCanvasShortcuts(SkeletonGraphicsWidget *graphicsWidget)
{
defineShortcut(Qt::Key_Delete, graphicsWidget, &SkeletonGraphicsWidget::shortcutDelete);
defineShortcut(Qt::Key_Backspace, graphicsWidget, &SkeletonGraphicsWidget::shortcutDelete);
defineShortcut(Qt::CTRL + Qt::Key_X, graphicsWidget, &SkeletonGraphicsWidget::shortcutCut);
defineShortcut(Qt::CTRL + Qt::Key_C, graphicsWidget, &SkeletonGraphicsWidget::shortcutCopy);
defineShortcut(Qt::CTRL + Qt::Key_V, graphicsWidget, &SkeletonGraphicsWidget::shortcutPaste);
defineShortcut(Qt::ALT + Qt::Key_Minus, graphicsWidget, &SkeletonGraphicsWidget::shortcutZoomRenderedModelByMinus10);
defineShortcut(Qt::Key_Minus, graphicsWidget, &SkeletonGraphicsWidget::shortcutZoomSelectedByMinus1);
defineShortcut(Qt::ALT + Qt::Key_Equal, graphicsWidget, &SkeletonGraphicsWidget::shortcutZoomRenderedModelBy10);
defineShortcut(Qt::Key_Equal, graphicsWidget, &SkeletonGraphicsWidget::shortcutZoomSelectedBy1);
defineShortcut(Qt::Key_Comma, graphicsWidget, &SkeletonGraphicsWidget::shortcutRotateSelectedByMinus1);
defineShortcut(Qt::Key_Period, graphicsWidget, &SkeletonGraphicsWidget::shortcutRotateSelectedBy1);
defineShortcut(Qt::Key_Left, graphicsWidget, &SkeletonGraphicsWidget::shortcutMoveSelectedToLeft);
defineShortcut(Qt::Key_Right, graphicsWidget, &SkeletonGraphicsWidget::shortcutMoveSelectedToRight);
defineShortcut(Qt::Key_Up, graphicsWidget, &SkeletonGraphicsWidget::shortcutMoveSelectedToUp);
defineShortcut(Qt::Key_Down, graphicsWidget, &SkeletonGraphicsWidget::shortcutMoveSelectedToDown);
defineShortcut(Qt::Key_BracketLeft, graphicsWidget, &SkeletonGraphicsWidget::shortcutScaleSelectedByMinus1);
defineShortcut(Qt::Key_BracketRight, graphicsWidget, &SkeletonGraphicsWidget::shortcutScaleSelectedBy1);
defineShortcut(Qt::Key_E, graphicsWidget, &SkeletonGraphicsWidget::shortcutSwitchProfileOnSelected);
defineShortcut(Qt::Key_H, graphicsWidget, &SkeletonGraphicsWidget::shortcutShowOrHideSelectedPart);
defineShortcut(Qt::Key_J, graphicsWidget, &SkeletonGraphicsWidget::shortcutEnableOrDisableSelectedPart);
defineShortcut(Qt::Key_L, graphicsWidget, &SkeletonGraphicsWidget::shortcutLockOrUnlockSelectedPart);
defineShortcut(Qt::Key_F, graphicsWidget, &SkeletonGraphicsWidget::shortcutCheckPartComponent);
}
void DocumentWindow::initializeShortcuts() void DocumentWindow::initializeShortcuts()
{ {
initializeToolShortcuts(m_shapeGraphicsWidget);
initializeCanvasShortcuts(m_shapeGraphicsWidget);
initializeCanvasShortcuts(m_boneGraphicsWidget);
defineShortcut(Qt::Key_M, m_shapeGraphicsWidget, &SkeletonGraphicsWidget::shortcutXmirrorOnOrOffSelectedPart);
defineShortcut(Qt::Key_B, m_shapeGraphicsWidget, &SkeletonGraphicsWidget::shortcutSubdivedOrNotSelectedPart);
defineShortcut(Qt::Key_U, m_shapeGraphicsWidget, &SkeletonGraphicsWidget::shortcutRoundEndOrNotSelectedPart);
defineShortcut(Qt::Key_C, m_shapeGraphicsWidget, &SkeletonGraphicsWidget::shortcutChamferedOrNotSelectedPart);
} }

View File

@ -10,6 +10,7 @@
#include <map> #include <map>
#include <QStringList> #include <QStringList>
#include <QLabel> #include <QLabel>
#include <QShortcut>
#include "modelwidget.h" #include "modelwidget.h"
#include "rigwidget.h" #include "rigwidget.h"
#include "bonemark.h" #include "bonemark.h"
@ -124,6 +125,9 @@ private:
void updateTitle(); void updateTitle();
void createPartSnapshotForFillMesh(const QUuid &fillMeshFileId, Snapshot *snapshot); void createPartSnapshotForFillMesh(const QUuid &fillMeshFileId, Snapshot *snapshot);
void initializeShortcuts(); void initializeShortcuts();
void initializeToolShortcuts(SkeletonGraphicsWidget *graphicsWidget);
void initializeCanvasShortcuts(SkeletonGraphicsWidget *graphicsWidget);
QShortcut *createShortcut(QKeySequence key);
private: private:
Document *m_document = nullptr; Document *m_document = nullptr;
BoneDocument *m_boneDocument = nullptr; BoneDocument *m_boneDocument = nullptr;
@ -218,6 +222,8 @@ private:
GraphicsViewEditTarget m_graphicsViewEditTarget = GraphicsViewEditTarget::Shape; GraphicsViewEditTarget m_graphicsViewEditTarget = GraphicsViewEditTarget::Shape;
bool m_isSilhouetteImageObsolete = false; bool m_isSilhouetteImageObsolete = false;
SilhouetteImageGenerator *m_silhouetteImageGenerator = nullptr; SilhouetteImageGenerator *m_silhouetteImageGenerator = nullptr;
std::map<QKeySequence, QShortcut *> m_shortcutMap;
public: public:
static int m_autoRecovered; static int m_autoRecovered;
}; };

View File

@ -1,58 +0,0 @@
#include <QShortcut>
#include <QObject>
#include <map>
#include "shortcuts.h"
static std::map<QKeySequence, QShortcut *> g_shortcutMap;
#define defineKey(keyVal, funcName) do { \
auto key = new QShortcut(widget); \
key->setKey(keyVal); \
QObject::connect(key, &QShortcut::activated, \
graphicsWidget, funcName); \
} while (false)
void initShortCuts(QWidget *widget, SkeletonGraphicsWidget *graphicsWidget)
{
defineKey(Qt::Key_Escape, &SkeletonGraphicsWidget::shortcutEscape);
defineKey(Qt::Key_Delete, &SkeletonGraphicsWidget::shortcutDelete);
defineKey(Qt::Key_Backspace, &SkeletonGraphicsWidget::shortcutDelete);
defineKey(Qt::Key_A, &SkeletonGraphicsWidget::shortcutAddMode);
//defineKey(Qt::Key_G, &SkeletonGraphicsWidget::shortcutMarkMode);
defineKey(Qt::CTRL + Qt::Key_A, &SkeletonGraphicsWidget::shortcutSelectAll);
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::Key_S, &SkeletonGraphicsWidget::shortcutSelectMode);
defineKey(Qt::Key_D, &SkeletonGraphicsWidget::shortcutPaintMode);
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::shortcutToggleWireframe);
defineKey(Qt::Key_F, &SkeletonGraphicsWidget::shortcutCheckPartComponent);
defineKey(Qt::Key_C, &SkeletonGraphicsWidget::shortcutChamferedOrNotSelectedPart);
defineKey(Qt::Key_O, &SkeletonGraphicsWidget::shortcutToggleFlatShading);
defineKey(Qt::Key_R, &SkeletonGraphicsWidget::shortcutToggleRotation);
}

View File

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