Your ROOT_URL in app.ini is http://git.osmesh.ru/ but you are visiting http://91.221.70.94:3000/MOS/OpenBoard/commit/cb7a0a3807c894f43ce93ac8e68279f8df30be24?style=split&whitespace=ignore-change You should set ROOT_URL correctly, otherwise the web may not work correctly.

Segfault with ToolWidget instances fixed.

Trying to position ToolWidget at the right place to move naturally from widgetitem to toolidget.
preferencesAboutTextFull
Yimgo 13 years ago
parent d5af873782
commit cb7a0a3807
  1. 7
      src/board/UBBoardController.cpp
  2. 19
      src/domain/UBGraphicsItemDelegate.cpp
  3. 2
      src/frameworks/UBCoreGraphicsScene.cpp
  4. 13
      src/gui/UBToolWidget.cpp
  5. 2
      src/gui/UBToolWidget.h

@ -2041,10 +2041,15 @@ void UBBoardController::togglePodcast(bool checked)
void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget) void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget)
{ {
graphicsWidget->remove(); QPointF controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());
graphicsWidget->hide();
UBToolWidget *toolWidget = new UBToolWidget(graphicsWidget); UBToolWidget *toolWidget = new UBToolWidget(graphicsWidget);
mActiveScene->addItem(toolWidget); mActiveScene->addItem(toolWidget);
qreal ssf = 1 / UBApplication::boardController->systemScaleFactor();
toolWidget->scale(ssf, ssf);
toolWidget->setPos(graphicsWidget->scenePos());
} }

@ -378,28 +378,13 @@ void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible)
void UBGraphicsItemDelegate::remove(bool canUndo) void UBGraphicsItemDelegate::remove(bool canUndo)
{ {
// QGraphicsScene* scene = mDelegated->scene();
UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene()); UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(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<UBGraphicsWebView*>(mDelegated);
if (mDelegated_casted)
mDelegated_casted->setHtml(QString());
scene->removeItem(mDelegated);
if (canUndo)
{ {
UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand(scene, mDelegated, 0); UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand(scene, mDelegated, 0);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
} mDelegated->hide();
} }

@ -32,7 +32,7 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene()
//we must delete removed items that are no more in any scene //we must delete removed items that are no more in any scene
foreach (const QGraphicsItem* item, mItemsToDelete) foreach (const QGraphicsItem* item, mItemsToDelete)
{ {
if (item && (item->scene() == NULL || item->scene() == this)) if (item->scene() == NULL || item->scene() == this)
{ {
delete item; delete item;
} }

@ -61,8 +61,6 @@ UBToolWidget::UBToolWidget(UBGraphicsWidgetItem *pWidget, QGraphicsItem *pParent
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
{ {
mGraphicsWidgetItem = pWidget; mGraphicsWidgetItem = pWidget;
mGraphicsWidgetItem->setParent(this);
mGraphicsWidgetItem->loadMainHtml();
initialize(); 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) 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() if (event->pos().x() >= 0 && event->pos().x() < sClosePixmap->width()
&& event->pos().y() >= 0 && event->pos().y() < sClosePixmap->height()) && event->pos().y() >= 0 && event->pos().y() < sClosePixmap->height())
{ {
scene()->removeItem(this); hide();
event->accept(); event->accept();
} }
else if (mGraphicsWidgetItem->canBeContent() && event->pos().x() >= mContentMargin && event->pos().x() < mContentMargin + sUnpinPixmap->width() else if (mGraphicsWidgetItem->canBeContent() && event->pos().x() >= mContentMargin && event->pos().x() < mContentMargin + sUnpinPixmap->width()

@ -37,6 +37,8 @@ class UBToolWidget : public QGraphicsWidget
UBGraphicsWidgetItem* graphicsWidgetItem() const; UBGraphicsWidgetItem* graphicsWidgetItem() const;
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void setPos(const QPointF &point);
virtual void setPos(qreal x, qreal y);
protected: protected:
void initialize(); void initialize();

Loading…
Cancel
Save