Commit bce67995 authored by Aleksei Kanash's avatar Aleksei Kanash

UBToolWidget is QWidget now. Implemented all expected behavior.

parent f9e12cc3
......@@ -2318,13 +2318,9 @@ void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* gr
{
mActiveScene->setURStackEnable(false);
graphicsWidget->remove(false);
UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget));
UBGraphicsWidgetItem *copyedGraphicsWidget = NULL;
mActiveScene->addItemToDeletion(graphicsWidget);
if (UBGraphicsWidgetItem::Type == toolW3C->type())
copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C);
UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget, mControlView);
UBToolWidget *toolWidget = new UBToolWidget(graphicsWidget, mControlView);
mActiveScene->setURStackEnable(true);
QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());
......@@ -2335,11 +2331,15 @@ void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* gr
void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget)
{
UBGraphicsWidgetItem *graphicsWidgetItem = addW3cWidget(toolWidget->toolWidget()->widgetUrl(), QPointF(0, 0));
graphicsWidgetItem->setPos(toolWidget->pos());
toolWidget->hide();
delete toolWidget;
graphicsWidgetItem->setSelected(true);
UBGraphicsWidgetItem *widgetToScene = toolWidget->toolWidget();
QPoint mainWindowCenter = toolWidget->mapTo(mMainWindow, QPoint(toolWidget->width(), toolWidget->height()) / 2);
QPoint controlViewCenter = mControlView->mapFrom(mMainWindow, mainWindowCenter);
QPointF scenePos = mControlView->mapToScene(controlViewCenter);
mActiveScene->addGraphicsWidget(widgetToScene, scenePos);
toolWidget->remove();
}
......
......@@ -1310,7 +1310,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
if (graphicsWidget->canBeContent())
{
// graphicsWidget->widgetWebView()->loadMainHtml();
graphicsWidget->loadMainHtml();
graphicsWidget->setSelected(true);
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
......
......@@ -222,6 +222,13 @@ QPoint UBToolWidget::naturalCenter() const
return QPoint(0, 0);
}
void UBToolWidget::remove()
{
mToolWidget = NULL;
hide();
deleteLater();
}
void UBToolWidget::centerOn(const QPoint& pos)
{
QWidget::move(pos - QPoint(width() / 2, height() / 2));
......
......@@ -32,6 +32,7 @@ class UBToolWidget : public QWidget
UBToolWidget(UBGraphicsWidgetItem* pWidget, QWidget* pParent = 0);
virtual ~UBToolWidget();
void remove();
void centerOn(const QPoint& pos);
QPoint naturalCenter() const;
......
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