diff --git a/toonz/sources/include/toonzqt/schematicviewer.h b/toonz/sources/include/toonzqt/schematicviewer.h index 37e3f57..2342355 100644 --- a/toonz/sources/include/toonzqt/schematicviewer.h +++ b/toonz/sources/include/toonzqt/schematicviewer.h @@ -124,6 +124,8 @@ class DVAPI SchematicSceneViewer final : public QGraphicsView { bool m_panning = false; double m_scaleFactor; // used for zoom gesture + bool m_stylusUsed = false; + CursorMode m_cursorMode; public: @@ -146,6 +148,7 @@ protected: void showEvent(QShowEvent *se) override; void mouseDoubleClickEvent(QMouseEvent *event); + void tabletEvent(QTabletEvent *e); void touchEvent(QTouchEvent *e, int type); void gestureEvent(QGestureEvent *e); diff --git a/toonz/sources/toonzqt/schematicviewer.cpp b/toonz/sources/toonzqt/schematicviewer.cpp index 46a8518..caf05df 100644 --- a/toonz/sources/toonzqt/schematicviewer.cpp +++ b/toonz/sources/toonzqt/schematicviewer.cpp @@ -217,7 +217,8 @@ SchematicSceneViewer::~SchematicSceneViewer() {} /*! Reimplemets the QGraphicsView::mousePressEvent() */ void SchematicSceneViewer::mousePressEvent(QMouseEvent *me) { - if (m_gestureActive && m_touchDevice == QTouchDevice::TouchScreen) { + if (m_gestureActive && m_touchDevice == QTouchDevice::TouchScreen && + !m_stylusUsed) { return; } @@ -257,7 +258,8 @@ void SchematicSceneViewer::mousePressEvent(QMouseEvent *me) { /*! Reimplemets the QGraphicsView::mouseMoveEvent() */ void SchematicSceneViewer::mouseMoveEvent(QMouseEvent *me) { - if (m_gestureActive && m_touchDevice == QTouchDevice::TouchScreen) { + if (m_gestureActive && m_touchDevice == QTouchDevice::TouchScreen && + !m_stylusUsed) { return; } @@ -284,16 +286,19 @@ void SchematicSceneViewer::mouseMoveEvent(QMouseEvent *me) { */ void SchematicSceneViewer::mouseReleaseEvent(QMouseEvent *me) { // for touchscreens but not touchpads... - if (m_gestureActive && m_touchDevice == QTouchDevice::TouchScreen) { + if (m_gestureActive && m_touchDevice == QTouchDevice::TouchScreen && + !m_stylusUsed) { m_gestureActive = false; m_zooming = false; m_panning = false; + m_stylusUsed = false; m_scaleFactor = 0.0; return; } m_zooming = false; m_panning = false; + m_stylusUsed = false; m_buttonState = Qt::NoButton; QGraphicsView::mouseReleaseEvent(me); @@ -304,7 +309,7 @@ void SchematicSceneViewer::mouseReleaseEvent(QMouseEvent *me) { //------------------------------------------------------------------ void SchematicSceneViewer::mouseDoubleClickEvent(QMouseEvent *event) { - if (m_gestureActive) { + if (m_gestureActive && !m_stylusUsed) { fitScene(); m_gestureActive = false; return; @@ -500,6 +505,18 @@ void SchematicSceneViewer::showEvent(QShowEvent *se) { //------------------------------------------------------------------ +void SchematicSceneViewer::tabletEvent(QTabletEvent *e) { + if (e->type() == QTabletEvent::TabletPress) { + m_stylusUsed = e->pointerType() ? true : false; + } else if (e->type() == QTabletEvent::TabletRelease) { + m_stylusUsed = false; + } + + e->accept(); +} + +//------------------------------------------------------------------ + void SchematicSceneViewer::touchEvent(QTouchEvent *e, int type) { if (type == QEvent::TouchBegin) { m_touchActive = true;