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,43 +382,49 @@ 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); if (showToolOptions)
break; {
case Qt::NoModifier: QList<QGraphicsItem *> list = items(mousePress->pos());
if (showToolOptions) if (list.size() == 0)
{ {
QList<QGraphicsItem *> list = items(mousePress->pos()); emit itemClicked(nullptr);
if (list.size() == 0) break;
}
for (int i = 0; i < list.size(); ++i)
{
if (this->scene()->items().contains(list.at(i)))
{ {
emit itemClicked(nullptr); if (list.at(i)->type() <= VSimplePoint::Type &&
break; list.at(i)->type() > QGraphicsItem::UserType)
}
for (int i = 0; i < list.size(); ++i)
{
if (this->scene()->items().contains(list.at(i)))
{ {
if (list.at(i)->type() <= VSimplePoint::Type && emit itemClicked(list.at(i));
list.at(i)->type() > QGraphicsItem::UserType) break;
{ }
emit itemClicked(list.at(i)); else
break; {
} emit itemClicked(nullptr);
else
{
emit itemClicked(nullptr);
}
} }
} }
} }
break; }
default: 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:
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();