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_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();});
|
[](const VPuzzlePiece* a, const VPuzzlePiece* b) -> bool { return a->GetName() < b->GetName();});
|
||||||
|
|
||||||
// create the corresponding carrousel pieces
|
// create the corresponding carrousel pieces
|
||||||
|
|
||||||
for (auto piece : pieces)
|
for (auto piece : pieces)
|
||||||
{
|
{
|
||||||
// qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str());
|
// qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str());
|
||||||
|
@ -79,5 +80,11 @@ void VPieceCarrouselLayer::Refresh()
|
||||||
VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece);
|
VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece);
|
||||||
m_carrouselPieces.append(carrouselPiece);
|
m_carrouselPieces.append(carrouselPiece);
|
||||||
layout()->addWidget(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();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPieceCarrouselPiece::CleanPreview()
|
||||||
|
{
|
||||||
|
m_graphicsView->fitInView(m_graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPieceCarrouselPiece::Refresh()
|
void VPieceCarrouselPiece::Refresh()
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,11 @@ public:
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Refresh();
|
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:
|
signals:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user