diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 30fcdcfb..2acedc64 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -2041,10 +2041,15 @@ void UBBoardController::togglePodcast(bool checked) void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget) { - graphicsWidget->remove(); + QPointF controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center()); + graphicsWidget->hide(); UBToolWidget *toolWidget = new UBToolWidget(graphicsWidget); mActiveScene->addItem(toolWidget); + qreal ssf = 1 / UBApplication::boardController->systemScaleFactor(); + + toolWidget->scale(ssf, ssf); + toolWidget->setPos(graphicsWidget->scenePos()); } diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index f1ded872..5dccc8ff 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -378,28 +378,13 @@ void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible) void UBGraphicsItemDelegate::remove(bool canUndo) { -// QGraphicsScene* scene = mDelegated->scene(); UBGraphicsScene* scene = dynamic_cast(mDelegated->scene()); - if (scene) + if (scene && canUndo) { - foreach(DelegateButton* button, mButtons) - scene->removeItem(button); - - scene->removeItem(mFrame); - - /* this is performed because when removing delegated from scene while it contains flash content, segfault happens because of QGraphicsScene::removeItem() */ - UBGraphicsWebView *mDelegated_casted = dynamic_cast(mDelegated); - if (mDelegated_casted) - mDelegated_casted->setHtml(QString()); - - scene->removeItem(mDelegated); - - if (canUndo) - { - UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand(scene, mDelegated, 0); - UBApplication::undoStack->push(uc); - } - } + UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand(scene, mDelegated, 0); + UBApplication::undoStack->push(uc); + } + mDelegated->hide(); } diff --git a/src/frameworks/UBCoreGraphicsScene.cpp b/src/frameworks/UBCoreGraphicsScene.cpp index 8c526a65..fd4948ec 100644 --- a/src/frameworks/UBCoreGraphicsScene.cpp +++ b/src/frameworks/UBCoreGraphicsScene.cpp @@ -32,7 +32,7 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene() //we must delete removed items that are no more in any scene foreach (const QGraphicsItem* item, mItemsToDelete) { - if (item && (item->scene() == NULL || item->scene() == this)) + if (item->scene() == NULL || item->scene() == this) { delete item; } diff --git a/src/gui/UBToolWidget.cpp b/src/gui/UBToolWidget.cpp index 665711c6..c6e0e9a8 100644 --- a/src/gui/UBToolWidget.cpp +++ b/src/gui/UBToolWidget.cpp @@ -61,8 +61,6 @@ UBToolWidget::UBToolWidget(UBGraphicsWidgetItem *pWidget, QGraphicsItem *pParent , mShouldMoveWidget(false) { mGraphicsWidgetItem = pWidget; - mGraphicsWidgetItem->setParent(this); - mGraphicsWidgetItem->loadMainHtml(); initialize(); @@ -129,6 +127,15 @@ void UBToolWidget::javaScriptWindowObjectCleared() } } +void UBToolWidget::setPos(const QPointF &point) +{ + UBToolWidget::setPos(point.x(), point.y()); +} + +void UBToolWidget::setPos(qreal x, qreal y) +{ + QGraphicsItem::setPos((x - mContentMargin)*scale(), (y - mContentMargin)*scale()); +} void UBToolWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { @@ -185,7 +192,7 @@ void UBToolWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (event->pos().x() >= 0 && event->pos().x() < sClosePixmap->width() && event->pos().y() >= 0 && event->pos().y() < sClosePixmap->height()) { - scene()->removeItem(this); + hide(); event->accept(); } else if (mGraphicsWidgetItem->canBeContent() && event->pos().x() >= mContentMargin && event->pos().x() < mContentMargin + sUnpinPixmap->width() diff --git a/src/gui/UBToolWidget.h b/src/gui/UBToolWidget.h index a56db78c..78bb2d0c 100644 --- a/src/gui/UBToolWidget.h +++ b/src/gui/UBToolWidget.h @@ -37,6 +37,8 @@ class UBToolWidget : public QGraphicsWidget UBGraphicsWidgetItem* graphicsWidgetItem() const; virtual UBGraphicsScene* scene(); + virtual void setPos(const QPointF &point); + virtual void setPos(qreal x, qreal y); protected: void initialize();