Commit cc9ddea6 authored by Ivan Ilin's avatar Ivan Ilin

Floating background and doubleclick selection fixed

parent a4fc469c
......@@ -421,8 +421,6 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
}
else if (currentTool == UBStylusTool::Selector)
{
QSet<QGraphicsItem*> existingTools = scene()->tools();
movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint()));
if (!movingItem
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment