Floating background and doubleclick selection fixed

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent a4fc469c88
commit cc9ddea6ae
  1. 5
      src/board/UBBoardView.cpp
  2. 25
      src/domain/UBGraphicsItemDelegate.cpp
  3. 4
      src/domain/UBGraphicsItemDelegate.h
  4. 5
      src/domain/UBGraphicsPixmapItem.cpp
  5. 3
      src/domain/UBGraphicsPixmapItem.h
  6. 5
      src/domain/UBGraphicsVideoItem.cpp

@ -421,8 +421,6 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
} }
else if (currentTool == UBStylusTool::Selector) else if (currentTool == UBStylusTool::Selector)
{ {
QSet<QGraphicsItem*> existingTools = scene()->tools();
movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint())); movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint()));
if (!movingItem if (!movingItem
@ -432,7 +430,8 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
|| movingItem->type() == UBGraphicsCompass::Type || movingItem->type() == UBGraphicsCompass::Type
|| movingItem->type() == UBGraphicsPDFItem::Type || movingItem->type() == UBGraphicsPDFItem::Type
|| movingItem->type() == UBGraphicsPolygonItem::Type || movingItem->type() == UBGraphicsPolygonItem::Type
|| movingItem->type() == UBGraphicsCache::Type) || movingItem->type() == UBGraphicsCache::Type
|| scene()->isBackgroundObject(movingItem))
{ {
movingItem = NULL; movingItem = NULL;
QGraphicsView::mousePressEvent (event); QGraphicsView::mousePressEvent (event);

@ -147,12 +147,7 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event) bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if(NULL != mMimeData) mDragStartPosition = event->pos();
{
QDrag* mDrag = new QDrag(event->widget());
mDrag->setMimeData(mMimeData);
mDrag->start();
}
startUndoStep(); startUndoStep();
@ -186,13 +181,27 @@ void UBGraphicsItemDelegate::setMimeData(QMimeData *mimeData)
bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event) bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if((NULL != mMimeData) && ((event->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance()))
{
QDrag* mDrag = new QDrag(event->widget());
mDrag->setMimeData(mMimeData);
if (!mDragPixmap.isNull()) {
mDrag->setPixmap(mDragPixmap);
mDrag->setHotSpot(mDragPixmap.rect().center());
}
mDrag->exec();
mDragPixmap = QPixmap();
return true;
}
if(isLocked()) if(isLocked())
{ {
event->accept(); event->accept();
return true; return true;
} }
else
return false; return true;
} }
bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event) bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event)

@ -129,6 +129,7 @@ class UBGraphicsItemDelegate : public QObject
QMimeData* mimeData(){ return mMimeData; } QMimeData* mimeData(){ return mMimeData; }
void setMimeData(QMimeData* mimeData); void setMimeData(QMimeData* mimeData);
void setDragPixmap(const QPixmap &pix) {mDragPixmap = pix;}
signals: signals:
void showOnDisplayChanged(bool shown); void showOnDisplayChanged(bool shown);
@ -174,12 +175,15 @@ private:
QPointF mOffset; QPointF mOffset;
QTransform mPreviousTransform; QTransform mPreviousTransform;
QPointF mPreviousPosition; QPointF mPreviousPosition;
QPointF mDragStartPosition;
qreal mPreviousZValue; qreal mPreviousZValue;
QSizeF mPreviousSize; QSizeF mPreviousSize;
bool mCanRotate; bool mCanRotate;
bool mCanDuplicate; bool mCanDuplicate;
bool mRespectRatio; bool mRespectRatio;
QMimeData* mMimeData; QMimeData* mMimeData;
QPixmap mDragPixmap;
}; };

@ -53,6 +53,11 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
QMimeData* pMime = new QMimeData(); QMimeData* pMime = new QMimeData();
pMime->setImageData(pixmap().toImage()); pMime->setImageData(pixmap().toImage());
mDelegate->setMimeData(pMime); mDelegate->setMimeData(pMime);
int k = pixmap().width() / 100;
QSize newSize(pixmap().width() / k, pixmap().height() / k);
mDelegate->setDragPixmap(pixmap().scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
if (mDelegate->mousePressEvent(event)) if (mDelegate->mousePressEvent(event))
{ {
//NOOP //NOOP

@ -62,9 +62,6 @@ protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
// UBGraphicsItemDelegate* mDelegate;
}; };
#endif /* UBGRAPHICSPIXMAPITEM_H_ */ #endif /* UBGRAPHICSPIXMAPITEM_H_ */

@ -109,11 +109,6 @@ void UBGraphicsVideoItem::showOnDisplayChanged(bool shown)
void UBGraphicsVideoItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsVideoItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
QDrag* mDrag = new QDrag(event->widget());
QMimeData* pMime = new QMimeData();
mDrag->setMimeData(pMime);
mDrag->start();
mShouldMove = (event->buttons() & Qt::LeftButton); mShouldMove = (event->buttons() & Qt::LeftButton);
mMousePressPos = event->scenePos(); mMousePressPos = event->scenePos();
mMouseMovePos = mMousePressPos; mMouseMovePos = mMousePressPos;

Loading…
Cancel
Save