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"
|
#include "graphicscontainerwidget.h"
|
||||||
|
|
||||||
GraphicsContainerWidget::GraphicsContainerWidget() :
|
GraphicsContainerWidget::GraphicsContainerWidget()
|
||||||
m_graphicsWidget(nullptr)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,11 +30,16 @@ void GraphicsContainerWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void GraphicsContainerWidget::wheelEvent(QWheelEvent *event)
|
void GraphicsContainerWidget::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
|
if (m_graphicsWidget) {
|
||||||
|
m_graphicsWidget->inputWheelEventFromOtherWidget(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_modelWidget)
|
if (m_modelWidget)
|
||||||
m_modelWidget->inputWheelEventFromOtherWidget(event);
|
m_modelWidget->inputWheelEventFromOtherWidget(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsContainerWidget::setGraphicsWidget(QWidget *graphicsWidget)
|
void GraphicsContainerWidget::setGraphicsWidget(SkeletonGraphicsWidget *graphicsWidget)
|
||||||
{
|
{
|
||||||
m_graphicsWidget = graphicsWidget;
|
m_graphicsWidget = graphicsWidget;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include "modelwidget.h"
|
#include "modelwidget.h"
|
||||||
|
#include "skeletongraphicswidget.h"
|
||||||
|
|
||||||
class GraphicsContainerWidget : public QWidget
|
class GraphicsContainerWidget : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -13,7 +14,7 @@ signals:
|
||||||
void containerSizeChanged(QSize size);
|
void containerSizeChanged(QSize size);
|
||||||
public:
|
public:
|
||||||
GraphicsContainerWidget();
|
GraphicsContainerWidget();
|
||||||
void setGraphicsWidget(QWidget *graphicsWidget);
|
void setGraphicsWidget(SkeletonGraphicsWidget *graphicsWidget);
|
||||||
void setModelWidget(ModelWidget *modelWidget);
|
void setModelWidget(ModelWidget *modelWidget);
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
@ -22,8 +23,8 @@ protected:
|
||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
void wheelEvent(QWheelEvent *event) override;
|
void wheelEvent(QWheelEvent *event) override;
|
||||||
private:
|
private:
|
||||||
QWidget *m_graphicsWidget = nullptr;
|
|
||||||
ModelWidget *m_modelWidget = nullptr;
|
ModelWidget *m_modelWidget = nullptr;
|
||||||
|
SkeletonGraphicsWidget *m_graphicsWidget = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -588,17 +588,21 @@ void SkeletonGraphicsWidget::mouseMoveEvent(QMouseEvent *event)
|
||||||
mouseMove(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)
|
void SkeletonGraphicsWidget::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (!wheel(event)) {
|
if (!wheel(event)) {
|
||||||
if (m_modelWidget && m_modelWidget->inputWheelEventFromOtherWidget(event))
|
if (m_modelWidget && m_modelWidget->inputWheelEventFromOtherWidget(event))
|
||||||
return;
|
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)
|
void SkeletonGraphicsWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
|
|
@ -410,6 +410,7 @@ public:
|
||||||
bool hasTwoDisconnectedNodesSelection();
|
bool hasTwoDisconnectedNodesSelection();
|
||||||
void setModelWidget(ModelWidget *modelWidget);
|
void setModelWidget(ModelWidget *modelWidget);
|
||||||
void setNodePositionModifyOnly(bool nodePositionModifyOnly);
|
void setNodePositionModifyOnly(bool nodePositionModifyOnly);
|
||||||
|
bool inputWheelEventFromOtherWidget(QWheelEvent *event);
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
void wheelEvent(QWheelEvent *event) override;
|
void wheelEvent(QWheelEvent *event) override;
|
||||||
|
|
Loading…
Reference in New Issue