Floating background and doubleclick selection fixed

preferencesAboutTextFull
Ivan Ilin 12 years ago
parent a4fc469c88
commit cc9ddea6ae
  1. 7
      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,9 +421,7 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
}
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
|| movingItem->isSelected()
@ -432,7 +430,8 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
|| movingItem->type() == UBGraphicsCompass::Type
|| movingItem->type() == UBGraphicsPDFItem::Type
|| movingItem->type() == UBGraphicsPolygonItem::Type
|| movingItem->type() == UBGraphicsCache::Type)
|| movingItem->type() == UBGraphicsCache::Type
|| scene()->isBackgroundObject(movingItem))
{
movingItem = NULL;
QGraphicsView::mousePressEvent (event);

@ -147,12 +147,7 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(NULL != mMimeData)
{
QDrag* mDrag = new QDrag(event->widget());
mDrag->setMimeData(mMimeData);
mDrag->start();
}
mDragStartPosition = event->pos();
startUndoStep();
@ -186,13 +181,27 @@ void UBGraphicsItemDelegate::setMimeData(QMimeData *mimeData)
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())
{
event->accept();
return true;
}
else
return false;
return true;
}
bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event)

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

@ -53,6 +53,11 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
QMimeData* pMime = new QMimeData();
pMime->setImageData(pixmap().toImage());
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))
{
//NOOP

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

@ -109,11 +109,6 @@ void UBGraphicsVideoItem::showOnDisplayChanged(bool shown)
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);
mMousePressPos = event->scenePos();
mMouseMovePos = mMousePressPos;

Loading…
Cancel
Save