Fixed behavior of c++ tools.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent ac215755c3
commit c74c6cdc40
  1. 16
      src/board/UBBoardView.cpp
  2. 1
      src/board/UBBoardView.h
  3. 23
      src/tools/UBGraphicsCompass.cpp

@ -28,6 +28,7 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBSetting.h" #include "core/UBSetting.h"
#include "core/UBPersistenceManager.h" #include "core/UBPersistenceManager.h"
#include "core/UB.h"
#include "network/UBHttpGet.h" #include "network/UBHttpGet.h"
@ -446,6 +447,16 @@ bool UBBoardView::isUBItem(QGraphicsItem *item)
} }
} }
bool UBBoardView::isCppTool(QGraphicsItem *item)
{
return (item->type() == UBGraphicsItemType::CompassItemType
|| item->type() == UBGraphicsItemType::RulerItemType
|| item->type() == UBGraphicsItemType::ProtractorItemType
|| item->type() == UBGraphicsItemType::TriangleItemType
|| item->type() == UBGraphicsItemType::AristoItemType
|| item->type() == UBGraphicsItemType::CurtainItemType);
}
void UBBoardView::handleItemsSelection(QGraphicsItem *item) void UBBoardView::handleItemsSelection(QGraphicsItem *item)
{ {
// we need to select new pressed itemOnBoard and deselect all other items. // we need to select new pressed itemOnBoard and deselect all other items.
@ -1137,7 +1148,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
movingItem = NULL; movingItem = NULL;
} }
else else
if (movingItem) if (movingItem && !isCppTool(movingItem))
{ {
if (suspendedMousePressEvent) if (suspendedMousePressEvent)
{ {
@ -1153,7 +1164,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
DelegateButton::Type != movingItem->type() && DelegateButton::Type != movingItem->type() &&
QGraphicsSvgItem::Type != movingItem->type() && QGraphicsSvgItem::Type != movingItem->type() &&
UBGraphicsDelegateFrame::Type != movingItem->type() && UBGraphicsDelegateFrame::Type != movingItem->type() &&
// UBToolWidget::Type != movingItem->type() &&
UBGraphicsCache::Type != movingItem->type() && UBGraphicsCache::Type != movingItem->type() &&
QGraphicsWebView::Type != movingItem->type() && // for W3C widgets as Tools. QGraphicsWebView::Type != movingItem->type() && // for W3C widgets as Tools.
!(!isMultipleSelectionEnabled() && movingItem->parentItem() && UBGraphicsWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type())) !(!isMultipleSelectionEnabled() && movingItem->parentItem() && UBGraphicsWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type()))
@ -1175,6 +1185,8 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
} }
} }
} }
else
bReleaseIsNeed = true;
if (mUBRubberBand && mUBRubberBand->isVisible()) { if (mUBRubberBand && mUBRubberBand->isVisible()) {
mUBRubberBand->hide(); mUBRubberBand->hide();

@ -58,6 +58,7 @@ class UBBoardView : public QGraphicsView
bool itemIsLocked(QGraphicsItem *item); bool itemIsLocked(QGraphicsItem *item);
bool isUBItem(QGraphicsItem *item); // we should to determine items who is not UB and use general scene behavior for them. bool isUBItem(QGraphicsItem *item); // we should to determine items who is not UB and use general scene behavior for them.
bool isCppTool(QGraphicsItem *item);
void handleItemsSelection(QGraphicsItem *item); void handleItemsSelection(QGraphicsItem *item);
bool itemShouldReceiveMousePressEvent(QGraphicsItem *item); bool itemShouldReceiveMousePressEvent(QGraphicsItem *item);
bool itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item); bool itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item);

@ -188,20 +188,21 @@ void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event)
UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
bool closing = false;
if (resizeButtonRect().contains(event->pos())) if (resizeButtonRect().contains(event->pos()))
{ {
mResizing = true; mResizing = true;
mCloseSvgItem->setVisible(false); mRotating = false;
event->accept(); event->accept();
} }
else if (hingeRect().contains(event->pos())) else if (hingeRect().contains(event->pos()))
{ {
mRotating = true; mRotating = true;
mResizeSvgItem->setVisible(false); mResizing = false;
mCloseSvgItem->setVisible(false);
event->accept(); event->accept();
} }
else else if (!closeButtonRect().contains(event->pos()))
{ {
mDrawing = event->pos().x() > rect().right() - sPencilLength - sPencilBaseLength; mDrawing = event->pos().x() > rect().right() - sPencilLength - sPencilBaseLength;
if (mDrawing) if (mDrawing)
@ -211,12 +212,13 @@ void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event)
scene()->initStroke(); scene()->initStroke();
scene()->moveTo(mSceneArcStartPoint); scene()->moveTo(mSceneArcStartPoint);
} }
mResizeSvgItem->setVisible(false);
mCloseSvgItem->setVisible(false);
QGraphicsRectItem::mousePressEvent(event); QGraphicsRectItem::mousePressEvent(event);
} }
else
closing = true;
mResizeSvgItem->setVisible(mShowButtons && mResizing);
mCloseSvgItem->setVisible(mShowButtons && closing);
} }
void UBGraphicsCompass::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCompass::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
@ -272,19 +274,16 @@ void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (mResizing) if (mResizing)
{ {
mResizing = false;
event->accept(); event->accept();
} }
else if (mRotating) else if (mRotating)
{ {
mRotating = false;
updateResizeCursor(); updateResizeCursor();
updateDrawCursor(); updateDrawCursor();
event->accept(); event->accept();
} }
else if (mDrawing) else if (mDrawing)
{ {
mDrawing = false;
updateResizeCursor(); updateResizeCursor();
updateDrawCursor(); updateDrawCursor();
event->accept(); event->accept();
@ -300,6 +299,8 @@ void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
QGraphicsRectItem::mouseReleaseEvent(event); QGraphicsRectItem::mouseReleaseEvent(event);
} }
mResizing = false;
mDrawing = false;
if (scene()) if (scene())
scene()->setModified(true); scene()->setModified(true);

Loading…
Cancel
Save