ui: Fixed scrolling broken in graph view
This commit is contained in:
@@ -103,11 +103,6 @@ void QtGraphicsView::ensureVisibleAnimated(const QRectF& rect, int xmargin, int
|
||||
move->start();
|
||||
}
|
||||
|
||||
void QtGraphicsView::setMouseWheelCallback(const std::function<void(QWheelEvent*)>& callback)
|
||||
{
|
||||
m_mouseWheelCallback = callback;
|
||||
}
|
||||
|
||||
void QtGraphicsView::updateZoom(float delta)
|
||||
{
|
||||
float factor = 1.0f + 0.001f * delta;
|
||||
@@ -213,7 +208,20 @@ void QtGraphicsView::keyReleaseEvent(QKeyEvent* event)
|
||||
|
||||
void QtGraphicsView::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
m_mouseWheelCallback(event);
|
||||
bool zoomDefault = ApplicationSettings::getInstance()->getControlsGraphZoomOnMouseWheel();
|
||||
bool shiftPressed = event->modifiers() == Qt::ShiftModifier;
|
||||
|
||||
if (zoomDefault != shiftPressed)
|
||||
{
|
||||
if (event->delta() != 0.0f)
|
||||
{
|
||||
updateZoom(event->delta());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QGraphicsView::wheelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef QT_GRAPHICS_VIEW_H
|
||||
#define QT_GRAPHICS_VIEW_H
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <QGraphicsView>
|
||||
@@ -26,7 +25,6 @@ public:
|
||||
|
||||
void ensureVisibleAnimated(const QRectF& rect, int xmargin = 50, int ymargin = 50);
|
||||
|
||||
void setMouseWheelCallback(const std::function<void(QWheelEvent*)>& callback);
|
||||
void updateZoom(float delta);
|
||||
|
||||
protected:
|
||||
@@ -73,8 +71,6 @@ private:
|
||||
|
||||
QAction* m_exportGraphAction;
|
||||
QAction* m_copyNodeNameAction;
|
||||
|
||||
std::function<void(QWheelEvent*)> m_mouseWheelCallback;
|
||||
};
|
||||
|
||||
#endif // QT_GRAPHICS_VIEW_H
|
||||
|
||||
@@ -72,8 +72,6 @@ void QtGraphView::initView()
|
||||
view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||
view->viewport()->setCursor(Qt::ArrowCursor);
|
||||
|
||||
getView()->setMouseWheelCallback(std::bind(&QtGraphView::onMouseWheelEvent, this, std::placeholders::_1));
|
||||
|
||||
widget->layout()->addWidget(view);
|
||||
|
||||
m_zoomInButton = new QPushButton(widget);
|
||||
@@ -178,24 +176,6 @@ void QtGraphView::zoomOutPressed()
|
||||
zoom(m_zoomOutButtonSpeed);
|
||||
}
|
||||
|
||||
void QtGraphView::onMouseWheelEvent(QWheelEvent* event)
|
||||
{
|
||||
bool zoomDefault = ApplicationSettings::getInstance()->getControlsGraphZoomOnMouseWheel();
|
||||
bool shiftPressed = event->modifiers() == Qt::ShiftModifier;
|
||||
|
||||
if (zoomDefault != shiftPressed)
|
||||
{
|
||||
if (event->delta() != 0.0f)
|
||||
{
|
||||
zoom(event->delta());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// QGraphicsView::wheelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphView::switchToNewGraphData()
|
||||
{
|
||||
m_oldGraph = m_graph;
|
||||
|
||||
@@ -58,8 +58,6 @@ private slots:
|
||||
void zoomInPressed();
|
||||
void zoomOutPressed();
|
||||
|
||||
void onMouseWheelEvent(QWheelEvent* event);
|
||||
|
||||
private:
|
||||
void switchToNewGraphData();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user