mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
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.)
This commit is contained in:
parent
e09f4d47cd
commit
9bb04d7154
@ -346,11 +346,7 @@ void GraphView::mouseMoveEvent(QMouseEvent *e)
|
|||||||
{
|
{
|
||||||
if (e->buttons() & Qt::MiddleButton) {
|
if (e->buttons() & Qt::MiddleButton) {
|
||||||
QScrollBar *sb = horizontalScrollBar();
|
QScrollBar *sb = horizontalScrollBar();
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
|
||||||
int x = e->x();
|
int x = e->x();
|
||||||
#else // QT 5.15
|
|
||||||
int x = e->position().toPoint().x();
|
|
||||||
#endif // QT 5.15
|
|
||||||
sb->setSliderPosition(sb->sliderPosition() - (x - _xStartDrag));
|
sb->setSliderPosition(sb->sliderPosition() - (x - _xStartDrag));
|
||||||
_xStartDrag = x;
|
_xStartDrag = x;
|
||||||
}
|
}
|
||||||
@ -360,17 +356,10 @@ void GraphView::mouseMoveEvent(QMouseEvent *e)
|
|||||||
|
|
||||||
void GraphView::mousePressEvent(QMouseEvent *e)
|
void GraphView::mousePressEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
|
||||||
if (e->button() == Qt::LeftButton)
|
if (e->button() == Qt::LeftButton)
|
||||||
newSliderPosition(mapToScene(e->pos()));
|
newSliderPosition(mapToScene(e->pos()));
|
||||||
else if (e->button() == Qt::MiddleButton)
|
else if (e->button() == Qt::MiddleButton)
|
||||||
_xStartDrag = e->x();
|
_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);
|
QGraphicsView::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user