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