|
|
|
@ -973,7 +973,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mMouseDownPos = event->pos (); |
|
|
|
|
|
|
|
|
|
movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint())); |
|
|
|
|
|
|
|
|
|
if (!movingItem) |
|
|
|
@ -981,30 +980,29 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) |
|
|
|
|
|
|
|
|
|
if (event->button () == Qt::LeftButton && isInteractive()) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); |
|
|
|
|
|
|
|
|
|
int currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); |
|
|
|
|
if (!mTabletStylusIsPressed) |
|
|
|
|
mMouseButtonIsPressed = true; |
|
|
|
|
|
|
|
|
|
if (currentTool == UBStylusTool::ZoomIn) |
|
|
|
|
{ |
|
|
|
|
switch (currentTool) { |
|
|
|
|
case UBStylusTool::ZoomIn : |
|
|
|
|
mController->zoomIn (mapToScene (event->pos ())); |
|
|
|
|
event->accept(); |
|
|
|
|
} |
|
|
|
|
else if (currentTool == UBStylusTool::ZoomOut) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case UBStylusTool::ZoomOut : |
|
|
|
|
mController->zoomOut (mapToScene (event->pos ())); |
|
|
|
|
event->accept(); |
|
|
|
|
} |
|
|
|
|
else if (currentTool == UBStylusTool::Hand) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case UBStylusTool::Hand : |
|
|
|
|
viewport()->setCursor(QCursor (Qt::ClosedHandCursor)); |
|
|
|
|
mPreviousPoint = event->posF(); |
|
|
|
|
event->accept(); |
|
|
|
|
} |
|
|
|
|
else if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case UBStylusTool::Selector : |
|
|
|
|
case UBStylusTool::Play : |
|
|
|
|
if (bIsDesktop) { |
|
|
|
|
event->ignore(); |
|
|
|
|
return; |
|
|
|
@ -1019,26 +1017,26 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) |
|
|
|
|
|
|
|
|
|
if (!movingItem) { |
|
|
|
|
// Rubberband selection implementation
|
|
|
|
|
if (!mUBRubberBand) { |
|
|
|
|
mUBRubberBand = new UBRubberBand(QRubberBand::Rectangle, this); |
|
|
|
|
// if (!mUBRubberBand) {
|
|
|
|
|
// mUBRubberBand = new UBRubberBand(QRubberBand::Rectangle, this);
|
|
|
|
|
// }
|
|
|
|
|
// mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
|
|
|
|
|
// mUBRubberBand->show();
|
|
|
|
|
// scene()->updateMultipleSelectionFrame();
|
|
|
|
|
scene()->clearSelectionFrame(); |
|
|
|
|
} |
|
|
|
|
mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); |
|
|
|
|
mUBRubberBand->show(); |
|
|
|
|
scene()->setMultipleSelectionProcess(true); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if(mUBRubberBand) { |
|
|
|
|
mUBRubberBand->hide(); |
|
|
|
|
scene()->setMultipleSelectionProcess(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleItemMousePress(event); |
|
|
|
|
event->accept(); |
|
|
|
|
} |
|
|
|
|
else if (currentTool == UBStylusTool::Text) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case UBStylusTool::Text : { |
|
|
|
|
int frameWidth = UBSettings::settings ()->objectFrameWidth; |
|
|
|
|
QRectF fuzzyRect (0, 0, frameWidth * 4, frameWidth * 4); |
|
|
|
|
fuzzyRect.moveCenter (mapToScene (mMouseDownPos)); |
|
|
|
@ -1065,13 +1063,12 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) |
|
|
|
|
mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); |
|
|
|
|
mRubberBand->show(); |
|
|
|
|
mIsCreatingTextZone = true; |
|
|
|
|
scene()->setMultipleSelectionProcess(true); |
|
|
|
|
|
|
|
|
|
event->accept (); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (currentTool == UBStylusTool::Capture) |
|
|
|
|
{ |
|
|
|
|
} break; |
|
|
|
|
|
|
|
|
|
case UBStylusTool::Capture : |
|
|
|
|
scene ()->deselectAllItems (); |
|
|
|
|
|
|
|
|
|
if (!mRubberBand) |
|
|
|
@ -1083,18 +1080,15 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) |
|
|
|
|
scene()->setMultipleSelectionProcess(true); |
|
|
|
|
|
|
|
|
|
event->accept (); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if(UBDrawingController::drawingController()->mActiveRuler==NULL) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
if(UBDrawingController::drawingController()->mActiveRuler==NULL) { |
|
|
|
|
viewport()->setCursor (QCursor (Qt::BlankCursor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (scene () && !mTabletStylusIsPressed) |
|
|
|
|
{ |
|
|
|
|
if (currentTool == UBStylusTool::Eraser) |
|
|
|
|
{ |
|
|
|
|
if (scene () && !mTabletStylusIsPressed) { |
|
|
|
|
if (currentTool == UBStylusTool::Eraser) { |
|
|
|
|
connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent())); |
|
|
|
|
mLongPressTimer.start(); |
|
|
|
|
} |
|
|
|
@ -1114,51 +1108,65 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QTime mouseMoveTime = QTime::currentTime(); |
|
|
|
|
if(!mIsDragInProgress && ((mapToScene(event->pos()) - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())) |
|
|
|
|
{ |
|
|
|
|
if(!mIsDragInProgress |
|
|
|
|
&& ((mapToScene(event->pos()) - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())) { |
|
|
|
|
qDebug() << "mouse move event canceled"; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mIsDragInProgress = true; |
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); |
|
|
|
|
|
|
|
|
|
mWidgetMoved = true; |
|
|
|
|
mLongPressTimer.stop(); |
|
|
|
|
|
|
|
|
|
if (isAbsurdPoint (event->pos ())) |
|
|
|
|
{ |
|
|
|
|
if (isAbsurdPoint (event->pos ())) { |
|
|
|
|
event->accept (); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (currentTool == UBStylusTool::Hand && (mMouseButtonIsPressed || mTabletStylusIsPressed)) |
|
|
|
|
{ |
|
|
|
|
if ((UBDrawingController::drawingController()->isDrawingTool()) |
|
|
|
|
&& !mMouseButtonIsPressed) { |
|
|
|
|
QGraphicsView::mouseMoveEvent(event); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int currentTool = static_cast<int>(UBDrawingController::drawingController()->stylusTool()); |
|
|
|
|
switch (currentTool) { |
|
|
|
|
|
|
|
|
|
case UBStylusTool::Hand : { |
|
|
|
|
if (!mMouseButtonIsPressed && mTabletStylusIsPressed) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
QPointF eventPosition = event->posF (); |
|
|
|
|
qreal dx = eventPosition.x () - mPreviousPoint.x (); |
|
|
|
|
qreal dy = eventPosition.y () - mPreviousPoint.y (); |
|
|
|
|
mController->handScroll (dx, dy); |
|
|
|
|
mPreviousPoint = eventPosition; |
|
|
|
|
event->accept (); |
|
|
|
|
} |
|
|
|
|
else if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play) |
|
|
|
|
{ |
|
|
|
|
if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} break; |
|
|
|
|
|
|
|
|
|
case UBStylusTool::Selector : |
|
|
|
|
case UBStylusTool::Play : { |
|
|
|
|
if (bIsDesktop) { |
|
|
|
|
event->ignore(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (currentTool != UBStylusTool::Play || mRubberBandInPlayMode) { |
|
|
|
|
|
|
|
|
|
if (!movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed) && mUBRubberBand && mUBRubberBand->isVisible()) { |
|
|
|
|
bool rubberMove = currentTool != (UBStylusTool::Play || mRubberBandInPlayMode) |
|
|
|
|
&& (mMouseButtonIsPressed || mTabletStylusIsPressed) |
|
|
|
|
&& !movingItem; |
|
|
|
|
|
|
|
|
|
if (rubberMove) { |
|
|
|
|
QRect bandRect(mMouseDownPos, event->pos()); |
|
|
|
|
|
|
|
|
|
bandRect = bandRect.normalized(); |
|
|
|
|
|
|
|
|
|
if (!mUBRubberBand) { |
|
|
|
|
mUBRubberBand = new UBRubberBand(QRubberBand::Rectangle, this); |
|
|
|
|
} |
|
|
|
|
// mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
|
|
|
|
|
mUBRubberBand->setGeometry(bandRect); |
|
|
|
|
mUBRubberBand->show(); |
|
|
|
|
scene()->setMultipleSelectionProcess(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTime startTime = QTime::currentTime(); |
|
|
|
|
QTime testTime = QTime::currentTime(); |
|
|
|
@ -1203,38 +1211,28 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event) |
|
|
|
|
<< "| =elapsed time " << startTime.msecsTo(QTime::currentTime()) << endl |
|
|
|
|
<< "=================="; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleItemMouseMove(event); |
|
|
|
|
} |
|
|
|
|
else if ((UBDrawingController::drawingController()->isDrawingTool()) |
|
|
|
|
&& !mMouseButtonIsPressed) |
|
|
|
|
{ |
|
|
|
|
QGraphicsView::mouseMoveEvent (event); |
|
|
|
|
} |
|
|
|
|
else if (currentTool == UBStylusTool::Text || currentTool == UBStylusTool::Capture) |
|
|
|
|
{ |
|
|
|
|
if (mRubberBand && (mIsCreatingTextZone || mIsCreatingSceneGrabZone)) |
|
|
|
|
{ |
|
|
|
|
} break; |
|
|
|
|
|
|
|
|
|
case UBStylusTool::Text : |
|
|
|
|
case UBStylusTool::Capture : { |
|
|
|
|
if (mRubberBand |
|
|
|
|
&& (mIsCreatingTextZone || mIsCreatingSceneGrabZone)) { |
|
|
|
|
mRubberBand->setGeometry(QRect(mMouseDownPos, event->pos()).normalized()); |
|
|
|
|
event->accept(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
QGraphicsView::mouseMoveEvent (event); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (!mTabletStylusIsPressed && scene ()) |
|
|
|
|
{ |
|
|
|
|
scene ()->inputDeviceMove (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ())), mMouseButtonIsPressed); |
|
|
|
|
} break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
if (!mTabletStylusIsPressed && scene()) { |
|
|
|
|
scene()->inputDeviceMove(mapToScene(UBGeometryUtils::pointConstrainedInRect(event->pos(), rect())) |
|
|
|
|
, mMouseButtonIsPressed); |
|
|
|
|
} |
|
|
|
|
event->accept (); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) |
|
|
|
|
mWidgetMoved = true; |
|
|
|
|
qDebug() << "mouse move time" << mouseMoveTime.msecsTo(QTime::currentTime()); |
|
|
|
|
lastCallTime = QTime::currentTime(); |
|
|
|
|
} |
|
|
|
|