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. 58
      src/domain/UBGraphicsItemDelegate.cpp
  2. 2
      src/domain/UBGraphicsScene.cpp

@ -274,37 +274,43 @@ 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 (value.toBool()) { //selected(true) if (ubScene) {
ubScene->setSelectedZLevel(delegated()); if (value.toBool()) { //selected(true)
} else { ubScene->setSelectedZLevel(delegated());
ubScene->setOwnZlevel(delegated()); } else {
freeControls(); ubScene->setOwnZlevel(delegated());
freeControls();
}
} }
break;
} }
case QGraphicsItem::ItemVisibleHasChanged :
} break; {
case QGraphicsItem::ItemVisibleHasChanged : bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
{ showHide(shownOnDisplay);
bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
showHide(shownOnDisplay);
break;
}
case QGraphicsItem::ItemPositionHasChanged :
case QGraphicsItem::ItemTransformHasChanged :
case QGraphicsItem::ItemZValueHasChanged :
if (!controlsExist()) {
break; break;
} }
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom()); case QGraphicsItem::ItemPositionHasChanged :
positionHandles(); case QGraphicsItem::ItemTransformHasChanged :
if (ubScene) { case QGraphicsItem::ItemZValueHasChanged :
ubScene->setModified(true); {
if (ubScene)
{
ubScene->setModified(true);
}
if (controlsExist())
{
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
positionHandles();
break;
}
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