diff --git a/src/graphicscontainerwidget.cpp b/src/graphicscontainerwidget.cpp index c9b9846e..b0aed1fd 100644 --- a/src/graphicscontainerwidget.cpp +++ b/src/graphicscontainerwidget.cpp @@ -1,7 +1,6 @@ #include "graphicscontainerwidget.h" -GraphicsContainerWidget::GraphicsContainerWidget() : - m_graphicsWidget(nullptr) +GraphicsContainerWidget::GraphicsContainerWidget() { } @@ -31,11 +30,16 @@ void GraphicsContainerWidget::mouseReleaseEvent(QMouseEvent *event) void GraphicsContainerWidget::wheelEvent(QWheelEvent *event) { + if (m_graphicsWidget) { + m_graphicsWidget->inputWheelEventFromOtherWidget(event); + return; + } + if (m_modelWidget) m_modelWidget->inputWheelEventFromOtherWidget(event); } -void GraphicsContainerWidget::setGraphicsWidget(QWidget *graphicsWidget) +void GraphicsContainerWidget::setGraphicsWidget(SkeletonGraphicsWidget *graphicsWidget) { m_graphicsWidget = graphicsWidget; } diff --git a/src/graphicscontainerwidget.h b/src/graphicscontainerwidget.h index cd0cbff5..987d158c 100644 --- a/src/graphicscontainerwidget.h +++ b/src/graphicscontainerwidget.h @@ -5,6 +5,7 @@ #include #include #include "modelwidget.h" +#include "skeletongraphicswidget.h" class GraphicsContainerWidget : public QWidget { @@ -13,7 +14,7 @@ signals: void containerSizeChanged(QSize size); public: GraphicsContainerWidget(); - void setGraphicsWidget(QWidget *graphicsWidget); + void setGraphicsWidget(SkeletonGraphicsWidget *graphicsWidget); void setModelWidget(ModelWidget *modelWidget); protected: void resizeEvent(QResizeEvent *event) override; @@ -22,8 +23,8 @@ protected: void mouseReleaseEvent(QMouseEvent *event) override; void wheelEvent(QWheelEvent *event) override; private: - QWidget *m_graphicsWidget = nullptr; ModelWidget *m_modelWidget = nullptr; + SkeletonGraphicsWidget *m_graphicsWidget = nullptr; }; #endif diff --git a/src/skeletongraphicswidget.cpp b/src/skeletongraphicswidget.cpp index 78201d31..59ea648c 100644 --- a/src/skeletongraphicswidget.cpp +++ b/src/skeletongraphicswidget.cpp @@ -588,17 +588,21 @@ void SkeletonGraphicsWidget::mouseMoveEvent(QMouseEvent *event) mouseMove(event); } +bool SkeletonGraphicsWidget::inputWheelEventFromOtherWidget(QWheelEvent *event) +{ + if (!wheel(event)) { + if (m_modelWidget && m_modelWidget->inputWheelEventFromOtherWidget(event)) + return true; + } + return true; +} + void SkeletonGraphicsWidget::wheelEvent(QWheelEvent *event) { if (!wheel(event)) { if (m_modelWidget && m_modelWidget->inputWheelEventFromOtherWidget(event)) return; } - - //if (SkeletonDocumentEditMode::ZoomIn == m_document->editMode || - // SkeletonDocumentEditMode::ZoomOut == m_document->editMode || - // SkeletonDocumentEditMode::Drag == m_document->editMode) - // QGraphicsView::wheelEvent(event); } void SkeletonGraphicsWidget::mouseReleaseEvent(QMouseEvent *event) diff --git a/src/skeletongraphicswidget.h b/src/skeletongraphicswidget.h index 38653eba..09fd2b92 100644 --- a/src/skeletongraphicswidget.h +++ b/src/skeletongraphicswidget.h @@ -410,6 +410,7 @@ public: bool hasTwoDisconnectedNodesSelection(); void setModelWidget(ModelWidget *modelWidget); void setNodePositionModifyOnly(bool nodePositionModifyOnly); + bool inputWheelEventFromOtherWidget(QWheelEvent *event); protected: void mouseMoveEvent(QMouseEvent *event) override; void wheelEvent(QWheelEvent *event) override;