OpenToonz - An open-source full-featured 2D animation creation software
C
fix viewer key press event (#2047)
shun-iwasawa1d99423a73ce
diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cppindex 8317664e7..7313175e3 100644--- a/toonz/sources/toonz/sceneviewerevents.cpp+++ b/toonz/sources/toonz/sceneviewerevents.cpp@@ -1178,68 +1178,65 @@ bool changeFrameSkippingHolds(QKeyEvent *e) {void SceneViewer::keyPressEvent(QKeyEvent *event) {if (m_freezedStatus != NO_FREEZED) return;-int key = event->key();- if (changeFrameSkippingHolds(event)) {- return;- }- TTool *tool = TApp::instance()->getCurrentTool()->getTool();- if (!tool) return;-- bool isTextToolActive = tool->getName() == T_Type && tool->isActive();-- if (!isTextToolActive && ViewerZoomer(this).exec(event)) return;-- if (!isTextToolActive && SceneViewerShortcutReceiver(this).exec(event))- return;-- if (!tool->isEnabled()) return;-- tool->setViewer(this);+ // resolving priority and tool-specific key events in this lambda+ auto ret = [&]() -> bool {+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();+ if (!tool) return false;++ bool isTextToolActive = tool->getName() == T_Type && tool->isActive();++ if (!isTextToolActive) {+ if (ViewerZoomer(this).exec(event)) return true;+ if (SceneViewerShortcutReceiver(this).exec(event)) return true;+ // If this object is child of Viewer or ComboViewer+ // (m_isStyleShortcutSelective = true),+ // then consider about shortcut for the current style selection.+ if (m_isStyleShortcutSwitchable &&+ Preferences::instance()->isUseNumpadForSwitchingStylesEnabled() &&+ (event->modifiers() == Qt::NoModifier ||+ event->modifiers() == Qt::KeypadModifier) &&+ ((Qt::Key_0 <= key && key <= Qt::Key_9) || key == Qt::Key_Tab ||+ key == Qt::Key_Backtab)) {+ event->ignore();+ return true;+ }+ }- // If this object is child of Viewer or ComboViewer- // (m_isStyleShortcutSelective = true),- // then consider about shortcut for the current style selection.- if (m_isStyleShortcutSwitchable &&- Preferences::instance()->isUseNumpadForSwitchingStylesEnabled() &&- (!isTextToolActive) && (event->modifiers() == Qt::NoModifier ||- event->modifiers() == Qt::KeypadModifier) &&- ((Qt::Key_0 <= key && key <= Qt::Key_9) || key == Qt::Key_Tab ||- key == Qt::Key_Backtab)) {- event->ignore();- return;- }+ if (!tool->isEnabled()) return false;- if (key == Qt::Key_Shift || key == Qt::Key_Control || key == Qt::Key_Alt ||- key == Qt::Key_AltGr) {- // quando l'utente preme shift/ctrl ecc. alcuni tool (es. pinch) devono- // cambiare subito la forma del cursore, senza aspettare il prossimo move- TMouseEvent toonzEvent;- initToonzEvent(toonzEvent, event);- toonzEvent.m_pos = TPointD(m_lastMousePos.x(),- (double)(height() - 1) - m_lastMousePos.y());+ tool->setViewer(this);- TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);+ if (key == Qt::Key_Shift || key == Qt::Key_Control || key == Qt::Key_Alt ||+ key == Qt::Key_AltGr) {+ // quando l'utente preme shift/ctrl ecc. alcuni tool (es. pinch) devono+ // cambiare subito la forma del cursore, senza aspettare il prossimo move+ TMouseEvent toonzEvent;+ initToonzEvent(toonzEvent, event);+ toonzEvent.m_pos = TPointD(m_lastMousePos.x(),+ (double)(height() - 1) - m_lastMousePos.y());++ TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);++ TObjectHandle *objHandle = TApp::instance()->getCurrentObject();+ if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {+ pos.x /= m_dpiScale.x;+ pos.y /= m_dpiScale.y;+ }- TObjectHandle *objHandle = TApp::instance()->getCurrentObject();- if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {- pos.x /= m_dpiScale.x;- pos.y /= m_dpiScale.y;+ tool->mouseMove(pos, toonzEvent);+ setToolCursor(this, tool->getCursorId());}- tool->mouseMove(pos, toonzEvent);- setToolCursor(this, tool->getCursorId());- }+ if (key == Qt::Key_Menu || key == Qt::Key_Meta) return false;- bool shiftButton = QApplication::keyboardModifiers() == Qt::ShiftModifier;+ return tool->keyDown(event);+ }();- if (key == Qt::Key_Menu || key == Qt::Key_Meta) return;-- bool ret = false;- if (tool) // && m_toolEnabled)- ret = tool->keyDown(event);if (!ret) {+ if (changeFrameSkippingHolds(event)) return;+TFrameHandle *fh = TApp::instance()->getCurrentFrame();if (key == Qt::Key_Up || key == Qt::Key_Left)