Fix wheel event on windows
The mouse wheel event got triggered on multiple widgets at the same time, this will cause the rendered model been wrongly zoomed while the intention is resizing the nodes.master
parent
889c11ecef
commit
9b56ce2dd3
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
#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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue