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
- Toggle ScrollHandDrag mode by clicking a middle mouse button.
- Added horizontal scrolling by pressiong Shift + mouse wheel.
- [#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.

View File

@ -80,14 +80,6 @@ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *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)
{
if (mousePress->button() & Qt::LeftButton)
switch (mousePress->button())
{
switch (QGuiApplication::keyboardModifiers())
case Qt::LeftButton:
{
case Qt::ControlModifier:
QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag);
break;
case Qt::NoModifier:
if (showToolOptions)
QGraphicsView::setDragMode(QGraphicsView::RubberBandDrag);
if (showToolOptions)
{
QList<QGraphicsItem *> list = items(mousePress->pos());
if (list.size() == 0)
{
QList<QGraphicsItem *> list = items(mousePress->pos());
if (list.size() == 0)
emit itemClicked(nullptr);
break;
}
for (int i = 0; i < list.size(); ++i)
{
if (this->scene()->items().contains(list.at(i)))
{
emit itemClicked(nullptr);
break;
}
for (int i = 0; i < list.size(); ++i)
{
if (this->scene()->items().contains(list.at(i)))
if (list.at(i)->type() <= VSimplePoint::Type &&
list.at(i)->type() > QGraphicsItem::UserType)
{
if (list.at(i)->type() <= VSimplePoint::Type &&
list.at(i)->type() > QGraphicsItem::UserType)
{
emit itemClicked(list.at(i));
break;
}
else
{
emit itemClicked(nullptr);
}
emit itemClicked(list.at(i));
break;
}
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);
}
@ -431,7 +437,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event)
{
QGraphicsView::mouseReleaseEvent ( event );
QGraphicsView::setDragMode( QGraphicsView::RubberBandDrag );
QGraphicsView::setDragMode( QGraphicsView::NoDrag );
if (event->button() == Qt::LeftButton)
{
emit MouseRelease();