UBToolWidget is QWidget now. Implemented all expected behavior.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent f9e12cc320
commit bce6799593
  1. 22
      src/board/UBBoardController.cpp
  2. 2
      src/domain/UBGraphicsScene.cpp
  3. 7
      src/gui/UBToolWidget.cpp
  4. 1
      src/gui/UBToolWidget.h

@ -2318,13 +2318,9 @@ void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* gr
{ {
mActiveScene->setURStackEnable(false); mActiveScene->setURStackEnable(false);
graphicsWidget->remove(false); graphicsWidget->remove(false);
UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget)); mActiveScene->addItemToDeletion(graphicsWidget);
UBGraphicsWidgetItem *copyedGraphicsWidget = NULL;
if (UBGraphicsWidgetItem::Type == toolW3C->type()) UBToolWidget *toolWidget = new UBToolWidget(graphicsWidget, mControlView);
copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C);
UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget, mControlView);
mActiveScene->setURStackEnable(true); mActiveScene->setURStackEnable(true);
QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center()); QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());
@ -2335,11 +2331,15 @@ void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* gr
void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget) void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget)
{ {
UBGraphicsWidgetItem *graphicsWidgetItem = addW3cWidget(toolWidget->toolWidget()->widgetUrl(), QPointF(0, 0)); UBGraphicsWidgetItem *widgetToScene = toolWidget->toolWidget();
graphicsWidgetItem->setPos(toolWidget->pos());
toolWidget->hide(); QPoint mainWindowCenter = toolWidget->mapTo(mMainWindow, QPoint(toolWidget->width(), toolWidget->height()) / 2);
delete toolWidget; QPoint controlViewCenter = mControlView->mapFrom(mMainWindow, mainWindowCenter);
graphicsWidgetItem->setSelected(true); QPointF scenePos = mControlView->mapToScene(controlViewCenter);
mActiveScene->addGraphicsWidget(widgetToScene, scenePos);
toolWidget->remove();
} }

@ -1310,7 +1310,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
if (graphicsWidget->canBeContent()) if (graphicsWidget->canBeContent())
{ {
// graphicsWidget->widgetWebView()->loadMainHtml(); graphicsWidget->loadMainHtml();
graphicsWidget->setSelected(true); graphicsWidget->setSelected(true);
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented

@ -222,6 +222,13 @@ QPoint UBToolWidget::naturalCenter() const
return QPoint(0, 0); return QPoint(0, 0);
} }
void UBToolWidget::remove()
{
mToolWidget = NULL;
hide();
deleteLater();
}
void UBToolWidget::centerOn(const QPoint& pos) void UBToolWidget::centerOn(const QPoint& pos)
{ {
QWidget::move(pos - QPoint(width() / 2, height() / 2)); QWidget::move(pos - QPoint(width() / 2, height() / 2));

@ -32,6 +32,7 @@ class UBToolWidget : public QWidget
UBToolWidget(UBGraphicsWidgetItem* pWidget, QWidget* pParent = 0); UBToolWidget(UBGraphicsWidgetItem* pWidget, QWidget* pParent = 0);
virtual ~UBToolWidget(); virtual ~UBToolWidget();
void remove();
void centerOn(const QPoint& pos); void centerOn(const QPoint& pos);
QPoint naturalCenter() const; QPoint naturalCenter() const;

Loading…
Cancel
Save