Commit 6ff78892 authored by Craig Watson's avatar Craig Watson

Don't move a selection containing locked items

Fixes an issue where locked items could be moved if they were selected
along with other items, and these items all moved by dragging the
selection frame.

This implementation prevents any movement of the selected items if at
least one of them is locked. It also changes the colour of the selection
frame, like a locked UBGraphicsDelegateFrame.
parent d8b1dae9
......@@ -111,9 +111,15 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte
QRegion resultRegion;
UBGraphicsFlags resultFlags;
mEnclosedtems.clear();
// If at least one of the enclosed items is locked, the entire selection is
// considered to be locked.
mIsLocked = false;
foreach (QGraphicsItem *nextItem, pGraphicsItems) {
UBGraphicsItemDelegate *nextDelegate = UBGraphicsItem::Delegate(nextItem);
if (nextDelegate) {
mIsLocked = (mIsLocked || nextDelegate->isLocked());
mEnclosedtems.append(nextDelegate);
resultRegion |= nextItem->boundingRegion(nextItem->sceneTransform());
resultFlags |= nextDelegate->ubflags();
......@@ -129,6 +135,14 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte
if (resultRect.isEmpty()) {
hide();
}
if (mIsLocked) {
QColor baseColor = UBSettings::paletteColor;
baseColor.setAlphaF(baseColor.alphaF() / 3);
setLocalBrush(QBrush(baseColor));
}
else
setLocalBrush(QBrush(UBSettings::paletteColor));
}
void UBSelectionFrame::updateRect()
......@@ -168,6 +182,9 @@ void UBSelectionFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (mIsLocked)
return;
QPointF dp = event->pos() - mPressedPos;
QPointF rotCenter = mapToScene(rect().center());
......
......@@ -103,6 +103,8 @@ private:
QPointF mLastTranslateOffset;
qreal mRotationAngle;
bool mIsLocked;
QList<DelegateButton*> mButtons;
DelegateButton *mDeleteButton;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment