Merge branch 'release-candidate' of https://github.com/Sankore/Sankore-3.1 into release-candidate

Conflicts:
	src/tools/UBGraphicsRuler.cpp
preferencesAboutTextFull
shibakaneki 12 years ago
commit 47844ccf93
  1. 7
      src/adaptors/publishing/UBDocumentPublisher.cpp
  2. 9
      src/board/UBBoardController.cpp
  3. 6
      src/board/UBBoardView.cpp
  4. 1
      src/frameworks/UBFileSystemUtils.cpp
  5. 39
      src/tools/UBGraphicsCompass.cpp
  6. 2
      src/tools/UBGraphicsCompass.h
  7. 216
      src/tools/UBGraphicsRuler.cpp

@ -62,7 +62,6 @@ UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *pa
, mPassword("") , mPassword("")
, bLoginCookieSet(false) , bLoginCookieSet(false)
{ {
//NOOP
init(); init();
} }
@ -109,7 +108,7 @@ void UBDocumentPublisher::buildUbwFile()
if (UBFileSystemUtils::copyDir(mSourceDocument->persistencePath(), tmpDir)) if (UBFileSystemUtils::copyDir(mSourceDocument->persistencePath(), tmpDir))
{ {
QUuid publishingUuid = QUuid::createUuid(); QString documentName = mSourceDocument->name();
mPublishingPath = tmpDir; mPublishingPath = tmpDir;
mPublishingSize = mSourceDocument->pageCount(); mPublishingSize = mSourceDocument->pageCount();
@ -120,11 +119,11 @@ void UBDocumentPublisher::buildUbwFile()
UBExportFullPDF pdfExporter; UBExportFullPDF pdfExporter;
pdfExporter.setVerbode(false); pdfExporter.setVerbode(false);
pdfExporter.persistsDocument(mSourceDocument, mPublishingPath + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".pdf"); pdfExporter.persistsDocument(mSourceDocument, mPublishingPath + "/" + documentName + ".pdf");
UBExportDocument ubzExporter; UBExportDocument ubzExporter;
ubzExporter.setVerbode(false); ubzExporter.setVerbode(false);
ubzExporter.persistsDocument(mSourceDocument, mPublishingPath + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".ubz"); ubzExporter.persistsDocument(mSourceDocument, mPublishingPath + "/" + documentName + ".ubz");
// remove all useless files // remove all useless files

@ -2364,10 +2364,17 @@ void UBBoardController::togglePodcast(bool checked)
void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget) void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget)
{ {
mActiveScene->setURStackEnable(false); mActiveScene->setURStackEnable(false);
UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget));
UBGraphicsWidgetItem *copyedGraphicsWidget = NULL;
if (UBGraphicsWidgetItem::Type == toolW3C->type())
copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C);
UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget, mControlView);
graphicsWidget->remove(false); graphicsWidget->remove(false);
mActiveScene->addItemToDeletion(graphicsWidget); mActiveScene->addItemToDeletion(graphicsWidget);
UBToolWidget *toolWidget = new UBToolWidget(graphicsWidget, mControlView);
mActiveScene->setURStackEnable(true); mActiveScene->setURStackEnable(true);
QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center()); QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());

