detect scene modifications (object translations for exemple) even if object controls are not visible

preferencesAboutTextFull
Clément Fauconnier 4 years ago
parent 6693da1818
commit c81138d9be
  1. 24
      src/domain/UBGraphicsItemDelegate.cpp
  2. 2
      src/domain/UBGraphicsScene.cpp

@ -274,9 +274,10 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
UBGraphicsScene *ubScene = castUBGraphicsScene(); UBGraphicsScene *ubScene = castUBGraphicsScene();
switch (static_cast<int>(change)) { switch (static_cast<int>(change))
{
case QGraphicsItem::ItemSelectedHasChanged : { case QGraphicsItem::ItemSelectedHasChanged :
{
if (ubScene) { if (ubScene) {
if (value.toBool()) { //selected(true) if (value.toBool()) { //selected(true)
ubScene->setSelectedZLevel(delegated()); ubScene->setSelectedZLevel(delegated());
@ -285,8 +286,8 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
freeControls(); freeControls();
} }
} }
break;
} break; }
case QGraphicsItem::ItemVisibleHasChanged : case QGraphicsItem::ItemVisibleHasChanged :
{ {
bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control; bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
@ -296,16 +297,21 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
case QGraphicsItem::ItemPositionHasChanged : case QGraphicsItem::ItemPositionHasChanged :
case QGraphicsItem::ItemTransformHasChanged : case QGraphicsItem::ItemTransformHasChanged :
case QGraphicsItem::ItemZValueHasChanged : case QGraphicsItem::ItemZValueHasChanged :
if (!controlsExist()) { {
break; if (ubScene)
{
ubScene->setModified(true);
} }
if (controlsExist())
{
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom()); mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
positionHandles(); positionHandles();
if (ubScene) { break;
ubScene->setModified(true);
} }
break; break;
} }
}
return value; return value;
} }

@ -1295,7 +1295,9 @@ void UBGraphicsScene::updateSelectionFrame()
{ {
if (!mSelectionFrame) { if (!mSelectionFrame) {
mSelectionFrame = new UBSelectionFrame(); mSelectionFrame = new UBSelectionFrame();
bool sceneWasModified = isModified();
addItem(mSelectionFrame); addItem(mSelectionFrame);
setModified(sceneWasModified);
} }
QList<QGraphicsItem*> selItems = selectedItems(); QList<QGraphicsItem*> selItems = selectedItems();

Loading…
Cancel
Save