Merge pull request #629 from letsfindaway/628-bug-ruler

fix bug 628: ruler effective after removal
more-line-styles
kaamui 2 years ago committed by GitHub
commit db5f03fe28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/board/UBBoardView.cpp
  2. 19
      src/board/UBDrawingController.cpp
  3. 4
      src/board/UBDrawingController.h
  4. 12
      src/domain/UBGraphicsScene.cpp
  5. 6
      src/tools/UBGraphicsRuler.cpp
  6. 4
      src/tools/UBGraphicsTriangle.cpp

@ -1104,7 +1104,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
break; break;
default: default:
if(UBDrawingController::drawingController()->mActiveRuler==NULL) { if (UBDrawingController::drawingController()->activeRuler() == nullptr) {
viewport()->setCursor (QCursor (Qt::BlankCursor)); viewport()->setCursor (QCursor (Qt::BlankCursor));
} }
if (scene () && !mTabletStylusIsPressed) { if (scene () && !mTabletStylusIsPressed) {

@ -34,6 +34,7 @@
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "tools/UBAbstractDrawRuler.h"
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -58,7 +59,6 @@ void UBDrawingController::destroy()
UBDrawingController::UBDrawingController(QObject * parent) UBDrawingController::UBDrawingController(QObject * parent)
: QObject(parent) : QObject(parent)
, mActiveRuler(NULL)
, mStylusTool((UBStylusTool::Enum)-1) , mStylusTool((UBStylusTool::Enum)-1)
, mLatestDrawingTool((UBStylusTool::Enum)-1) , mLatestDrawingTool((UBStylusTool::Enum)-1)
, mIsDesktopMode(false) , mIsDesktopMode(false)
@ -322,6 +322,23 @@ void UBDrawingController::setMarkerAlpha(qreal alpha)
emit colorPaletteChanged(); emit colorPaletteChanged();
} }
void UBDrawingController::setActiveRuler(UBAbstractDrawRuler* ruler)
{
mActiveRuler = ruler;
}
UBAbstractDrawRuler* UBDrawingController::activeRuler() const
{
QGraphicsItem* item = dynamic_cast<QGraphicsItem*>(mActiveRuler.data());
if (item && item->isVisible())
{
return mActiveRuler;
}
return nullptr;
}
void UBDrawingController::penToolSelected(bool checked) void UBDrawingController::penToolSelected(bool checked)
{ {

@ -64,7 +64,8 @@ class UBDrawingController : public QObject
void setMarkerColor(bool onDarkBackground, const QColor& color, int pIndex); void setMarkerColor(bool onDarkBackground, const QColor& color, int pIndex);
void setMarkerAlpha(qreal alpha); void setMarkerAlpha(qreal alpha);
UBAbstractDrawRuler* mActiveRuler; void setActiveRuler(UBAbstractDrawRuler* ruler);
UBAbstractDrawRuler* activeRuler() const;
void setInDesktopMode(bool mode){ void setInDesktopMode(bool mode){
mIsDesktopMode = mode; mIsDesktopMode = mode;
@ -89,6 +90,7 @@ class UBDrawingController : public QObject
void colorIndexChanged(int index); void colorIndexChanged(int index);
private: private:
QPointer<UBAbstractDrawRuler> mActiveRuler;
UBStylusTool::Enum mStylusTool; UBStylusTool::Enum mStylusTool;
UBStylusTool::Enum mLatestDrawingTool; UBStylusTool::Enum mLatestDrawingTool;
bool mIsDesktopMode; bool mIsDesktopMode;

@ -451,8 +451,8 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
mAddedItems.clear(); mAddedItems.clear();
mRemovedItems.clear(); mRemovedItems.clear();
if (UBDrawingController::drawingController()->mActiveRuler) if (UBDrawingController::drawingController()->activeRuler())
UBDrawingController::drawingController()->mActiveRuler->StartLine(scenePos, width); UBDrawingController::drawingController()->activeRuler()->StartLine(scenePos, width);
else { else {
moveTo(scenePos); moveTo(scenePos);
drawLineTo(scenePos, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line); drawLineTo(scenePos, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
@ -539,7 +539,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
width /= UBApplication::boardController->systemScaleFactor(); width /= UBApplication::boardController->systemScaleFactor();
width /= UBApplication::boardController->currentZoom(); width /= UBApplication::boardController->currentZoom();
if (currentTool == UBStylusTool::Line || dc->mActiveRuler) if (currentTool == UBStylusTool::Line || dc->activeRuler())
{ {
if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker) if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker)
if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){ if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){
@ -573,8 +573,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
if (!mCurrentStroke) if (!mCurrentStroke)
mCurrentStroke = new UBGraphicsStroke(this); mCurrentStroke = new UBGraphicsStroke(this);
if(dc->mActiveRuler){ if(dc->activeRuler()){
dc->mActiveRuler->DrawLine(position, width); dc->activeRuler()->DrawLine(position, width);
} }
else if (currentTool == UBStylusTool::Line) { else if (currentTool == UBStylusTool::Line) {
@ -859,7 +859,7 @@ void UBGraphicsScene::drawPenCircle(const QPointF &pPoint)
cursor = UBResources::resources()->penCursor; cursor = UBResources::resources()->penCursor;
} }
if (!UBDrawingController::drawingController()->mActiveRuler) if (!UBDrawingController::drawingController()->activeRuler())
{ {
// set cursor only if no active ruler // set cursor only if no active ruler
if (controlView() && controlView()->viewport()) if (controlView() && controlView()->viewport())

@ -420,9 +420,6 @@ void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (UBDrawingController::drawingController()->mActiveRuler == nullptr)
UBDrawingController::drawingController()->mActiveRuler = this;
if (currentTool == UBStylusTool::Selector || if (currentTool == UBStylusTool::Selector ||
currentTool == UBStylusTool::Play) currentTool == UBStylusTool::Play)
{ {
@ -453,6 +450,7 @@ void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
else if (UBDrawingController::drawingController()->isDrawingTool()) else if (UBDrawingController::drawingController()->isDrawingTool())
{ {
setCursor(drawRulerLineCursor()); setCursor(drawRulerLineCursor());
UBDrawingController::drawingController()->setActiveRuler(this);
event->accept(); event->accept();
} }
} }
@ -464,7 +462,7 @@ void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
mCloseSvgItem->setVisible(mShowButtons); mCloseSvgItem->setVisible(mShowButtons);
mResizeSvgItem->setVisible(mShowButtons); mResizeSvgItem->setVisible(mShowButtons);
mRotateSvgItem->setVisible(mShowButtons); mRotateSvgItem->setVisible(mShowButtons);
UBDrawingController::drawingController()->mActiveRuler = nullptr; UBDrawingController::drawingController()->setActiveRuler(nullptr);
event->accept(); event->accept();
update(); update();
} }

@ -886,7 +886,7 @@ void UBGraphicsTriangle::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
} else if (UBDrawingController::drawingController()->isDrawingTool()) { } else if (UBDrawingController::drawingController()->isDrawingTool()) {
setCursor(drawRulerLineCursor()); setCursor(drawRulerLineCursor());
UBDrawingController::drawingController()->mActiveRuler = this; UBDrawingController::drawingController()->setActiveRuler(this);
event->accept(); event->accept();
} }
@ -904,7 +904,7 @@ void UBGraphicsTriangle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
mVFlipSvgItem->setVisible(false); mVFlipSvgItem->setVisible(false);
mHFlipSvgItem->setVisible(false); mHFlipSvgItem->setVisible(false);
mRotateSvgItem->setVisible(false); mRotateSvgItem->setVisible(false);
UBDrawingController::drawingController()->mActiveRuler = NULL; UBDrawingController::drawingController()->setActiveRuler(nullptr);
event->accept(); event->accept();
update(); update();
} }

Loading…
Cancel
Save