MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / addGraphicsWidget

Method addGraphicsWidget

src/domain/UBGraphicsScene.cpp:1748–1779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1746}
1747
1748void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, const QPointF& pPos)
1749{
1750 graphicsWidget->setFlag(QGraphicsItem::ItemIsSelectable, true);
1751
1752 addItem(graphicsWidget);
1753
1754 qreal ssf = 1 / UBApplication::boardController->systemScaleFactor();
1755
1756 graphicsWidget->setTransform(QTransform::fromScale(ssf, ssf), true);
1757
1758 graphicsWidget->setPos(QPointF(pPos.x() - graphicsWidget->boundingRect().width() / 2,
1759 pPos.y() - graphicsWidget->boundingRect().height() / 2));
1760
1761 if (graphicsWidget->canBeContent())
1762 {
1763 graphicsWidget->loadMainHtml();
1764
1765 graphicsWidget->setSelected(true);
1766 if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
1767 UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(shared_from_this(), 0, graphicsWidget);
1768 UBApplication::undoStack->push(uc);
1769 }
1770
1771 setDocumentUpdated();
1772 }
1773 else
1774 {
1775 UBApplication::boardController->moveGraphicsWidgetToControlView(graphicsWidget);
1776 }
1777
1778 UBApplication::boardController->controlView()->setFocus();
1779}
1780
1781
1782UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *> items)

Callers 1

moveToolWidgetToSceneMethod · 0.80

Calls 9

systemScaleFactorMethod · 0.80
canBeContentMethod · 0.80
loadMainHtmlMethod · 0.80
widthMethod · 0.45
boundingRectMethod · 0.45
heightMethod · 0.45
setSelectedMethod · 0.45
controlViewMethod · 0.45

Tested by

no test coverage detected