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

fix bug 628: ruler effective after removal
more-line-styles
kaamui 3 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;
default:
if(UBDrawingController::drawingController()->mActiveRuler==NULL) {
if (UBDrawingController::drawingController()->activeRuler() == nullptr) {
viewport()->setCursor (QCursor (Qt::BlankCursor));
}
if (scene () && !mTabletStylusIsPressed) {

@ -34,6 +34,7 @@
#include "domain/UBGraphicsScene.h"
#include "board/UBBoardController.h"
#include "tools/UBAbstractDrawRuler.h"
#include "gui/UBMainWindow.h"
#include "core/memcheck.h"
@ -58,7 +59,6 @@ void UBDrawingController::destroy()
UBDrawingController::UBDrawingController(QObject * parent)
: QObject(parent)
, mActiveRuler(NULL)
, mStylusTool((UBStylusTool::Enum)-1)
, mLatestDrawingTool((UBStylusTool::Enum)-1)
, mIsDesktopMode(false)
@ -322,6 +322,23 @@ void UBDrawingController::setMarkerAlpha(qreal alpha)
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)
{

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

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

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

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

Loading…
Cancel
Save