diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 670ee9e3..2d2d29cc 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -1691,9 +1691,14 @@ void UBBoardView::setToolCursor (int tool) controlViewport->setCursor (UBResources::resources ()->penCursor); break; case UBStylusTool::Eraser: + { controlViewport->setCursor (UBResources::resources ()->eraserCursor); - scene()->hideEraser(); + UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); + if (currentTool != UBStylusTool::Eraser) + // Avoid hiding the eraser after a click with the eraser + scene()->hideEraser(); break; + } case UBStylusTool::Marker: controlViewport->setCursor (UBResources::resources ()->markerCursor); break; diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 27bd0560..83d480d8 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -424,7 +424,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre eraserWidth /= UBApplication::boardController->currentZoom(); eraseLineTo(scenePos, eraserWidth); - drawEraser(scenePos, true); + drawEraser(scenePos, mInputDeviceIsPressed); accepted = true; } @@ -453,7 +453,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres if (currentTool == UBStylusTool::Eraser) { - drawEraser(position); + drawEraser(position, mInputDeviceIsPressed); accepted = true; } @@ -541,6 +541,12 @@ bool UBGraphicsScene::inputDeviceRelease() accepted = true; } + UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); + + if (currentTool == UBStylusTool::Eraser) + redrawEraser(false); + + UBDrawingController *dc = UBDrawingController::drawingController(); if (dc->isDrawingTool() || mDrawWithCompass) @@ -624,7 +630,7 @@ bool UBGraphicsScene::inputDeviceRelease() return accepted; } -void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw) +void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool pressed) { qreal eraserWidth = UBSettings::settings()->currentEraserWidth(); eraserWidth /= UBApplication::boardController->systemScaleFactor(); @@ -635,10 +641,19 @@ void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw) // TODO UB 4.x optimize - no need to do that every time we move it if (mEraser) { mEraser->setRect(QRectF(pPoint.x() - eraserRadius, pPoint.y() - eraserRadius, eraserWidth, eraserWidth)); + redrawEraser(pressed); + } +} - if(isFirstDraw) { - mEraser->show(); - } +void UBGraphicsScene::redrawEraser(bool pressed) +{ + if (mEraser) { + if(pressed) + mEraser->setPen(QPen(Qt::SolidLine)); + else + mEraser->setPen(QPen(Qt::DotLine)); + + mEraser->show(); } } diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h index a114d06c..9a3f009d 100644 --- a/src/domain/UBGraphicsScene.h +++ b/src/domain/UBGraphicsScene.h @@ -359,7 +359,8 @@ public slots: void initPolygonItem(UBGraphicsPolygonItem*); - void drawEraser(const QPointF& pEndPoint, bool isFirstDraw = false); + void drawEraser(const QPointF& pEndPoint, bool pressed = true); + void redrawEraser(bool pressed); void drawPointer(const QPointF& pEndPoint, bool isFirstDraw = false); void DisposeMagnifierQWidgets(); diff --git a/src/gui/UBResources.cpp b/src/gui/UBResources.cpp index 5a974873..9402e238 100644 --- a/src/gui/UBResources.cpp +++ b/src/gui/UBResources.cpp @@ -65,7 +65,7 @@ void UBResources::init() { // Cursors penCursor = QCursor(Qt::CrossCursor); - eraserCursor = QCursor(QPixmap(":/images/cursors/eraser.png"), 21, 21); + eraserCursor = QCursor(QPixmap(":/images/cursors/eraser.png"), 5, 25); markerCursor = QCursor(QPixmap(":/images/cursors/marker.png"), 3, 30); pointerCursor = QCursor(QPixmap(":/images/cursors/laser.png"), 2, 1); handCursor = QCursor(Qt::OpenHandCursor);