@ -660,6 +660,7 @@ bool UBGraphicsScene::inputDeviceRelease()
void UBGraphicsScene : : drawEraser ( const QPointF & pPoint , bool pressed )
void UBGraphicsScene : : drawEraser ( const QPointF & pPoint , bool pressed )
{
{
if ( mEraser ) {
qreal eraserWidth = UBSettings : : settings ( ) - > currentEraserWidth ( ) ;
qreal eraserWidth = UBSettings : : settings ( ) - > currentEraserWidth ( ) ;
eraserWidth / = UBApplication : : boardController - > systemScaleFactor ( ) ;
eraserWidth / = UBApplication : : boardController - > systemScaleFactor ( ) ;
eraserWidth / = UBApplication : : boardController - > currentZoom ( ) ;
eraserWidth / = UBApplication : : boardController - > currentZoom ( ) ;
@ -667,7 +668,6 @@ void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool pressed)
qreal eraserRadius = eraserWidth / 2 ;
qreal eraserRadius = eraserWidth / 2 ;
// TODO UB 4.x optimize - no need to do that every time we move it
// 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 ) ) ;
mEraser - > setRect ( QRectF ( pPoint . x ( ) - eraserRadius , pPoint . y ( ) - eraserRadius , eraserWidth , eraserWidth ) ) ;
redrawEraser ( pressed ) ;
redrawEraser ( pressed ) ;
}
}
@ -676,11 +676,14 @@ void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool pressed)
void UBGraphicsScene : : redrawEraser ( bool pressed )
void UBGraphicsScene : : redrawEraser ( bool pressed )
{
{
if ( mEraser ) {
if ( mEraser ) {
QPen pen = mEraser - > pen ( ) ;
if ( pressed )
if ( pressed )
mEraser - > setPen ( QPen ( Qt : : SolidLine ) ) ;
pen . setStyle ( Qt : : SolidLine ) ;
else
else
mEraser - > setPen ( QPen ( Qt : : DotLine ) ) ;
pen . setStyle ( Qt : : DotLine ) ;
mEraser - > setPen ( pen ) ;
mEraser - > show ( ) ;
mEraser - > show ( ) ;
}
}
}
}
@ -947,20 +950,8 @@ void UBGraphicsScene::setBackground(bool pIsDark, bool pIsCrossed)
{
{
mDarkBackground = pIsDark ;
mDarkBackground = pIsDark ;
if ( mEraser )
updateEraserColor ( mDarkBackground ) ;
{
updateMarkerCircleColor ( mDarkBackground ) ;
if ( mDarkBackground )
{
mEraser - > setBrush ( UBSettings : : eraserBrushDarkBackground ) ;
mEraser - > setPen ( UBSettings : : eraserPenDarkBackground ) ;
}
else
{
mEraser - > setBrush ( UBSettings : : eraserBrushLightBackground ) ;
mEraser - > setPen ( UBSettings : : eraserPenLightBackground ) ;
}
}
recolorAllItems ( ) ;
recolorAllItems ( ) ;
needRepaint = true ;
needRepaint = true ;
@ -2534,6 +2525,8 @@ void UBGraphicsScene::createEraiser()
mEraser - > setRect ( QRect ( 0 , 0 , 0 , 0 ) ) ;
mEraser - > setRect ( QRect ( 0 , 0 , 0 , 0 ) ) ;
mEraser - > setVisible ( false ) ;
mEraser - > setVisible ( false ) ;
updateEraserColor ( mDarkBackground ) ;
mEraser - > setData ( UBGraphicsItemData : : ItemLayerType , QVariant ( UBItemLayerType : : Control ) ) ;
mEraser - > setData ( UBGraphicsItemData : : ItemLayerType , QVariant ( UBItemLayerType : : Control ) ) ;
mEraser - > setData ( UBGraphicsItemData : : itemLayerType , QVariant ( itemLayerType : : Eraiser ) ) ; //Necessary to set if we want z value to be assigned correctly
mEraser - > setData ( UBGraphicsItemData : : itemLayerType , QVariant ( itemLayerType : : Eraiser ) ) ; //Necessary to set if we want z value to be assigned correctly
@ -2566,7 +2559,8 @@ void UBGraphicsScene::createMarkerCircle()
mMarkerCircle - > setRect ( QRect ( 0 , 0 , 0 , 0 ) ) ;
mMarkerCircle - > setRect ( QRect ( 0 , 0 , 0 , 0 ) ) ;
mMarkerCircle - > setVisible ( false ) ;
mMarkerCircle - > setVisible ( false ) ;
mMarkerCircle - > setPen ( Qt : : DotLine ) ; // TODO: set line color to black on white, or white on black
mMarkerCircle - > setPen ( Qt : : DotLine ) ;
updateMarkerCircleColor ( mDarkBackground ) ;
mMarkerCircle - > setData ( UBGraphicsItemData : : ItemLayerType , QVariant ( UBItemLayerType : : Control ) ) ;
mMarkerCircle - > setData ( UBGraphicsItemData : : ItemLayerType , QVariant ( UBItemLayerType : : Control ) ) ;
mMarkerCircle - > setData ( UBGraphicsItemData : : itemLayerType , QVariant ( itemLayerType : : Eraiser ) ) ;
mMarkerCircle - > setData ( UBGraphicsItemData : : itemLayerType , QVariant ( itemLayerType : : Eraiser ) ) ;
@ -2576,6 +2570,44 @@ void UBGraphicsScene::createMarkerCircle()
}
}
}
}
void UBGraphicsScene : : updateEraserColor ( bool darkBackground )
{
if ( ! mEraser )
return ;
if ( darkBackground ) {
mEraser - > setBrush ( UBSettings : : eraserBrushDarkBackground ) ;
mEraser - > setPen ( UBSettings : : eraserPenDarkBackground ) ;
}
else {
mEraser - > setBrush ( UBSettings : : eraserBrushLightBackground ) ;
mEraser - > setPen ( UBSettings : : eraserPenLightBackground ) ;
}
}
void UBGraphicsScene : : updateMarkerCircleColor ( bool darkBackground )
{
if ( ! mMarkerCircle )
return ;
QBrush mcBrush = mMarkerCircle - > brush ( ) ;
QPen mcPen = mMarkerCircle - > pen ( ) ;
if ( darkBackground ) {
mcBrush . setColor ( UBSettings : : markerCircleBrushColorDarkBackground ) ;
mcPen . setColor ( UBSettings : : markerCirclePenColorDarkBackground ) ;
}
else {
mcBrush . setColor ( UBSettings : : markerCircleBrushColorLightBackground ) ;
mcPen . setColor ( UBSettings : : markerCirclePenColorLightBackground ) ;
}
mMarkerCircle - > setBrush ( mcBrush ) ;
mMarkerCircle - > setPen ( mcPen ) ;
}
void UBGraphicsScene : : setToolCursor ( int tool )
void UBGraphicsScene : : setToolCursor ( int tool )
{
{
if ( tool = = ( int ) UBStylusTool : : Selector | |
if ( tool = = ( int ) UBStylusTool : : Selector | |