1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Compare commits

..

2 Commits

Author SHA1 Message Date
imonlyfourteen
1fb7448afd
Merge 9bb04d7154 into 74cf139b01 2024-06-04 11:34:47 +00:00
imonlyfourteen
9bb04d7154
Add middle mouse button drag in the GraphView
Handle middle mouse button in `mouseMoveEvent()` (new) and `mousePressEvent()` methods.

(Removed preprocessor conditions; deprecated QMouseEvent::pos() / QMouseEvent::x() were chosen.)
2024-06-04 11:34:44 +00:00

View File

@ -346,11 +346,7 @@ void GraphView::mouseMoveEvent(QMouseEvent *e)
{
if (e->buttons() & Qt::MiddleButton) {
QScrollBar *sb = horizontalScrollBar();
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
int x = e->x();
#else // QT 5.15
int x = e->position().toPoint().x();
#endif // QT 5.15
sb->setSliderPosition(sb->sliderPosition() - (x - _xStartDrag));
_xStartDrag = x;
}
@ -360,17 +356,10 @@ void GraphView::mouseMoveEvent(QMouseEvent *e)
void GraphView::mousePressEvent(QMouseEvent *e)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
if (e->button() == Qt::LeftButton)
newSliderPosition(mapToScene(e->pos()));
else if (e->button() == Qt::MiddleButton)
_xStartDrag = e->x();
#else // QT 5.15
if (e->button() == Qt::LeftButton)
newSliderPosition(mapToScene(e->position().toPoint()));
else if (e->button() == Qt::MiddleButton)
_xStartDrag = e->position().toPoint().x();
#endif // QT 5.15
QGraphicsView::mousePressEvent(e);
}