UBToolWidget is QWidget now. Implemented all expected behavior.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent f9e12cc320
commit bce6799593
  1. 24
      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);
graphicsWidget->remove(false);
UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget));
UBGraphicsWidgetItem *copyedGraphicsWidget = NULL;
if (UBGraphicsWidgetItem::Type == toolW3C->type())
copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C);
UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget, mControlView);
mActiveScene->addItemToDeletion(graphicsWidget);
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;

Loading…
Cancel
Save