preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent bff3e8343d
commit ff90ddf3d7
  1. 58
      src/board/UBBoardView.cpp
  2. 6
      src/board/UBBoardView.h

@ -58,6 +58,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
, mIsCreatingTextZone (false)
, mIsCreatingSceneGrabZone (false)
, mOkOnWidget(false)
, suspendedMousePressEvent(NULL)
{
init ();
@ -67,6 +68,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent)
: QGraphicsView (pParent)
, mController (pController)
, suspendedMousePressEvent(NULL)
{
init ();
@ -78,6 +80,8 @@ UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int p
UBBoardView::~UBBoardView () {
//NOOP
if (suspendedMousePressEvent)
delete suspendedMousePressEvent;
}
void
@ -116,6 +120,9 @@ UBBoardView::init ()
settingChanged (QVariant ());
unsetCursor();
movingItem = NULL;
mWidgetMoved = false;
}
UBGraphicsScene*
@ -410,7 +417,28 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
}
else if (currentTool == UBStylusTool::Selector)
{
QGraphicsView::mousePressEvent (event);
movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint()));
if (!movingItem ||
movingItem->isSelected() ||
(movingItem->type() == UBGraphicsDelegateFrame::Type ||
movingItem->type() == DelegateButton::Type))
{
movingItem = NULL;
QGraphicsView::mousePressEvent (event);
}
else
{
mLastPressedMousePos = mapToScene(event->pos());
if (suspendedMousePressEvent)
{
delete suspendedMousePressEvent;
}
suspendedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers()); // óäàëèòü
}
event->accept();
}
else if (currentTool == UBStylusTool::Text)
{
@ -496,7 +524,20 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
}
else if (currentTool == UBStylusTool::Selector)
{
QGraphicsView::mouseMoveEvent (event);
if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) {
return;
}
if (movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed))
{
QPointF scenePos = mapToScene(event->pos());
QPointF newPos = movingItem->pos() + scenePos - mLastPressedMousePos;
movingItem->setPos(newPos);
mLastPressedMousePos = scenePos;
mWidgetMoved = true;
event->accept();
}
else QGraphicsView::mouseMoveEvent (event);
}
else if ((UBDrawingController::drawingController()->isDrawingTool())
&& !mMouseButtonIsPressed)
@ -539,6 +580,19 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
if (currentTool == UBStylusTool::Selector)
{
if (mWidgetMoved)
{
mWidgetMoved = false;
movingItem = NULL;
}
else if (movingItem && suspendedMousePressEvent)
{
QGraphicsView::mousePressEvent(suspendedMousePressEvent); // suspendedMousePressEvent is deleted by old Qt event loop
movingItem = NULL;
delete suspendedMousePressEvent;
suspendedMousePressEvent = NULL;
}
QGraphicsView::mouseReleaseEvent (event);
}
else if (currentTool == UBStylusTool::Text)

@ -18,6 +18,7 @@
#include <QtGui>
#include "core/UB.h"
#include "domain/UBGraphicsDelegateFrame.h"
class UBBoardController;
class UBAppleWidget;
@ -116,6 +117,11 @@ class UBBoardView : public QGraphicsView
bool mVirtualKeyboardActive;
bool mOkOnWidget;
bool mWidgetMoved;
QPointF mLastPressedMousePos;
QGraphicsItem *movingItem;
QMouseEvent *suspendedMousePressEvent;
private slots:
void settingChanged(QVariant newValue);

Loading…
Cancel
Save