Toggle ScrollHandDrag mode by clicking a middle mouse button.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-03-30 11:51:09 +03:00
parent 77c09063ff
commit 254ccf8f52
3 changed files with 36 additions and 37 deletions

View File

@ -1,4 +1,5 @@
# Version 0.5.0 # Version 0.5.0
- Toggle ScrollHandDrag mode by clicking a middle mouse button.
- Added horizontal scrolling by pressiong Shift + mouse wheel. - Added horizontal scrolling by pressiong Shift + mouse wheel.
- [#366] Update 'Point from Distance and Angle' tool to read distance and angle between points. - [#366] Update 'Point from Distance and Angle' tool to read distance and angle between points.
- [#395] Create Curve tool which uses point as control handle. - [#395] Create Curve tool which uses point as control handle.

View File

@ -80,14 +80,6 @@ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
QGraphicsScene::mousePressEvent(event); QGraphicsScene::mousePressEvent(event);
// if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier)
// {
// QList<QGraphicsItem *> items = selectedItems();
// for (int i=0; i< items.size(); i++)
// {
// items[i]->setSelected(false);
// }
// }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -382,14 +382,11 @@ void VMainGraphicsView::ZoomFitBest()
*/ */
void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
{ {
if (mousePress->button() & Qt::LeftButton) switch (mousePress->button())
{ {
switch (QGuiApplication::keyboardModifiers()) case Qt::LeftButton:
{ {
case Qt::ControlModifier: QGraphicsView::setDragMode(QGraphicsView::RubberBandDrag);
QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag);
break;
case Qt::NoModifier:
if (showToolOptions) if (showToolOptions)
{ {
QList<QGraphicsItem *> list = items(mousePress->pos()); QList<QGraphicsItem *> list = items(mousePress->pos());
@ -416,10 +413,19 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
} }
} }
break; break;
}
case Qt::MiddleButton:
{
QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag);
// create a new mouse event that simulates a click of the left button instead of the middle button
QMouseEvent mouseEvent (mousePress->type(), mousePress->pos(), Qt::LeftButton, Qt::LeftButton,
mousePress->modifiers());
QGraphicsView::mousePressEvent(&mouseEvent);
return;
}
default: default:
break; break;
} }
}
QGraphicsView::mousePressEvent(mousePress); QGraphicsView::mousePressEvent(mousePress);
} }
@ -431,7 +437,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event) void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event)
{ {
QGraphicsView::mouseReleaseEvent ( event ); QGraphicsView::mouseReleaseEvent ( event );
QGraphicsView::setDragMode( QGraphicsView::RubberBandDrag ); QGraphicsView::setDragMode( QGraphicsView::NoDrag );
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
{ {
emit MouseRelease(); emit MouseRelease();