Optimize the carrousel piece fitInView
This commit is contained in:
parent
4edcbfd0c5
commit
7bca5f41ec
|
@ -121,7 +121,7 @@ void VPieceCarrousel::Refresh()
|
|||
m_layersContainer->layout()->addWidget(carrouselLayer);
|
||||
}
|
||||
|
||||
m_comboBoxLayer->setCurrentIndex(0);
|
||||
on_ActiveLayerChanged(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -72,6 +72,7 @@ void VPieceCarrouselLayer::Refresh()
|
|||
[](const VPuzzlePiece* a, const VPuzzlePiece* b) -> bool { return a->GetName() < b->GetName();});
|
||||
|
||||
// create the corresponding carrousel pieces
|
||||
|
||||
for (auto piece : pieces)
|
||||
{
|
||||
// qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str());
|
||||
|
@ -79,5 +80,11 @@ void VPieceCarrouselLayer::Refresh()
|
|||
VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece);
|
||||
m_carrouselPieces.append(carrouselPiece);
|
||||
layout()->addWidget(carrouselPiece);
|
||||
|
||||
// FIXME? the fitInView inside the refresh of the piece doesn't workd properly.
|
||||
// only by doing the following I did get it to work:
|
||||
setVisible(true);
|
||||
carrouselPiece->CleanPreview();
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,12 @@ void VPieceCarrouselPiece::Init()
|
|||
Refresh();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPieceCarrouselPiece::CleanPreview()
|
||||
{
|
||||
m_graphicsView->fitInView(m_graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPieceCarrouselPiece::Refresh()
|
||||
{
|
||||
|
|
|
@ -44,6 +44,11 @@ public:
|
|||
|
||||
void Init();
|
||||
void Refresh();
|
||||
/**
|
||||
* @brief CleanPiecesPreview fitInView of the qGraphicsView of the pieces works properly
|
||||
* only when the piece is in place in the layer and we call it from the layer.
|
||||
*/
|
||||
void CleanPreview();
|
||||
|
||||
signals:
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user