From addfcd94adf735386127c0e2fc2b462adc0f47a4 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 6 Sep 2021 18:06:06 +0300 Subject: [PATCH] Hide rotation controls while exporting. --- src/app/puzzle/layout/vplayout.cpp | 2 +- src/app/puzzle/layout/vpsheet.cpp | 41 +++++++++++++++++++-- src/app/puzzle/layout/vpsheet.h | 6 ++- src/app/puzzle/scene/vpmaingraphicsview.cpp | 2 +- 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/app/puzzle/layout/vplayout.cpp b/src/app/puzzle/layout/vplayout.cpp index fca3921db..ad540597e 100644 --- a/src/app/puzzle/layout/vplayout.cpp +++ b/src/app/puzzle/layout/vplayout.cpp @@ -133,7 +133,7 @@ void VPLayout::RefreshScenePieces() const { if (not sheet.isNull()) { - sheet->SceneData()->RefreshPieces(sheet); + sheet->SceneData()->RefreshPieces(); } } } diff --git a/src/app/puzzle/layout/vpsheet.cpp b/src/app/puzzle/layout/vpsheet.cpp index c32227a66..090f0e6f1 100644 --- a/src/app/puzzle/layout/vpsheet.cpp +++ b/src/app/puzzle/layout/vpsheet.cpp @@ -41,7 +41,8 @@ //--------------------------------------------------------------------------------------------------------------------- VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheetUuid) : m_layout(layout), - m_scene(new VMainGraphicsScene()) + m_scene(new VMainGraphicsScene()), + m_sheetUuid(sheetUuid) { SCASSERT(not layout.isNull()) @@ -49,7 +50,7 @@ VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheet m_graphicsSheet->setPos(0, 0); m_scene->addItem(m_graphicsSheet); - m_graphicsTileGrid = new VPGraphicsTileGrid(layout, sheetUuid); + m_graphicsTileGrid = new VPGraphicsTileGrid(layout, m_sheetUuid); m_scene->addItem(m_graphicsTileGrid); m_rotationControls = new VPGraphicsPieceControls(layout); @@ -89,11 +90,18 @@ void VPSheetSceneData::RefreshLayout() } //--------------------------------------------------------------------------------------------------------------------- -void VPSheetSceneData::RefreshPieces(const VPSheetPtr &sheet) +void VPSheetSceneData::RefreshPieces() { qDeleteAll(m_graphicsPieces); m_graphicsPieces.clear(); + VPLayoutPtr layout = m_layout.toStrongRef(); + if(layout.isNull()) + { + return; + } + + VPSheetPtr sheet = layout->GetSheet(m_sheetUuid); if (not sheet.isNull()) { QList pieces = sheet->GetPieces(); @@ -118,6 +126,9 @@ void VPSheetSceneData::PrepareForExport() m_graphicsSheet->SetShowBorder(false); m_graphicsSheet->SetShowMargin(false); + m_rotationControls->setVisible(false); + m_rotationOrigin->setVisible(false); + VPLayoutPtr layout = m_layout.toStrongRef(); if (not layout.isNull()) { @@ -126,9 +137,21 @@ void VPSheetSceneData::PrepareForExport() m_showTilesTmp = layout->LayoutSettings().GetShowTiles(); layout->LayoutSettings().SetShowTiles(false); + + VPSheetPtr sheet = layout->GetSheet(m_sheetUuid); + m_slectedPiecesTmp = sheet->GetSelectedPieces(); + + for (const auto& piece : m_slectedPiecesTmp) + { + if (not piece.isNull()) + { + piece->SetSelected(false); + } + } } RefreshLayout(); + RefreshPieces(); } //--------------------------------------------------------------------------------------------------------------------- @@ -142,9 +165,19 @@ void VPSheetSceneData::CleanAfterExport() { layout->LayoutSettings().SetShowGrid(m_showGridTmp); layout->LayoutSettings().SetShowTiles(m_showTilesTmp); + + for (const auto& piece : m_slectedPiecesTmp) + { + if (not piece.isNull()) + { + piece->SetSelected(true); + emit layout->PieceSelectionChanged(piece); + } + } } RefreshLayout(); + RefreshPieces(); } //--------------------------------------------------------------------------------------------------------------------- @@ -612,7 +645,7 @@ void VPSheet::ClearSelection() const VPLayoutPtr layout = GetLayout(); if (not layout.isNull()) { - emit GetLayout()->PieceSelectionChanged(VPPiecePtr()); + emit layout->PieceSelectionChanged(VPPiecePtr()); } } } diff --git a/src/app/puzzle/layout/vpsheet.h b/src/app/puzzle/layout/vpsheet.h index 1dff2aa9c..c8aca1a5c 100644 --- a/src/app/puzzle/layout/vpsheet.h +++ b/src/app/puzzle/layout/vpsheet.h @@ -60,7 +60,7 @@ public: */ void RefreshLayout(); - void RefreshPieces(const VPSheetPtr &sheet); + void RefreshPieces(); /** * @brief PrepareForExport prepares the graphic for an export (i.e hide margin etc) @@ -110,6 +110,10 @@ private: */ bool m_showGridTmp{false}; + QUuid m_sheetUuid; + + QList m_slectedPiecesTmp{}; + void ConnectPiece(VPGraphicsPiece *piece); }; diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index b72fe81d9..72b3bc4ab 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -104,7 +104,7 @@ void VPMainGraphicsView::RefreshPieces() VPSheetPtr sheet = layout->GetFocusedSheet(); if (not sheet.isNull()) { - sheet->SceneData()->RefreshPieces(sheet); + sheet->SceneData()->RefreshPieces(); } } }