Puzzle app. Fix losing selection by piece.

This commit is contained in:
Roman Telezhynskyi 2023-10-13 17:33:59 +03:00
parent 3db18228c8
commit ff27cb217a
2 changed files with 24 additions and 12 deletions

View File

@ -46,6 +46,7 @@
- New piece option Follow grainline. - New piece option Follow grainline.
- Validate sheet and layout names before proposing file name. - Validate sheet and layout names before proposing file name.
- Puzzle app. Fix piece position move when update layout data. - Puzzle app. Fix piece position move when update layout data.
- Puzzle app. Fix losing selection by piece.
# Valentina 0.7.52 September 12, 2022 # Valentina 0.7.52 September 12, 2022
- Fix crash when default locale is ru. - Fix crash when default locale is ru.

View File

@ -102,22 +102,33 @@ void VPSheetSceneData::RefreshPieces()
} }
VPSheetPtr sheet = layout->GetSheet(m_sheetUuid); VPSheetPtr sheet = layout->GetSheet(m_sheetUuid);
if (not sheet.isNull()) if (sheet.isNull())
{ {
return;
}
QList<VPPiecePtr> pieces = sheet->GetPieces(); QList<VPPiecePtr> pieces = sheet->GetPieces();
m_graphicsPieces.reserve(pieces.size()); m_graphicsPieces.reserve(pieces.size());
for (const auto &piece : pieces) for (const auto &piece : pieces)
{ {
if (not piece.isNull()) if (piece.isNull())
{ {
continue;
}
auto *graphicsPiece = new VPGraphicsPiece(piece); auto *graphicsPiece = new VPGraphicsPiece(piece);
m_graphicsPieces.append(graphicsPiece); m_graphicsPieces.append(graphicsPiece);
m_scene->addItem(graphicsPiece); m_scene->addItem(graphicsPiece);
// Restore selection state
if (piece->IsSelected())
{
graphicsPiece->setSelected(piece->IsSelected());
}
ConnectPiece(graphicsPiece); ConnectPiece(graphicsPiece);
} }
}
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -315,7 +326,7 @@ void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece)
QObject::connect(layout.data(), &VPLayout::PieceTransformationChanged, piece, &VPGraphicsPiece::on_RefreshPiece); QObject::connect(layout.data(), &VPLayout::PieceTransformationChanged, piece, &VPGraphicsPiece::on_RefreshPiece);
QObject::connect(layout.data(), &VPLayout::PieceZValueChanged, piece, &VPGraphicsPiece::PieceZValueChanged); QObject::connect(layout.data(), &VPLayout::PieceZValueChanged, piece, &VPGraphicsPiece::PieceZValueChanged);
QObject::connect(layout.data(), &VPLayout::PieceSelectionChanged, m_rotationControls, QObject::connect(layout.data(), &VPLayout::PieceSelectionChanged, m_rotationControls,
&VPGraphicsPieceControls::on_UpdateControls); &VPGraphicsPieceControls::on_UpdateControls, Qt::UniqueConnection);
QObject::connect(layout.data(), &VPLayout::PiecePositionValidityChanged, piece, &VPGraphicsPiece::on_RefreshPiece); QObject::connect(layout.data(), &VPLayout::PiecePositionValidityChanged, piece, &VPGraphicsPiece::on_RefreshPiece);
QObject::connect(piece, &VPGraphicsPiece::PieceTransformationChanged, m_rotationControls, QObject::connect(piece, &VPGraphicsPiece::PieceTransformationChanged, m_rotationControls,
&VPGraphicsPieceControls::on_UpdateControls); &VPGraphicsPieceControls::on_UpdateControls);