@ -866,6 +866,7 @@ 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();
@ -1099,6 +1100,11 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
if (currentTool == UBStylusTool::Selector) if (currentTool == UBStylusTool::Selector)
{ {
bool bReleaseIsNeed = true; bool bReleaseIsNeed = true;
if (movingItem != determineItemToPress(scene()->itemAt(this->mapToScene(event->posF().toPoint()))))
{
movingItem = NULL;
bReleaseIsNeed = false;
}
if (mWidgetMoved) if (mWidgetMoved)
{ {
mWidgetMoved = false; mWidgetMoved = false;

@ -397,7 +397,6 @@ QString UBFileSystemUtils::lastPathComponent(const QString& path)
QString UBFileSystemUtils::mimeTypeFromFileName(const QString& fileName) QString UBFileSystemUtils::mimeTypeFromFileName(const QString& fileName)
{ {
Q_ASSERT(fileName.length());
QString ext = extension(fileName); QString ext = extension(fileName);
if (ext == "xls" || ext == "xlsx") return "application/msexcel"; if (ext == "xls" || ext == "xlsx") return "application/msexcel";

@ -51,6 +51,13 @@ UBGraphicsCompass::UBGraphicsCompass()
, mDrewCenterCross(false) , mDrewCenterCross(false)
{ {
setRect(sDefaultRect); setRect(sDefaultRect);
setBrush(QBrush(Qt::red));
//TODO claudio: remove code duplication
QDesktopWidget* desktop = UBApplication::desktop();
int dpiCommon = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2;
mPixelsPerMillimeter = qRound(dpiCommon / 25.4f);
setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -68,7 +75,7 @@ UBGraphicsCompass::UBGraphicsCompass()
updateResizeCursor(); updateResizeCursor();
updateDrawCursor(); updateDrawCursor();
unsetCursor(); unsetCursor();
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false); setFlag(QGraphicsItem::ItemIsSelectable, false);
@ -179,9 +186,9 @@ QVariant UBGraphicsCompass::itemChange(GraphicsItemChange change, const QVariant
void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector &&
UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
if (resizeButtonRect().contains(event->pos())) if (resizeButtonRect().contains(event->pos()))
{ {
@ -216,9 +223,9 @@ void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCompass::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCompass::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector &&
UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
if (!mResizing && !mRotating && !mDrawing) if (!mResizing && !mRotating && !mDrawing)
{ {
@ -261,9 +268,9 @@ void UBGraphicsCompass::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector &&
UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
if (mResizing) if (mResizing)
{ {
@ -302,9 +309,9 @@ void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCompass::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsCompass::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector &&
UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
mOuterCursor = cursor(); mOuterCursor = cursor();
mShowButtons = shape().contains(event->pos()); mShowButtons = shape().contains(event->pos());
@ -332,9 +339,9 @@ void UBGraphicsCompass::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void UBGraphicsCompass::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsCompass::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector &&
UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
mShowButtons = false; mShowButtons = false;
mCloseSvgItem->setVisible(mShowButtons); mCloseSvgItem->setVisible(mShowButtons);
@ -346,9 +353,9 @@ void UBGraphicsCompass::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void UBGraphicsCompass::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsCompass::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector &&
UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
mShowButtons = shape().contains(event->pos()); mShowButtons = shape().contains(event->pos());
mCloseSvgItem->setVisible(mShowButtons); mCloseSvgItem->setVisible(mShowButtons);
@ -399,7 +406,7 @@ void UBGraphicsCompass::paintAngleDisplay(QPainter *painter)
void UBGraphicsCompass::paintRadiusDisplay(QPainter *painter) void UBGraphicsCompass::paintRadiusDisplay(QPainter *painter)
{ {
qreal radiusInCentimeters = rect().width() / (sPixelsPerMillimeter * 10); qreal radiusInCentimeters = rect().width() / (mPixelsPerMillimeter * 10);
QString format = rect().width() >= sDisplayRadiusUnitMinLength ? "%1 cm" : "%1"; QString format = rect().width() >= sDisplayRadiusUnitMinLength ? "%1 cm" : "%1";
QString radiusText = QString(format).arg(radiusInCentimeters, 0, 'f', 1); QString radiusText = QString(format).arg(radiusInCentimeters, 0, 'f', 1);
@ -557,10 +564,10 @@ void UBGraphicsCompass::paintCenterCross()
QPointF needleCrossCenter = mapToScene(needlePosition()); QPointF needleCrossCenter = mapToScene(needlePosition());
scene()->moveTo(QPointF(needleCrossCenter.x() - 5, needleCrossCenter.y())); scene()->moveTo(QPointF(needleCrossCenter.x() - 5, needleCrossCenter.y()));
scene()->drawLineTo(QPointF(needleCrossCenter.x() + 5, needleCrossCenter.y()), 1, scene()->drawLineTo(QPointF(needleCrossCenter.x() + 5, needleCrossCenter.y()), 1,
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line); UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
scene()->moveTo(QPointF(needleCrossCenter.x(), needleCrossCenter.y() - 5)); scene()->moveTo(QPointF(needleCrossCenter.x(), needleCrossCenter.y() - 5));
scene()->drawLineTo(QPointF(needleCrossCenter.x(), needleCrossCenter.y() + 5), 1, scene()->drawLineTo(QPointF(needleCrossCenter.x(), needleCrossCenter.y() + 5), 1,
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line); UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
} }
QPointF UBGraphicsCompass::needlePosition() const QPointF UBGraphicsCompass::needlePosition() const

@ -113,6 +113,7 @@ class UBGraphicsCompass: public QObject, public QGraphicsRectItem, public UBItem
QGraphicsSvgItem* mResizeSvgItem; QGraphicsSvgItem* mResizeSvgItem;
qreal mAntiScaleRatio; qreal mAntiScaleRatio;
bool mDrewCenterCross; bool mDrewCenterCross;
int mPixelsPerMillimeter;
// Constants // Constants
static const QRect sDefaultRect; static const QRect sDefaultRect;
@ -130,7 +131,6 @@ class UBGraphicsCompass: public QObject, public QGraphicsRectItem, public UBItem
static const QColor sDarkBackgroundEdgeFillColor; static const QColor sDarkBackgroundEdgeFillColor;
static const QColor sDarkBackgroundMiddleFillColor; static const QColor sDarkBackgroundMiddleFillColor;
static const QColor sDarkBackgroundDrawColor; static const QColor sDarkBackgroundDrawColor;
static const int sPixelsPerMillimeter = 5;
static const int sDisplayRadiusOnPencilArmMinLength = 300; static const int sDisplayRadiusOnPencilArmMinLength = 300;
static const int sDisplayRadiusUnitMinLength = 250; static const int sDisplayRadiusUnitMinLength = 250;
}; };

@ -29,12 +29,12 @@ const QRect UBGraphicsRuler::sDefaultRect = QRect(0, 0, 800, 96);
UBGraphicsRuler::UBGraphicsRuler() UBGraphicsRuler::UBGraphicsRuler()
: QGraphicsRectItem() : QGraphicsRectItem()
, mResizing(false) , mResizing(false)
, mRotating(false) , mRotating(false)
{ {
setRect(sDefaultRect); setRect(sDefaultRect);
mResizeSvgItem = new QGraphicsSvgItem(":/images/resizeRuler.svg", this); mResizeSvgItem = new QGraphicsSvgItem(":/images/resizeRuler.svg", this);
mResizeSvgItem->setVisible(false); mResizeSvgItem->setVisible(false);
mResizeSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mResizeSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
@ -42,7 +42,7 @@ UBGraphicsRuler::UBGraphicsRuler()
mRotateSvgItem->setVisible(false); mRotateSvgItem->setVisible(false);
mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
create(*this); create(*this);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
@ -98,9 +98,9 @@ void UBGraphicsRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *s
Q_UNUSED(styleOption); Q_UNUSED(styleOption);
Q_UNUSED(widget); Q_UNUSED(widget);
UBAbstractDrawRuler::paint(); UBAbstractDrawRuler::paint();
QTransform antiScaleTransform2; QTransform antiScaleTransform2;
qreal ratio = mAntiScaleRatio > 1.0 ? mAntiScaleRatio : 1.0; qreal ratio = mAntiScaleRatio > 1.0 ? mAntiScaleRatio : 1.0;
antiScaleTransform2.scale(ratio, 1.0); antiScaleTransform2.scale(ratio, 1.0);
@ -269,28 +269,28 @@ QRectF UBGraphicsRuler::rotateButtonRect() const
void UBGraphicsRuler::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsRuler::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play) if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play)
{ {
mCloseSvgItem->setVisible(mShowButtons); mCloseSvgItem->setVisible(mShowButtons);
mResizeSvgItem->setVisible(mShowButtons); mResizeSvgItem->setVisible(mShowButtons);
mRotateSvgItem->setVisible(mShowButtons); mRotateSvgItem->setVisible(mShowButtons);
if (resizeButtonRect().contains(event->pos())) if (resizeButtonRect().contains(event->pos()))
setCursor(resizeCursor()); setCursor(resizeCursor());
else if (closeButtonRect().contains(event->pos())) else if (closeButtonRect().contains(event->pos()))
setCursor(closeCursor()); setCursor(closeCursor());
else if (rotateButtonRect().contains(event->pos())) else if (rotateButtonRect().contains(event->pos()))
setCursor(rotateCursor()); setCursor(rotateCursor());
else else
setCursor(moveCursor()); setCursor(moveCursor());
event->accept(); event->accept();
} }
else if (UBDrawingController::drawingController()->isDrawingTool()) else if (UBDrawingController::drawingController()->isDrawingTool())
{ {
event->accept(); event->accept();
} }
} }
void UBGraphicsRuler::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsRuler::mousePressEvent(QGraphicsSceneMouseEvent *event)
@ -309,7 +309,7 @@ void UBGraphicsRuler::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
mResizeSvgItem->setVisible(false); mResizeSvgItem->setVisible(false);
mRotateSvgItem->setVisible(false); mRotateSvgItem->setVisible(false);
QGraphicsItem::mousePressEvent(event); QGraphicsItem::mousePressEvent(event);
} }
mResizeSvgItem->setVisible(mShowButtons && mResizing); mResizeSvgItem->setVisible(mShowButtons && mResizing);
mRotateSvgItem->setVisible(mShowButtons && mRotating); mRotateSvgItem->setVisible(mShowButtons && mRotating);
@ -320,20 +320,20 @@ void UBGraphicsRuler::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (!mResizing && !mRotating) if (!mResizing && !mRotating)
{ {
QGraphicsItem::mouseMoveEvent(event); QGraphicsItem::mouseMoveEvent(event);
} }
else else
{ {
if (mResizing) if (mResizing)
{ {
QPointF delta = event->pos() - event->lastPos(); QPointF delta = event->pos() - event->lastPos();
if (rect().width() + delta.x() < sMinLength) if (rect().width() + delta.x() < sMinLength)
delta.setX(sMinLength - rect().width()); delta.setX(sMinLength - rect().width());
if (rect().width() + delta.x() > sMaxLength) if (rect().width() + delta.x() > sMaxLength)
delta.setX(sMaxLength - rect().width()); delta.setX(sMaxLength - rect().width());
setRect(QRectF(rect().topLeft(), QSizeF(rect().width() + delta.x(), rect().height()))); setRect(QRectF(rect().topLeft(), QSizeF(rect().width() + delta.x(), rect().height())));
} }
else else
{ {
@ -362,13 +362,13 @@ void UBGraphicsRuler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
} }
else if (closeButtonRect().contains(event->pos())) else if (closeButtonRect().contains(event->pos()))
{ {
hide(); hide();
emit hidden(); emit hidden();
event->accept(); event->accept();
} }
else else
{ {
QGraphicsItem::mouseReleaseEvent(event); QGraphicsItem::mouseReleaseEvent(event);
} }
if (scene()) if (scene())
@ -377,41 +377,41 @@ void UBGraphicsRuler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector || if (currentTool == UBStylusTool::Selector ||
currentTool == UBStylusTool::Play) currentTool == UBStylusTool::Play)
{ {
mCloseSvgItem->setParentItem(this); mCloseSvgItem->setParentItem(this);
mResizeSvgItem->setParentItem(this); mResizeSvgItem->setParentItem(this);
mRotateSvgItem->setParentItem(this); mRotateSvgItem->setParentItem(this);
mShowButtons = true; mShowButtons = true;
mCloseSvgItem->setVisible(mShowButtons); mCloseSvgItem->setVisible(mShowButtons);
mResizeSvgItem->setVisible(mShowButtons); mResizeSvgItem->setVisible(mShowButtons);
mRotateSvgItem->setVisible(mShowButtons); mRotateSvgItem->setVisible(mShowButtons);
if (event->pos().x() >= resizeButtonRect().left()) if (event->pos().x() >= resizeButtonRect().left())
{ {
setCursor(resizeCursor()); setCursor(resizeCursor());
} }
else else
{ {
if (closeButtonRect().contains(event->pos())) if (closeButtonRect().contains(event->pos()))
setCursor(closeCursor()); setCursor(closeCursor());
else if (rotateButtonRect().contains(event->pos())) else if (rotateButtonRect().contains(event->pos()))
setCursor(rotateCursor()); setCursor(rotateCursor());
else else
setCursor(moveCursor()); setCursor(moveCursor());
} }
event->accept(); event->accept();
update(); update();
} }
else if (UBDrawingController::drawingController()->isDrawingTool()) else if (UBDrawingController::drawingController()->isDrawingTool())
{ {
setCursor(drawRulerLineCursor()); setCursor(drawRulerLineCursor());
UBDrawingController::drawingController()->mActiveRuler = this; UBDrawingController::drawingController()->mActiveRuler = this;
event->accept(); event->accept();
} }
} }
void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
@ -421,7 +421,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 = NULL; UBDrawingController::drawingController()->mActiveRuler = NULL;
event->accept(); event->accept();
update(); update();
} }
@ -435,28 +435,28 @@ UBGraphicsScene* UBGraphicsRuler::scene() const
void UBGraphicsRuler::StartLine(const QPointF& scenePos, qreal width) void UBGraphicsRuler::StartLine(const QPointF& scenePos, qreal width)
{ {
QPointF itemPos = mapFromScene(scenePos); QPointF itemPos = mapFromScene(scenePos);
qreal y; qreal y;
if (itemPos.y() > rect().y() + rect().height() / 2) if (itemPos.y() > rect().y() + rect().height() / 2)
{ {
drawLineDirection = 0; drawLineDirection = 0;
y = rect().y() + rect().height() + width / 2; y = rect().y() + rect().height() + width / 2;
} }
else else
{ {
drawLineDirection = 1; drawLineDirection = 1;
y = rect().y() - width /2; y = rect().y() - width /2;
} }
if (itemPos.x() < rect().x() + sLeftEdgeMargin) if (itemPos.x() < rect().x() + sLeftEdgeMargin)
itemPos.setX(rect().x() + sLeftEdgeMargin); itemPos.setX(rect().x() + sLeftEdgeMargin);
if (itemPos.x() > rect().x() + rect().width() - sLeftEdgeMargin) if (itemPos.x() > rect().x() + rect().width() - sLeftEdgeMargin)
itemPos.setX(rect().x() + rect().width() - sLeftEdgeMargin); itemPos.setX(rect().x() + rect().width() - sLeftEdgeMargin);
itemPos.setY(y); itemPos.setY(y);
itemPos = mapToScene(itemPos); itemPos = mapToScene(itemPos);
scene()->moveTo(itemPos); scene()->moveTo(itemPos);
scene()->drawLineTo(itemPos, width, true); scene()->drawLineTo(itemPos, width, true);
@ -464,26 +464,26 @@ void UBGraphicsRuler::StartLine(const QPointF& scenePos, qreal width)
void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width) void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width)
{ {
QPointF itemPos = mapFromScene(scenePos); QPointF itemPos = mapFromScene(scenePos);
qreal y; qreal y;
if (drawLineDirection == 0) if (drawLineDirection == 0)
{ {
y = rect().y() + rect().height() + width / 2; y = rect().y() + rect().height() + width / 2;
} }
else else
{ {
y = rect().y() - width /2; y = rect().y() - width /2;
} }
if (itemPos.x() < rect().x() + sLeftEdgeMargin) if (itemPos.x() < rect().x() + sLeftEdgeMargin)
itemPos.setX(rect().x() + sLeftEdgeMargin); itemPos.setX(rect().x() + sLeftEdgeMargin);
if (itemPos.x() > rect().x() + rect().width() - sLeftEdgeMargin) if (itemPos.x() > rect().x() + rect().width() - sLeftEdgeMargin)
itemPos.setX(rect().x() + rect().width() - sLeftEdgeMargin); itemPos.setX(rect().x() + rect().width() - sLeftEdgeMargin);
itemPos.setY(y); itemPos.setY(y);
itemPos = mapToScene(itemPos); itemPos = mapToScene(itemPos);
// We have to use "pointed" line for marker tool // We have to use "pointed" line for marker tool
scene()->drawLineTo(itemPos, width, UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker); scene()->drawLineTo(itemPos, width, UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker);
} }

Loading…
Cancel
Save