diff --git a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp index 3f5889162..c39fa26cc 100644 --- a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp @@ -151,6 +151,12 @@ void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions) { m_carrousel->Refresh(); piece->SetSelected(true); + + VPLayoutPtr layout = piece->Layout(); + if (not layout.isNull()) + { + emit layout->PieceSelectionChanged(piece); + } } } } diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp index 4695a6848..42544049d 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp @@ -40,7 +40,7 @@ PuzzlePreferencesLayoutPage::PuzzlePreferencesLayoutPage(QWidget *parent) : InitLayoutUnits(); VAbstractLayoutDialog::InitTemplates(ui->comboBoxSheetTemplates); - VAbstractLayoutDialog::InitTemplates(ui->comboBoxTileTemplates); + VAbstractLayoutDialog::InitTileTemplates(ui->comboBoxTileTemplates); MinimumSheetPaperSize(); MinimumTilePaperSize(); @@ -225,7 +225,7 @@ void PuzzlePreferencesLayoutPage::ConvertPaperSize() ui->doubleSpinBoxTileMarginTop->setValue(newTileTopMargin); ui->doubleSpinBoxTileMarginBottom->setValue(newTileBottomMargin); - ui->doubleSpinBoxPiecesGap->setMaximum(UnitConvertor(50, Unit::Cm, layoutUnit)); + ui->doubleSpinBoxPiecesGap->setMaximum(UnitConvertor(VPSettings::GetMaxLayoutPieceGap(), Unit::Cm, layoutUnit)); ui->doubleSpinBoxPiecesGap->setValue(newGap); } @@ -610,7 +610,7 @@ void PuzzlePreferencesLayoutPage::ReadSettings() ui->checkBoxWarningPiecesOutOfBound->setChecked(settings->GetLayoutWarningPiecesOutOfBound()); ui->checkBoxFollowGrainline->setChecked(settings->GetLayoutFollowGrainline()); - ui->doubleSpinBoxPiecesGap->setMaximum(UnitConvertor(50, Unit::Cm, LayoutUnit())); + ui->doubleSpinBoxPiecesGap->setMaximum(UnitConvertor(VPSettings::GetMaxLayoutPieceGap(), Unit::Px, LayoutUnit())); SetPieceGap(settings->GetLayoutPieceGap()); FindSheetTemplate(); @@ -637,7 +637,7 @@ void PuzzlePreferencesLayoutPage::FindTemplate(QComboBox *box, qreal width, qrea if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize) { box->blockSignals(true); - const int index = ui->comboBoxTileTemplates->findData(i); + const int index = box->findData(i); if (index != -1) { box->setCurrentIndex(index); diff --git a/src/app/puzzle/layout/vplayout.h b/src/app/puzzle/layout/vplayout.h index d565e54a5..fb120725e 100644 --- a/src/app/puzzle/layout/vplayout.h +++ b/src/app/puzzle/layout/vplayout.h @@ -90,6 +90,8 @@ signals: void PieceTransformationChanged(const VPPiecePtr &piece); void TransformationOriginChanged(); void SheetListChanged(); + void PieceSelectionChanged(const VPPiecePtr &piece); + void LayoutChanged(); protected: explicit VPLayout(QUndoStack *undoStack); diff --git a/src/app/puzzle/layout/vplayoutsettings.cpp b/src/app/puzzle/layout/vplayoutsettings.cpp index 619a62c33..a112787ad 100644 --- a/src/app/puzzle/layout/vplayoutsettings.cpp +++ b/src/app/puzzle/layout/vplayoutsettings.cpp @@ -100,8 +100,8 @@ void VPLayoutSettings::SetTilesSize(qreal width, qreal height) //--------------------------------------------------------------------------------------------------------------------- void VPLayoutSettings::SetTilesSizeConverted(qreal width, qreal height) { - m_tilesSize.setWidth(UnitConvertor(width, GetUnit(), Unit::Px)); - m_tilesSize.setHeight(UnitConvertor(height, GetUnit(), Unit::Px)); + m_tilesSize.setWidth(UnitConvertor(width, m_unit, Unit::Px)); + m_tilesSize.setHeight(UnitConvertor(height, m_unit, Unit::Px)); } //--------------------------------------------------------------------------------------------------------------------- @@ -142,12 +142,6 @@ auto VPLayoutSettings::GetTilesSizeConverted() const -> QSizeF return GetTilesSize(GetUnit()); } -//--------------------------------------------------------------------------------------------------------------------- -auto VPLayoutSettings::GetTilesOrientation() -> PageOrientation -{ - return m_tilesSize.height() >= m_tilesSize.width() ? PageOrientation::Portrait : PageOrientation::Landscape; -} - //--------------------------------------------------------------------------------------------------------------------- void VPLayoutSettings::SetTilesMargins(qreal left, qreal top, qreal right, qreal bottom) { @@ -497,21 +491,6 @@ auto VPLayoutSettings::GetSheetSizeConverted() const -> QSizeF return convertedSize; } -//--------------------------------------------------------------------------------------------------------------------- -auto VPLayoutSettings::GetOrientation() -> PageOrientation -{ - return m_orientation; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayoutSettings::SetOrientation(PageOrientation orientation) -{ - if(orientation != m_orientation) - { - m_orientation = orientation; - } -} - //--------------------------------------------------------------------------------------------------------------------- void VPLayoutSettings::SetSheetMargins(qreal left, qreal top, qreal right, qreal bottom) { diff --git a/src/app/puzzle/layout/vplayoutsettings.h b/src/app/puzzle/layout/vplayoutsettings.h index 4fc95bb22..aabfc9897 100644 --- a/src/app/puzzle/layout/vplayoutsettings.h +++ b/src/app/puzzle/layout/vplayoutsettings.h @@ -191,12 +191,6 @@ public: */ auto GetTilesSizeConverted() const -> QSizeF; - /** - * @brief GetOrientation Returns the orientation of the tiles - * @return orientation of the tiles - */ - auto GetTilesOrientation() -> PageOrientation; - /** * @brief SetTilesMargins, set the margins of the tiles, the values have to be in Unit::Px * @param left in Unit::Px @@ -332,18 +326,6 @@ public: */ auto GetSheetSizeConverted() const -> QSizeF; - /** - * @brief GetOrientation Returns the orientation of the sheet - * @return orientation of the sheet - */ - auto GetOrientation() -> PageOrientation; - - /** - * @brief SetOrientation Sets the orientation of the sheet to the given value - * @param orientation the new page orientation - */ - void SetOrientation(PageOrientation orientation); - /** * @brief SetSheetMargins, set the margins of the sheet, the values have to be in Unit::Px * @param left in Unit::Px @@ -488,11 +470,6 @@ private: */ QSizeF m_size{}; - /** - * @brief holds the orientation of the sheet - */ - PageOrientation m_orientation {PageOrientation::Portrait}; - // margins /** * @brief m_margins the margins in Unit::Px diff --git a/src/app/puzzle/layout/vpsheet.cpp b/src/app/puzzle/layout/vpsheet.cpp index 4de346e05..0538215a5 100644 --- a/src/app/puzzle/layout/vpsheet.cpp +++ b/src/app/puzzle/layout/vpsheet.cpp @@ -28,6 +28,7 @@ #include "vpsheet.h" #include "vplayout.h" +#include "vppiece.h" //--------------------------------------------------------------------------------------------------------------------- VPSheet::VPSheet(const VPLayoutPtr &layout) : @@ -45,8 +46,6 @@ auto VPSheet::GetLayout() const -> VPLayoutPtr //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetPieces() const -> QList { - QList list; - VPLayoutPtr layout = GetLayout(); if (not layout.isNull()) { @@ -56,6 +55,31 @@ auto VPSheet::GetPieces() const -> QList return {}; } +//--------------------------------------------------------------------------------------------------------------------- +auto VPSheet::GetSelectedPieces() const -> QList +{ + VPLayoutPtr layout = GetLayout(); + if (not layout.isNull()) + { + QList list = layout->PiecesForSheet(m_uuid); + + QList selected; + selected.reserve(list.size()); + + for (const auto& piece : list) + { + if (not piece.isNull() && piece->IsSelected()) + { + selected.append(piece); + } + } + + return selected; + } + + return {}; +} + //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetName() const -> QString { diff --git a/src/app/puzzle/layout/vpsheet.h b/src/app/puzzle/layout/vpsheet.h index 81ac3907c..46bfe0243 100644 --- a/src/app/puzzle/layout/vpsheet.h +++ b/src/app/puzzle/layout/vpsheet.h @@ -55,6 +55,8 @@ public: auto GetPieces() const -> QList; + auto GetSelectedPieces() const -> QList; + /** * @brief GetName Returns the name of the sheet * @return the name diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index 81e2b2006..c2168b8da 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -76,7 +76,7 @@ VPGraphicsPiece::VPGraphicsPiece(const VPPiecePtr &piece, QGraphicsItem *parent) //--------------------------------------------------------------------------------------------------------------------- auto VPGraphicsPiece::GetPiece() -> VPPiecePtr { - return m_piece; + return m_piece.toStrongRef(); } //--------------------------------------------------------------------------------------------------------------------- @@ -245,7 +245,7 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) if (painter != nullptr) { painter->save(); - painter->setBrush(isSelected() ? selectionBrush : noBrush); + painter->setBrush(piece->IsSelected() ? selectionBrush : noBrush); painter->drawPath(m_seamLine); painter->restore(); } @@ -362,55 +362,48 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) //--------------------------------------------------------------------------------------------------------------------- void VPGraphicsPiece::GroupMove(const QPointF &pos) { - if (scene() != nullptr) + VPPiecePtr piece = m_piece.toStrongRef(); + if (piece.isNull()) { - QList list = scene()->selectedItems(); + return; + } - if (list.isEmpty()) + VPLayoutPtr layout = piece->Layout(); + if (layout.isNull()) + { + return; + } + + auto PreparePieces = [layout]() + { + QList pieces; + + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (not sheet.isNull()) { - return; + return sheet->GetSelectedPieces(); } - VPPiecePtr piece = m_piece.toStrongRef(); - if (piece.isNull()) - { - return; - } + return pieces; + }; - VPLayoutPtr layout = piece->Layout(); - if (layout.isNull()) - { - return; - } + QList pieces = PreparePieces(); + QPointF newPos = pos - m_moveStartPoint; - auto PreparePieces = [list]() - { - QVector pieces; - for (auto *item : list) - { - if (item->type() == VPGraphicsPiece::Type) - { - auto *pieceItem = dynamic_cast(item); - pieces.append(pieceItem->GetPiece()); - } - } + if (qFuzzyIsNull(newPos.x()) && qFuzzyIsNull(newPos.y())) + { + return; + } - return pieces; - }; - - QVector pieces = PreparePieces(); - QPointF newPos = pos - m_moveStartPoint; - - if (pieces.size() == 1) - { - auto *command = new VPUndoPieceMove(pieces.first(), newPos.x(), newPos.y(), allowChangeMerge); - layout->UndoStack()->push(command); - } - else if (pieces.size() > 1) - { - auto *command = new VPUndoPiecesMove(pieces, newPos.x(), newPos.y(), allowChangeMerge); - layout->UndoStack()->push(command); - } + if (pieces.size() == 1) + { + auto *command = new VPUndoPieceMove(pieces.first(), newPos.x(), newPos.y(), allowChangeMerge); + layout->UndoStack()->push(command); + } + else if (pieces.size() > 1) + { + auto *command = new VPUndoPiecesMove(pieces, newPos.x(), newPos.y(), allowChangeMerge); + layout->UndoStack()->push(command); } } @@ -435,8 +428,13 @@ auto VPGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &valu VPPiecePtr piece = m_piece.toStrongRef(); if (not piece.isNull()) { - emit PieceSelectionChanged(); piece->SetSelected(value.toBool()); + + VPLayoutPtr layout = piece->Layout(); + if (not layout.isNull()) + { + emit layout->PieceSelectionChanged(piece); + } } } } diff --git a/src/app/puzzle/scene/vpgraphicspiece.h b/src/app/puzzle/scene/vpgraphicspiece.h index 62d2d22e1..da7ea0b51 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.h +++ b/src/app/puzzle/scene/vpgraphicspiece.h @@ -52,7 +52,6 @@ public: enum { Type = UserType + static_cast(PGraphicsItem::Piece)}; signals: - void PieceSelectionChanged(); void HideTransformationHandles(bool hide); void PieceTransformationChanged(); diff --git a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp index 852ecaf25..8716b7313 100644 --- a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp +++ b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp @@ -37,6 +37,7 @@ #include "../vmisc/compatibility.h" #include "../vwidgets/global.h" #include "../layout/vplayout.h" +#include "../layout/vppiece.h" #include "../undocommands/vpundopiecerotate.h" #include "../undocommands/vpundooriginmove.h" #include "vpgraphicspiece.h" @@ -479,16 +480,21 @@ void VPGraphicsPieceControls::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { auto PreparePieces = [this]() { - QVector pieces; - for (auto *item : m_selectedPieces) + QList pieces; + VPLayoutPtr layout = m_layout.toStrongRef(); + if (not layout.isNull()) { - pieces.append(item->GetPiece()); + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + pieces = sheet->GetSelectedPieces(); + } } return pieces; }; - QVector pieces = PreparePieces(); + QList pieces = PreparePieces(); VPLayoutPtr layout = m_layout.toStrongRef(); if (not layout.isNull()) @@ -662,7 +668,7 @@ auto VPGraphicsPieceControls::ControllersRect() const -> QRectF //--------------------------------------------------------------------------------------------------------------------- auto VPGraphicsPieceControls::ArrowPath() const -> QPainterPath { - const qreal scale = SceneScale(scene()); + const qreal scale = SceneScale(scene())/2; QPainterPath arrow; QRectF pieceRect = ControllersRect(); @@ -764,23 +770,17 @@ auto VPGraphicsPieceControls::ArrowPath() const -> QPainterPath } //--------------------------------------------------------------------------------------------------------------------- -auto VPGraphicsPieceControls::SelectedPieces() const -> QVector +auto VPGraphicsPieceControls::SelectedPieces() const -> QList { - QVector pieces; - QGraphicsScene *scene = this->scene(); - if (scene != nullptr) + QList pieces; + + VPLayoutPtr layout = m_layout.toStrongRef(); + if (not layout.isNull()) { - QList list = scene->selectedItems(); - for (auto *item : list) + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (not sheet.isNull()) { - if (item->type() == VPGraphicsPiece::Type) - { - auto *pieceItem = dynamic_cast(item); - if (pieceItem != nullptr) - { - pieces.append(pieceItem); - } - } + pieces = sheet->GetSelectedPieces(); } } @@ -788,12 +788,15 @@ auto VPGraphicsPieceControls::SelectedPieces() const -> QVector &selectedPieces) -> QRectF +auto VPGraphicsPieceControls::PiecesBoundingRect(const QList &selectedPieces) -> QRectF { QRectF rect; - for (auto *item : selectedPieces) + for (const auto& item : selectedPieces) { - rect = rect.united(item->sceneBoundingRect()); + if (not item.isNull()) + { + rect = rect.united(item->MappedDetailBoundingRect()); + } } return rect; diff --git a/src/app/puzzle/scene/vpgraphicspiececontrols.h b/src/app/puzzle/scene/vpgraphicspiececontrols.h index 9c838cec8..07b26e655 100644 --- a/src/app/puzzle/scene/vpgraphicspiececontrols.h +++ b/src/app/puzzle/scene/vpgraphicspiececontrols.h @@ -114,7 +114,7 @@ private: VPTransformationOrigon m_savedOrigin{}; bool m_originSaved{false}; bool allowChangeMerge{false}; - QVector m_selectedPieces{}; + QList m_selectedPieces{}; bool m_ignorePieceTransformation{false}; auto TopLeftControl(QPainter *painter = nullptr) const -> QPainterPath; @@ -130,8 +130,8 @@ private: auto HandleCorner(const QPointF &pos) const -> int; - auto SelectedPieces() const -> QVector; - static auto PiecesBoundingRect(const QVector &selectedPieces) -> QRectF; + auto SelectedPieces() const -> QList; + static auto PiecesBoundingRect(const QList &selectedPieces) -> QRectF; }; #endif // VPGRAPHICSPIECECONTROLS_H diff --git a/src/app/puzzle/scene/vpgraphicssheet.cpp b/src/app/puzzle/scene/vpgraphicssheet.cpp index d4a2e28f3..af5257948 100644 --- a/src/app/puzzle/scene/vpgraphicssheet.cpp +++ b/src/app/puzzle/scene/vpgraphicssheet.cpp @@ -113,10 +113,6 @@ auto VPGraphicsSheet::GetSheetRect() const -> QRectF QPoint topLeft = QPoint(0,0); QSizeF size = layout->LayoutSettings().GetSheetSize(); - if(layout->LayoutSettings().GetOrientation() == PageOrientation::Landscape) - { - size.transpose(); - } QRectF rect = QRectF(topLeft, size); return rect; } @@ -130,17 +126,17 @@ auto VPGraphicsSheet::GetMarginsRect() const -> QRectF return {}; } - QMarginsF margins = layout->LayoutSettings().GetSheetMargins(); QSizeF size = layout->LayoutSettings().GetSheetSize(); - if(layout->LayoutSettings().GetOrientation() == PageOrientation::Landscape) + if (not layout->LayoutSettings().IgnoreMargins()) { - size.transpose(); + QMarginsF margins = layout->LayoutSettings().GetSheetMargins(); + QRectF rect = QRectF(QPointF(margins.left(), margins.top()), + QPointF(size.width()-margins.right(), size.height()-margins.bottom())); + return rect; } - QRectF rect = QRectF(QPointF(margins.left(),margins.top()), - QPointF(size.width()-margins.right(), size.height()-margins.bottom())); - return rect; + return QRectF(0, 0, size.width(), size.height()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/scene/vpgraphicstilegrid.cpp b/src/app/puzzle/scene/vpgraphicstilegrid.cpp index 3ce3d539b..3154d3323 100644 --- a/src/app/puzzle/scene/vpgraphicstilegrid.cpp +++ b/src/app/puzzle/scene/vpgraphicstilegrid.cpp @@ -13,13 +13,7 @@ VPGraphicsTileGrid::VPGraphicsTileGrid(const VPLayoutPtr &layout, VPTileFactory } //--------------------------------------------------------------------------------------------------------------------- -VPGraphicsTileGrid::~VPGraphicsTileGrid() -{ - -} - -//--------------------------------------------------------------------------------------------------------------------- -QRectF VPGraphicsTileGrid::boundingRect() const +auto VPGraphicsTileGrid::boundingRect() const -> QRectF { VPLayoutPtr layout = m_layout.toStrongRef(); if(not layout.isNull() && layout->LayoutSettings().GetShowTiles()) diff --git a/src/app/puzzle/scene/vpgraphicstilegrid.h b/src/app/puzzle/scene/vpgraphicstilegrid.h index 11fb45b63..b30b70195 100644 --- a/src/app/puzzle/scene/vpgraphicstilegrid.h +++ b/src/app/puzzle/scene/vpgraphicstilegrid.h @@ -42,7 +42,7 @@ class VPGraphicsTileGrid : public QGraphicsItem { public: explicit VPGraphicsTileGrid(const VPLayoutPtr &layout, VPTileFactory *tileFactory, QGraphicsItem *parent = nullptr); - ~VPGraphicsTileGrid(); + ~VPGraphicsTileGrid()=default; QRectF boundingRect() const override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index 19267a8df..e87e090ca 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -70,6 +70,8 @@ VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, VPTileFactory SCASSERT(not m_layout.isNull()) setScene(m_scene); + connect(m_scene, &VMainGraphicsScene::ItemClicked, this, &VPMainGraphicsView::on_ItemClicked); + m_graphicsSheet = new VPGraphicsSheet(m_layout); m_graphicsSheet->setPos(0, 0); m_scene->addItem(m_graphicsSheet); @@ -262,6 +264,8 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event) VPLayoutPtr layout = m_layout.toStrongRef(); if (not layout.isNull()) { + emit layout->PieceSelectionChanged(piece); + auto *command = new VPUndoMovePieceOnSheet(VPSheetPtr(), piece); layout->UndoStack()->push(command); } @@ -429,11 +433,12 @@ void VPMainGraphicsView::RestoreOrigin() const origin.custom = false; QRectF boundingRect; - for (auto *graphicsPiece : m_graphicsPieces) + QList selectedPieces = sheet->GetSelectedPieces(); + for (const auto& piece : selectedPieces) { - if (graphicsPiece->isSelected()) + if (piece->IsSelected()) { - boundingRect = boundingRect.united(graphicsPiece->sceneBoundingRect()); + boundingRect = boundingRect.united(piece->MappedDetailBoundingRect()); } } origin.origin = boundingRect.center(); @@ -444,6 +449,60 @@ void VPMainGraphicsView::RestoreOrigin() const } } +//--------------------------------------------------------------------------------------------------------------------- +void VPMainGraphicsView::on_ItemClicked(QGraphicsItem *item) +{ + if (item == nullptr || (item->type() != VPGraphicsPiece::Type && + item->type() != VPGraphicsPieceControls::Type && + item->type() != VPGraphicsTransformationOrigin::Type)) + { + VPLayoutPtr layout = m_layout.toStrongRef(); + if (not layout.isNull()) + { + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + QList selectedPieces = sheet->GetSelectedPieces(); + for (const auto& piece : selectedPieces) + { + if (piece->IsSelected()) + { + piece->SetSelected(false); + } + } + + if (not selectedPieces.isEmpty()) + { + emit layout->PieceSelectionChanged(VPPiecePtr()); + } + } + } + } + else + { + if (item->type() == VPGraphicsPiece::Type) + { + auto *pieceItem = dynamic_cast(item); + if (pieceItem != nullptr) + { + VPPiecePtr piece = pieceItem->GetPiece(); + if (not piece.isNull()) + { + if (not piece->IsSelected()) + { + piece->SetSelected(true); + VPLayoutPtr layout = m_layout.toStrongRef(); + if (not layout.isNull()) + { + emit layout->PieceSelectionChanged(piece); + } + } + } + } + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPMainGraphicsView::ConnectPiece(VPGraphicsPiece *piece) { @@ -453,7 +512,7 @@ void VPMainGraphicsView::ConnectPiece(VPGraphicsPiece *piece) connect(layout.get(), &VPLayout::PieceTransformationChanged, piece, &VPGraphicsPiece::on_RefreshPiece); - connect(piece, &VPGraphicsPiece::PieceSelectionChanged, + connect(layout.get(), &VPLayout::PieceSelectionChanged, m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls); connect(piece, &VPGraphicsPiece::PieceTransformationChanged, m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls); @@ -485,19 +544,21 @@ void VPMainGraphicsView::RotatePiecesByAngle(qreal angle) auto PreparePieces = [this]() { - QVector pieces; - for (auto *item : m_graphicsPieces) + QList pieces; + VPLayoutPtr layout = m_layout.toStrongRef(); + if (not layout.isNull()) { - if (item->isSelected()) + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (not sheet.isNull()) { - pieces.append(item->GetPiece()); + pieces = sheet->GetSelectedPieces(); } } return pieces; }; - QVector pieces = PreparePieces(); + QList pieces = PreparePieces(); if (pieces.size() == 1) { @@ -535,19 +596,21 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy) auto PreparePieces = [this]() { - QVector pieces; - for (auto *graphicsPiece : m_graphicsPieces) + QList pieces; + VPLayoutPtr layout = m_layout.toStrongRef(); + if (not layout.isNull()) { - if (graphicsPiece->isSelected()) + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (not sheet.isNull()) { - pieces.append(graphicsPiece->GetPiece()); + pieces = sheet->GetSelectedPieces(); } } return pieces; }; - QVector pieces = PreparePieces(); + QList pieces = PreparePieces(); if (pieces.size() == 1) { auto *command = new VPUndoPieceMove(pieces.first(), dx, dy, m_allowChangeMerge); diff --git a/src/app/puzzle/scene/vpmaingraphicsview.h b/src/app/puzzle/scene/vpmaingraphicsview.h index 8033fdc2f..a2d8896f9 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.h +++ b/src/app/puzzle/scene/vpmaingraphicsview.h @@ -95,6 +95,7 @@ protected: private slots: void RestoreOrigin() const; + void on_ItemClicked(QGraphicsItem* item); private: Q_DISABLE_COPY(VPMainGraphicsView) diff --git a/src/app/puzzle/share/resources/puzzleicon.qrc b/src/app/puzzle/share/resources/puzzleicon.qrc index 33d297039..6c117d3fe 100644 --- a/src/app/puzzle/share/resources/puzzleicon.qrc +++ b/src/app/puzzle/share/resources/puzzleicon.qrc @@ -5,10 +5,6 @@ puzzleicon/64x64/iconCurrentPiece.png puzzleicon/64x64/iconLayers.png puzzleicon/64x64/iconTiles.png - puzzleicon/64x64/iconLandscape.png - puzzleicon/64x64/iconPortrait.png - puzzleicon/64x64/iconGrainlineVertical.png - puzzleicon/64x64/iconGrainlineHorizontal.png puzzleicon/64x64/iconProperties.png puzzleicon/svg/icon_scissors.svg puzzleicon/svg/icon_scissors_vertical.svg @@ -18,10 +14,6 @@ puzzleicon/svg/cursor_rotate.svg puzzleicon/svg/icon_rotate_90_anticlockwise.svg puzzleicon/svg/icon_rotate_90_clockwise.svg - puzzleicon/64x64/iconRotate90Anticlockwise.png - puzzleicon/64x64/iconRotate90Clockwise.png - puzzleicon/64x64/iconRotateGrainlineHorizontal.png - puzzleicon/64x64/iconRotateGrainlineVertical.png puzzleicon/svg/icon_rotate_grainline_horizontal.svg puzzleicon/svg/icon_rotate_grainline_vertical.svg diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineHorizontal.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineHorizontal.png deleted file mode 100644 index 394d48fc0..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineHorizontal.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineHorizontal@2x.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineHorizontal@2x.png deleted file mode 100644 index 10620e97a..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineHorizontal@2x.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineVertical.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineVertical.png deleted file mode 100644 index e2a49f1ab..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineVertical.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineVertical@2x.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineVertical@2x.png deleted file mode 100644 index 1493af76f..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconGrainlineVertical@2x.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconLandscape.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconLandscape.png deleted file mode 100644 index 666d96fa7..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconLandscape.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconLandscape@2x.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconLandscape@2x.png deleted file mode 100644 index 67827f90f..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconLandscape@2x.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconPortrait.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconPortrait.png deleted file mode 100644 index 46077bbc5..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconPortrait.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconPortrait@2x.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconPortrait@2x.png deleted file mode 100644 index 95efe95ff..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconPortrait@2x.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotate90Anticlockwise.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotate90Anticlockwise.png deleted file mode 100644 index 278265d82..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotate90Anticlockwise.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotate90Clockwise.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotate90Clockwise.png deleted file mode 100644 index 9e6907d73..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotate90Clockwise.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineHorizontal.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineHorizontal.png deleted file mode 100644 index 910e3766a..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineHorizontal.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineHorizontal@2x.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineHorizontal@2x.png deleted file mode 100644 index f02832cd4..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineHorizontal@2x.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineVertical.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineVertical.png deleted file mode 100644 index 74d62e60d..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineVertical.png and /dev/null differ diff --git a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineVertical@2x.png b/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineVertical@2x.png deleted file mode 100644 index e4af4320d..000000000 Binary files a/src/app/puzzle/share/resources/puzzleicon/64x64/iconRotateGrainlineVertical@2x.png and /dev/null differ diff --git a/src/app/puzzle/undocommands/vpundomovepieceonsheet.cpp b/src/app/puzzle/undocommands/vpundomovepieceonsheet.cpp index 32a0c1a76..fa277a1dd 100644 --- a/src/app/puzzle/undocommands/vpundomovepieceonsheet.cpp +++ b/src/app/puzzle/undocommands/vpundomovepieceonsheet.cpp @@ -59,7 +59,7 @@ void VPUndoMovePieceOnSheet::undo() if (not activateSheet.isNull()) { layout = activateSheet->GetLayout(); - if (not layout.isNull() && not activateSheet->TrashSheet()) + if (not layout.isNull() && not activateSheet->TrashSheet() && layout->GetFocusedSheet() != activateSheet) { layout->SetFocusedSheet(activateSheet); } @@ -69,10 +69,12 @@ void VPUndoMovePieceOnSheet::undo() if (not piece.isNull()) { piece->SetSheet(sourceSheet); + piece->SetSelected(false); if (not layout.isNull()) { emit layout->PieceSheetChanged(piece); + emit layout->PieceSelectionChanged(piece); } } } @@ -92,7 +94,7 @@ void VPUndoMovePieceOnSheet::redo() if (not activateSheet.isNull()) { layout = activateSheet->GetLayout(); - if (not layout.isNull() && not activateSheet->TrashSheet()) + if (not layout.isNull() && not activateSheet->TrashSheet() && layout->GetFocusedSheet() != activateSheet) { layout->SetFocusedSheet(activateSheet); } diff --git a/src/app/puzzle/undocommands/vpundooriginmove.cpp b/src/app/puzzle/undocommands/vpundooriginmove.cpp index b2e5e21b6..b9e66add8 100644 --- a/src/app/puzzle/undocommands/vpundooriginmove.cpp +++ b/src/app/puzzle/undocommands/vpundooriginmove.cpp @@ -59,7 +59,10 @@ void VPUndoOriginMove::undo() return; } - layout->SetFocusedSheet(sheet); + if (layout->GetFocusedSheet() != sheet) + { + layout->SetFocusedSheet(sheet); + } sheet->SetTransformationOrigin(m_oldOrigin); layout->TransformationOriginChanged(); @@ -80,7 +83,10 @@ void VPUndoOriginMove::redo() return; } - layout->SetFocusedSheet(sheet); + if (layout->GetFocusedSheet() != sheet) + { + layout->SetFocusedSheet(sheet); + } sheet->SetTransformationOrigin(m_origin); emit layout->TransformationOriginChanged(); diff --git a/src/app/puzzle/undocommands/vpundopiecemove.cpp b/src/app/puzzle/undocommands/vpundopiecemove.cpp index 3b90642bd..c8941a32f 100644 --- a/src/app/puzzle/undocommands/vpundopiecemove.cpp +++ b/src/app/puzzle/undocommands/vpundopiecemove.cpp @@ -59,7 +59,10 @@ void VPUndoPieceMove::undo() return; } - layout->SetFocusedSheet(piece->Sheet()); + if (layout->GetFocusedSheet() != piece->Sheet()) + { + layout->SetFocusedSheet(piece->Sheet()); + } piece->SetMatrix(m_oldTransform); emit layout->PieceTransformationChanged(piece); @@ -80,7 +83,10 @@ void VPUndoPieceMove::redo() return; } - layout->SetFocusedSheet(piece->Sheet()); + if (layout->GetFocusedSheet() != piece->Sheet()) + { + layout->SetFocusedSheet(piece->Sheet()); + } piece->Translate(m_dx, m_dy); emit layout->PieceTransformationChanged(piece); @@ -117,7 +123,7 @@ auto VPUndoPieceMove::id() const -> int // move pieces //--------------------------------------------------------------------------------------------------------------------- -VPUndoPiecesMove::VPUndoPiecesMove(const QVector &pieces, qreal dx, qreal dy, bool allowMerge, +VPUndoPiecesMove::VPUndoPiecesMove(const QList &pieces, qreal dx, qreal dy, bool allowMerge, QUndoCommand *parent) : VPUndoCommand(allowMerge, parent), m_dx(dx), @@ -149,7 +155,11 @@ void VPUndoPiecesMove::undo() return; } - layout->SetFocusedSheet(Sheet()); + VPSheetPtr sheet = Sheet(); + if (layout->GetFocusedSheet() != sheet) + { + layout->SetFocusedSheet(sheet); + } for (const auto& piece : m_pieces) { @@ -179,7 +189,11 @@ void VPUndoPiecesMove::redo() return; } - layout->SetFocusedSheet(Sheet()); + VPSheetPtr sheet = Sheet(); + if (layout->GetFocusedSheet() != sheet) + { + layout->SetFocusedSheet(sheet); + } for (const auto& piece : m_pieces) { diff --git a/src/app/puzzle/undocommands/vpundopiecemove.h b/src/app/puzzle/undocommands/vpundopiecemove.h index 9c4bf09e3..fe84e3413 100644 --- a/src/app/puzzle/undocommands/vpundopiecemove.h +++ b/src/app/puzzle/undocommands/vpundopiecemove.h @@ -38,7 +38,7 @@ class VPUndoPieceMove : public VPUndoCommand { Q_OBJECT public: - explicit VPUndoPieceMove(const VPPiecePtr &piece, qreal dx, qreal dy, bool allowMerge, + explicit VPUndoPieceMove(const VPPiecePtr &piece, qreal dx, qreal dy, bool allowMerge = false, QUndoCommand *parent = nullptr); virtual ~VPUndoPieceMove()=default; @@ -84,7 +84,7 @@ class VPUndoPiecesMove : public VPUndoCommand { Q_OBJECT public: - explicit VPUndoPiecesMove(const QVector &pieces, qreal dx, qreal dy, bool allowMerge, + explicit VPUndoPiecesMove(const QList &pieces, qreal dx, qreal dy, bool allowMerge = false, QUndoCommand *parent = nullptr); virtual ~VPUndoPiecesMove()=default; diff --git a/src/app/puzzle/undocommands/vpundopiecerotate.cpp b/src/app/puzzle/undocommands/vpundopiecerotate.cpp index f947c4d94..a264b70c6 100644 --- a/src/app/puzzle/undocommands/vpundopiecerotate.cpp +++ b/src/app/puzzle/undocommands/vpundopiecerotate.cpp @@ -59,7 +59,10 @@ void VPUndoPieceRotate::undo() return; } - layout->SetFocusedSheet(piece->Sheet()); + if (layout->GetFocusedSheet() != piece->Sheet()) + { + layout->SetFocusedSheet(piece->Sheet()); + } piece->SetMatrix(m_oldTransform); emit layout->PieceTransformationChanged(piece); @@ -80,7 +83,10 @@ void VPUndoPieceRotate::redo() return; } - layout->SetFocusedSheet(piece->Sheet()); + if (layout->GetFocusedSheet() != piece->Sheet()) + { + layout->SetFocusedSheet(piece->Sheet()); + } piece->Rotate(m_origin, m_angle); emit layout->PieceTransformationChanged(piece); @@ -116,7 +122,7 @@ auto VPUndoPieceRotate::id() const -> int // rotate pieces //--------------------------------------------------------------------------------------------------------------------- -VPUndoPiecesRotate::VPUndoPiecesRotate(const QVector &pieces, const QPointF &origin, qreal angle, +VPUndoPiecesRotate::VPUndoPiecesRotate(const QList &pieces, const QPointF &origin, qreal angle, bool allowMerge, QUndoCommand *parent) : VPUndoCommand(allowMerge, parent), m_origin(origin), @@ -148,7 +154,11 @@ void VPUndoPiecesRotate::undo() return; } - layout->SetFocusedSheet(Sheet()); + VPSheetPtr sheet = Sheet(); + if (layout->GetFocusedSheet() != sheet) + { + layout->SetFocusedSheet(sheet); + } for (const auto& piece : m_pieces) { @@ -178,7 +188,11 @@ void VPUndoPiecesRotate::redo() return; } - layout->SetFocusedSheet(Sheet()); + VPSheetPtr sheet = Sheet(); + if (layout->GetFocusedSheet() != sheet) + { + layout->SetFocusedSheet(sheet); + } for (const auto& piece : m_pieces) { diff --git a/src/app/puzzle/undocommands/vpundopiecerotate.h b/src/app/puzzle/undocommands/vpundopiecerotate.h index 96a480e36..c9f5ab25e 100644 --- a/src/app/puzzle/undocommands/vpundopiecerotate.h +++ b/src/app/puzzle/undocommands/vpundopiecerotate.h @@ -38,7 +38,7 @@ class VPUndoPieceRotate : public VPUndoCommand { Q_OBJECT public: - VPUndoPieceRotate(const VPPiecePtr &piece, const QPointF &origin, qreal angle, bool allowMerge, + VPUndoPieceRotate(const VPPiecePtr &piece, const QPointF &origin, qreal angle, bool allowMerge = false, QUndoCommand *parent = nullptr); virtual ~VPUndoPieceRotate()=default; @@ -85,8 +85,8 @@ class VPUndoPiecesRotate : public VPUndoCommand { Q_OBJECT public: - explicit VPUndoPiecesRotate(const QVector &pieces, const QPointF &origin, qreal angle, bool allowMerge, - QUndoCommand *parent = nullptr); + explicit VPUndoPiecesRotate(const QList &pieces, const QPointF &origin, qreal angle, + bool allowMerge = false, QUndoCommand *parent = nullptr); virtual ~VPUndoPiecesRotate()=default; virtual void undo() override; diff --git a/src/app/puzzle/vpexporter.cpp b/src/app/puzzle/vpexporter.cpp index df4a2d86f..9a886bb12 100644 --- a/src/app/puzzle/vpexporter.cpp +++ b/src/app/puzzle/vpexporter.cpp @@ -44,10 +44,6 @@ void VPExporter::Export(VPLayout* layout, LayoutExportFormats format, VPMainGrap SetFileName(fileName); QSizeF size = QSizeF(layout->GetFocusedSheet()->GetLayout()->LayoutSettings().GetSheetSize()); - if(layout->GetFocusedSheet()->GetLayout()->LayoutSettings().GetOrientation() == PageOrientation::Landscape) - { - size.transpose(); - } const QRectF rect = QRectF(0, 0, size.width(), size.height()); SetImageRect(rect); diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index b65acc6df..d2c4a9d75 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -49,6 +49,8 @@ #include "layout/vpsheet.h" #include "dialogs/dialogpuzzlepreferences.h" #include "undocommands/vpundoaddsheet.h" +#include "undocommands/vpundopiecerotate.h" +#include "undocommands/vpundopiecemove.h" #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #include "../vmisc/backport/qscopeguard.h" @@ -66,6 +68,56 @@ Q_LOGGING_CATEGORY(pWindow, "p.window") QT_WARNING_POP +namespace +{ +//--------------------------------------------------------------------------------------------------------------------- +void SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value) +{ + spinBox->blockSignals(true); + spinBox->setValue(value); + spinBox->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void SetCheckBoxValue(QCheckBox *checkbox, bool value) +{ + checkbox->blockSignals(true); + checkbox->setChecked(value); + checkbox->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void SetLineEditValue(QLineEdit *lineEdit, const QString &value) +{ + lineEdit->blockSignals(true); + lineEdit->setText(value); + lineEdit->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void SetPlainTextEditValue(QPlainTextEdit *textEdit, const QString &value) +{ + textEdit->blockSignals(true); + textEdit->setPlainText(value); + textEdit->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto PiecesBoundingRect(const QList &selectedPieces) -> QRectF +{ + QRectF rect; + for (const auto& item : selectedPieces) + { + if (not item.isNull()) + { + rect = rect.united(item->MappedDetailBoundingRect()); + } + } + + return rect; +} +} // namespace + //--------------------------------------------------------------------------------------------------------------------- VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : VAbstractMainWindow(parent), @@ -78,6 +130,21 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : { ui->setupUi(this); + connect(m_layout.get(), &VPLayout::PieceSelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged); + connect(m_layout.get(), &VPLayout::LayoutChanged, this, [this]() + { + LayoutWasSaved(false); + }); + connect(m_layout.get(), &VPLayout::PieceTransformationChanged, this, [this]() + { + SetPropertyTabCurrentPieceData(); + }); + + connect(m_undoStack, &QUndoStack::cleanChanged, this, [this](bool clean) + { + LayoutWasSaved(clean); + }); + // init the tile factory m_tileFactory = new VPTileFactory(m_layout, VPApplication::VApp()->Settings()); m_tileFactory->refreshTileInfos(); @@ -113,11 +180,14 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : UpdateWindowTitle(); } }); + + m_graphicsView->RefreshLayout(); } //--------------------------------------------------------------------------------------------------------------------- VPMainWindow::~VPMainWindow() { + delete m_undoStack; delete ui; delete m_carrousel; } @@ -205,6 +275,8 @@ auto VPMainWindow::LoadFile(QString path) -> bool m_layout->SetFocusedSheet(); + m_oldLayoutUnit = m_layout->LayoutSettings().GetUnit(); + // updates the properties with the loaded data SetPropertiesData(); @@ -212,6 +284,7 @@ auto VPMainWindow::LoadFile(QString path) -> bool m_graphicsView->RefreshLayout(); m_graphicsView->RefreshPieces(); m_tileFactory->refreshTileInfos(); + VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); return true; } @@ -429,48 +502,211 @@ void VPMainWindow::SetupMenu() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitProperties() { + ui->tabWidgetProperties->setCurrentIndex(0); + + VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); + m_oldLayoutUnit = settings->LayoutUnit(); + InitPropertyTabCurrentPiece(); InitPropertyTabCurrentSheet(); - InitPropertyTabLayout(); InitPropertyTabTiles(); + InitPropertyTabLayout(); } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitPropertyTabCurrentPiece() { - // FIXME ---- For MVP we hide a few things. To be displayed when functions there - ui->groupBoxLayoutControl->hide(); - ui->groupBoxCurrentPieceGeometry->hide(); + connect(ui->lineEditCurrentPieceName, &QLineEdit::textEdited, this, [this](const QString &text) + { + QList selectedPieces = SelectedPieces(); + if (selectedPieces.size() == 1) + { + VPPiecePtr selectedPiece = selectedPieces.first(); + if (not selectedPiece.isNull()) + { + selectedPiece->SetName(text); + LayoutWasSaved(false); + } + } + }); + connect(ui->plainTextEditCurrentPieceUUID, &QPlainTextEdit::textChanged, this, [this]() + { + QList selectedPieces = SelectedPieces(); + if (selectedPieces.size() == 1) + { + VPPiecePtr selectedPiece = selectedPieces.first(); + if (not selectedPiece.isNull()) + { + const QUuid temp = QUuid(ui->plainTextEditCurrentPieceUUID->toPlainText()); + if (not temp.isNull()) + { + selectedPiece->SetUUID(temp); + } + LayoutWasSaved(false); + } + } + }); - // ------------------------------ placement ----------------------------------- - connect(ui->doubleSpinBoxCurrentPieceBoxPositionX, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_CurrentPiecePositionEdited); - connect(ui->doubleSpinBoxCurrentPieceBoxPositionY, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_CurrentPiecePositionEdited); + connect(ui->checkBoxCurrentPieceShowSeamline, &QCheckBox::toggled, this, [this](bool checked) + { + QList selectedPieces = SelectedPieces(); + if (selectedPieces.size() == 1) + { + VPPiecePtr selectedPiece = selectedPieces.first(); + if (not selectedPiece.isNull()) + { +// selectedPiece->SetShowSeamline(checked); +// LayoutWasSaved(false); + } + } + }); + + connect(ui->checkBoxCurrentPieceMirrorPiece, &QCheckBox::toggled, this, [this](bool checked) + { + QList selectedPieces = SelectedPieces(); + if (selectedPieces.size() == 1) + { + VPPiecePtr selectedPiece = selectedPieces.first(); + if (not selectedPiece.isNull()) + { + selectedPiece->SetMirror(checked); + LayoutWasSaved(false); + emit m_layout->PieceTransformationChanged(selectedPiece); + } + } + }); + + // Translate + ui->comboBoxTranslateUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm))); + ui->comboBoxTranslateUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm))); + ui->comboBoxTranslateUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch))); + ui->comboBoxTranslateUnit->addItem(tr("Pixels"), QVariant(UnitsToStr(Unit::Px))); + + m_oldPieceTranslationUnit = Unit::Mm; + ui->comboBoxTranslateUnit->blockSignals(true); + ui->comboBoxTranslateUnit->setCurrentIndex(0); + ui->comboBoxTranslateUnit->blockSignals(false); + + const int minTranslate = -1000; + const int maxTranslate = 1000; + + ui->doubleSpinBoxCurrentPieceBoxPositionX->setMinimum( + UnitConvertor(minTranslate, Unit::Cm, m_oldPieceTranslationUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionX->setMaximum( + UnitConvertor(maxTranslate, Unit::Cm, m_oldPieceTranslationUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue(0); + + ui->doubleSpinBoxCurrentPieceBoxPositionY->setMinimum( + UnitConvertor(minTranslate, Unit::Cm, m_oldPieceTranslationUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setMaximum( + UnitConvertor(maxTranslate, Unit::Cm, m_oldPieceTranslationUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue(0); + + connect(ui->comboBoxTranslateUnit, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() + { + const Unit newUnit = TranslateUnit(); + const qreal oldTranslateX = ui->doubleSpinBoxCurrentPieceBoxPositionX->value(); + const qreal oldTranslateY = ui->doubleSpinBoxCurrentPieceBoxPositionY->value(); + + ui->doubleSpinBoxCurrentPieceBoxPositionX->setMinimum(UnitConvertor(minTranslate, Unit::Cm, newUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionX->setMaximum(UnitConvertor(maxTranslate, Unit::Cm, newUnit)); + + ui->doubleSpinBoxCurrentPieceBoxPositionY->setMinimum(UnitConvertor(minTranslate, Unit::Cm, newUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setMaximum(UnitConvertor(maxTranslate, Unit::Cm, newUnit)); + + ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue( + UnitConvertor(oldTranslateX, m_oldPieceTranslationUnit, newUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue( + UnitConvertor(oldTranslateY, m_oldPieceTranslationUnit, newUnit)); + + m_oldPieceTranslationUnit = newUnit; + }); + + SetCheckBoxValue(ui->checkBoxRelativeTranslation, true); + connect(ui->checkBoxRelativeTranslation, &QCheckBox::toggled, this, &VPMainWindow::on_RelativeTranslationChanged); + + // Rotate + ui->doubleSpinBoxCurrentPieceAngle->setValue(0); + + ui->toolButtonCurrentPieceRotationAnticlockwise->setChecked(true); + ui->checkBoxTransformSeparately->setChecked(false); + + QPushButton *bApply = ui->buttonBox->button(QDialogButtonBox::Apply); + SCASSERT(bApply != nullptr) + connect(bApply, &QPushButton::clicked, this, &VPMainWindow::on_ApplyPieceTransformation); + + QPushButton *bReset = ui->buttonBox->button(QDialogButtonBox::Reset); + SCASSERT(bReset != nullptr) + connect(bReset, &QPushButton::clicked, this, &VPMainWindow::on_ResetPieceTransformationSettings); } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitPropertyTabCurrentSheet() { - // FIXME ---- For MVP we hide a few things. To be displayed when functions there - ui->pushButtonSheetRemoveUnusedLength->hide(); - ui->groupBoxSheetControl->hide(); + connect(ui->lineEditSheetName, &QLineEdit::textEdited, this, [this](const QString &text) + { + if (not m_layout.isNull()) + { + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + sheet->SetName(text); + LayoutWasSaved(false); - // some of the UI Elements are connected to the slots via auto-connect - // see https://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect + if(m_carrousel != nullptr) + { + m_carrousel->RefreshSheetNames(); + } + } + } + }); - // -------------------- layout width, length, orientation ------------------------ - connect(ui->doubleSpinBoxSheetWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + // -------------------- layout units --------------------------- + ui->comboBoxLayoutUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm))); + ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm))); + ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch))); + ui->comboBoxLayoutUnit->addItem(tr("Pixels"), QVariant(UnitsToStr(Unit::Px))); + + VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); + const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(UnitsToStr(settings->LayoutUnit())); + if (indexUnit != -1) + { + ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); + } + + connect(ui->comboBoxLayoutUnit, QOverload::of(&QComboBox::currentIndexChanged), + this, &VPMainWindow::on_ConvertPaperSize); + + // -------------------- sheet template --------------------------- + VAbstractLayoutDialog::InitTemplates(ui->comboBoxSheetTemplates); + + connect(ui->comboBoxSheetTemplates, QOverload::of(&QComboBox::currentIndexChanged), + this, [this]{SheetSize(SheetTemplate());}); + + // -------------------- paper size --------------------------- + MinimumSheetPaperSize(); + + const QString suffix = " " + UnitsToStr(LayoutUnit(), true); + + ui->doubleSpinBoxSheetPaperWidth->setSuffix(suffix); + ui->doubleSpinBoxSheetPaperHeight->setSuffix(suffix); + + connect(ui->doubleSpinBoxSheetPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, &VPMainWindow::on_SheetSizeChanged); - connect(ui->doubleSpinBoxSheetLength, QOverload::of(&QDoubleSpinBox::valueChanged), this, + connect(ui->doubleSpinBoxSheetPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, &VPMainWindow::on_SheetSizeChanged); - connect(ui->radioButtonSheetPortrait, QOverload::of(&QRadioButton::clicked), this, + connect(ui->toolButtonSheetPortraitOritation, &QToolButton::toggled, this, &VPMainWindow::on_SheetOrientationChanged); - connect(ui->radioButtonSheetLandscape, QOverload::of(&QRadioButton::clicked), this, + connect(ui->toolButtonSheetLandscapeOrientation, &QToolButton::toggled, this, &VPMainWindow::on_SheetOrientationChanged); // -------------------- margins ------------------------ + ui->doubleSpinBoxSheetMarginLeft->setSuffix(suffix); + ui->doubleSpinBoxSheetMarginRight->setSuffix(suffix); + ui->doubleSpinBoxSheetMarginTop->setSuffix(suffix); + ui->doubleSpinBoxSheetMarginBottom->setSuffix(suffix); + connect(ui->doubleSpinBoxSheetMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, &VPMainWindow::on_SheetMarginChanged); connect(ui->doubleSpinBoxSheetMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, @@ -480,111 +716,176 @@ void VPMainWindow::InitPropertyTabCurrentSheet() connect(ui->doubleSpinBoxSheetMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, &VPMainWindow::on_SheetMarginChanged); - // ------------------- follow grainline ----------------------- - connect(ui->radioButtonSheetFollowGrainlineNo, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_SheetFollowGrainlineChanged); - connect(ui->radioButtonSheetFollowGrainlineVertical, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_SheetFollowGrainlineChanged); - connect(ui->radioButtonSheetFollowGrainlineHorizontal, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_SheetFollowGrainlineChanged); - - // -------------------- sheet template --------------------------- - - // FIXME: find a nicer way to initiliase it - QVector sheetTemplates = QVector(); - sheetTemplates.append(PaperSizeTemplate::A0); - sheetTemplates.append(PaperSizeTemplate::A1); - sheetTemplates.append(PaperSizeTemplate::A2); - sheetTemplates.append(PaperSizeTemplate::A3); - sheetTemplates.append(PaperSizeTemplate::A4); - sheetTemplates.append(PaperSizeTemplate::Letter); - sheetTemplates.append(PaperSizeTemplate::Legal); - sheetTemplates.append(PaperSizeTemplate::Tabloid); - sheetTemplates.append(PaperSizeTemplate::Roll24in); - sheetTemplates.append(PaperSizeTemplate::Roll30in); - sheetTemplates.append(PaperSizeTemplate::Roll36in); - sheetTemplates.append(PaperSizeTemplate::Roll42in); - sheetTemplates.append(PaperSizeTemplate::Roll44in); - sheetTemplates.append(PaperSizeTemplate::Roll48in); - sheetTemplates.append(PaperSizeTemplate::Roll62in); - sheetTemplates.append(PaperSizeTemplate::Roll72in); - sheetTemplates.append(PaperSizeTemplate::Custom); - - ui->comboBoxSheetTemplate->blockSignals(true); - VPLayoutSettings::PopulateComboBox(&sheetTemplates, ui->comboBoxSheetTemplate); - ui->comboBoxSheetTemplate->blockSignals(false); - - ui->comboBoxSheetTemplate->setCurrentIndex(0); - - // ---------------------- export format -------------------------- - - VPExporter exporter; - for (auto &v : exporter.InitFormats()) + connect(ui->checkBoxLayoutIgnoreFileds, &QCheckBox::stateChanged, this, [this](int state) { - ui->comboBoxSheetExportFormat->addItem(v.first, QVariant(static_cast(v.second))); - } + if (not m_layout.isNull()) + { + ui->doubleSpinBoxSheetMarginLeft->setDisabled(state != 0); + ui->doubleSpinBoxSheetMarginRight->setDisabled(state != 0); + ui->doubleSpinBoxSheetMarginTop->setDisabled(state != 0); + ui->doubleSpinBoxSheetMarginBottom->setDisabled(state != 0); + + m_layout->LayoutSettings().SetIgnoreMargins(state != 0); + LayoutWasSaved(false); + m_tileFactory->refreshTileInfos(); + m_graphicsView->RefreshLayout(); + } + }); + + ui->groupBoxSheetGrid->setVisible(false); // temporary hide } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitPropertyTabTiles() { - // -------------------- layout width, length, orientation ------------------------ - connect(ui->doubleSpinBoxTilesWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_TilesSizeChanged); - connect(ui->doubleSpinBoxTilesLength, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_TilesSizeChanged); - connect(ui->radioButtonTilesPortrait, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_TilesOrientationChanged); - connect(ui->radioButtonTilesLandscape, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_TilesOrientationChanged); - // -------------------- tiles template - QVector tilesTemplates = QVector(); - tilesTemplates.append(PaperSizeTemplate::A0); - tilesTemplates.append(PaperSizeTemplate::A1); - tilesTemplates.append(PaperSizeTemplate::A2); - tilesTemplates.append(PaperSizeTemplate::A3); - tilesTemplates.append(PaperSizeTemplate::A4); - tilesTemplates.append(PaperSizeTemplate::Letter); - tilesTemplates.append(PaperSizeTemplate::Legal); - tilesTemplates.append(PaperSizeTemplate::Custom); + VAbstractLayoutDialog::InitTileTemplates(ui->comboBoxTileTemplates, true); - ui->comboBoxTilesTemplate->blockSignals(true); - VPLayoutSettings::PopulateComboBox(&tilesTemplates, ui->comboBoxTilesTemplate); - ui->comboBoxTilesTemplate->blockSignals(false); + connect(ui->comboBoxTileTemplates, QOverload::of(&QComboBox::currentIndexChanged), + this, [this]{TileSize(TileTemplate());}); - ui->comboBoxTilesTemplate->setCurrentIndex(4); //A4 + // -------------------- paper size --------------------------- + MinimumTilePaperSize(); + const QString suffix = " " + UnitsToStr(LayoutUnit(), true); + + ui->doubleSpinBoxTilePaperWidth->setSuffix(suffix); + ui->doubleSpinBoxTilePaperHeight->setSuffix(suffix); + + connect(ui->doubleSpinBoxTilePaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_TilesSizeChanged); + connect(ui->doubleSpinBoxTilePaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_TilesSizeChanged); + connect(ui->toolButtonTilePortraitOrientation, &QToolButton::toggled, this, + &VPMainWindow::on_TilesOrientationChanged); + connect(ui->toolButtonTileLandscapeOrientation, &QToolButton::toggled, this, + &VPMainWindow::on_TilesOrientationChanged); // -------------------- margins ------------------------ - connect(ui->doubleSpinBoxTilesMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_TilesMarginChanged); - connect(ui->doubleSpinBoxTilesMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_TilesMarginChanged); - connect(ui->doubleSpinBoxTilesMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_TilesMarginChanged); - connect(ui->doubleSpinBoxTilesMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_TilesMarginChanged); -} + ui->doubleSpinBoxTileMarginLeft->setSuffix(suffix); + ui->doubleSpinBoxTileMarginRight->setSuffix(suffix); + ui->doubleSpinBoxTileMarginTop->setSuffix(suffix); + ui->doubleSpinBoxTileMarginBottom->setSuffix(suffix); + connect(ui->doubleSpinBoxTileMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_TilesMarginChanged); + connect(ui->doubleSpinBoxTileMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_TilesMarginChanged); + connect(ui->doubleSpinBoxTileMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_TilesMarginChanged); + connect(ui->doubleSpinBoxTileMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_TilesMarginChanged); + + connect(ui->checkBoxTileIgnoreFileds, &QCheckBox::stateChanged, this, [this](int state) + { + if (not m_layout.isNull()) + { + ui->doubleSpinBoxTileMarginLeft->setDisabled(state != 0); + ui->doubleSpinBoxTileMarginRight->setDisabled(state != 0); + ui->doubleSpinBoxTileMarginTop->setDisabled(state != 0); + ui->doubleSpinBoxTileMarginBottom->setDisabled(state != 0); + + m_layout->LayoutSettings().SetIgnoreTilesMargins(state != 0); + LayoutWasSaved(false); + m_tileFactory->refreshTileInfos(); + m_graphicsView->RefreshLayout(); + } + }); + + // -------------------- control ------------------------ + connect(ui->checkBoxTilesShowTiles, &QCheckBox::toggled, this, [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetShowTiles(checked); + LayoutWasSaved(false); + m_graphicsView->RefreshLayout(); + } + }); +} //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitPropertyTabLayout() { - // FIXME ---- For MVP we hide a few things. To be displayed when functions there - ui->groupBoxLayoutControl->hide(); + connect(ui->lineEditLayoutName, &QLineEdit::textEdited, this, [this](const QString &text) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetTitle(text); + LayoutWasSaved(false); + } + }); - // -------------------- init the unit combobox --------------------- - ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm))); - ui->comboBoxLayoutUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm))); - ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch))); + connect(ui->plainTextEditLayoutDescription, &QPlainTextEdit::textChanged, this, [this]() + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetDescription(ui->plainTextEditLayoutDescription->toPlainText()); + LayoutWasSaved(false); + } + }); - // set default unit - TODO when we have the setting for the unit -// const qint32 indexUnit = -1;//ui->comboBoxLayoutUnit->findData(qApp->ValentinaSettings()->GetUnit()); -// if (indexUnit != -1) -// { -// ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); -// } + connect(ui->checkBoxLayoutWarningPiecesSuperposition, &QCheckBox::toggled, this, [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetWarningSuperpositionOfPieces(checked); + LayoutWasSaved(false); + // TODO update the QGraphicView + } + }); + + connect(ui->checkBoxLayoutWarningPiecesOutOfBound, &QCheckBox::toggled, this, [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetWarningPiecesOutOfBound(checked); + LayoutWasSaved(false); + // TODO update the QGraphicView + } + }); + + connect(ui->checkBoxSheetStickyEdges, &QCheckBox::toggled, this, [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetStickyEdges(checked); + LayoutWasSaved(false); + } + }); + + connect(ui->checkBoxFollowGainline, &QCheckBox::toggled, this, [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetFollowGrainline(checked); + LayoutWasSaved(false); + // TODO update the QGraphicView + } + }); + + VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); + ui->doubleSpinBoxSheetPiecesGap->setMaximum( + UnitConvertor(VPSettings::GetMaxLayoutPieceGap(), Unit::Px, settings->LayoutUnit())); + ui->doubleSpinBoxSheetPiecesGap->setSuffix(" " + UnitsToStr(LayoutUnit(), true)); + connect(ui->doubleSpinBoxSheetPiecesGap, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](double d) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetPiecesGapConverted(d); + LayoutWasSaved(false); + // TODO update the QGraphicView + } + }); + + connect(ui->pushButtonLayoutExport, &QPushButton::clicked, this, [this]() + { + if (not m_layout.isNull()) + { + // TODO export layout + } + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -600,158 +901,307 @@ void VPMainWindow::InitCarrousel() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::SetPropertiesData() { - if(m_layout == nullptr) - { - // TODO : hide the tabs when there is no layout - } - else - { - SetPropertyTabCurrentPieceData(); - SetPropertyTabSheetData(); - SetPropertyTabTilesData(); - SetPropertyTabLayoutData(); - } + SetPropertyTabCurrentPieceData(); + SetPropertyTabSheetData(); + SetPropertyTabTilesData(); + SetPropertyTabLayoutData(); } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::SetPropertyTabCurrentPieceData() { - if(m_selectedPieces.count() == 0) + QList selectedPieces = SelectedPieces(); + + if(selectedPieces.isEmpty()) { // show the content "no piece selected" + ui->labelCurrentPieceNoPieceSelected->setVisible(true); - ui->containerCurrentPieceNoData->setVisible(true); - ui->containerCurrentPieceData->setVisible(false); - ui->containerCurrentPieceMultipleData->setVisible(false); + ui->groupBoxCurrentPieceInfo->setVisible(false); + ui->groupBoxPieceTransformation->setVisible(false); + ui-> groupBoxCurrentPieceSeamline->setVisible(false); + ui->groupBoxCurrentPieceGeometry->setVisible(false); } - else if(m_selectedPieces.count() == 1) + else if(selectedPieces.count() == 1) { - // show the content "selected piece data" - ui->containerCurrentPieceNoData->setVisible(false); - ui->containerCurrentPieceData->setVisible(true); - ui->containerCurrentPieceMultipleData->setVisible(false); + ui->labelCurrentPieceNoPieceSelected->setVisible(false); - VPPiece *selectedPiece = m_selectedPieces.first(); + ui->groupBoxCurrentPieceInfo->setVisible(true); + ui->groupBoxPieceTransformation->setVisible(true); + ui-> groupBoxCurrentPieceSeamline->setVisible(true); + ui->groupBoxCurrentPieceGeometry->setVisible(true); + + VPPiecePtr selectedPiece = selectedPieces.first(); // set the value to the current piece - ui->lineEditCurrentPieceName->setText(selectedPiece->GetName()); - ui->plainTextEditCurrentPieceUUID->setPlainText(selectedPiece->GetUUID().toString()); + SetLineEditValue(ui->lineEditCurrentPieceName, selectedPiece->GetName()); + SetPlainTextEditValue(ui->plainTextEditCurrentPieceUUID, selectedPiece->GetUUID().toString()); -// ui->checkBoxCurrentPieceShowSeamline->setChecked(selectedPiece->GetShowSeamLine()); - ui->checkBoxCurrentPieceMirrorPiece->setChecked(selectedPiece->IsMirror()); +// SetCheckBoxValue(ui->checkBoxCurrentPieceShowSeamline, selectedPiece->GetShowSeamLine()); + SetCheckBoxValue(ui->checkBoxCurrentPieceMirrorPiece, selectedPiece->IsMirror()); - QPointF pos = selectedPiece->GetPosition(); - SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX, - UnitConvertor(pos.x(), Unit::Px, m_layout->LayoutSettings().GetUnit())); - SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY, - UnitConvertor(pos.y(), Unit::Px, m_layout->LayoutSettings().GetUnit())); + if (not ui->checkBoxRelativeTranslation->isChecked()) + { + QRectF rect = PiecesBoundingRect(selectedPieces); -// qreal angle = selectedPiece->GetRotation(); -// SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle); + ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue( + UnitConvertor(rect.topLeft().x(), Unit::Px, TranslateUnit())); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue( + UnitConvertor(rect.topLeft().y(), Unit::Px, TranslateUnit())); + } } else { // show the content "multiple pieces selected" - ui->containerCurrentPieceNoData->setVisible(false); - ui->containerCurrentPieceData->setVisible(false); - ui->containerCurrentPieceMultipleData->setVisible(true); + ui->labelCurrentPieceNoPieceSelected->setVisible(true); - // if needed in the future, we can show some properties that coul be edited for all the pieces + ui->groupBoxCurrentPieceInfo->setVisible(false); + ui->groupBoxPieceTransformation->setVisible(true); + ui->groupBoxCurrentPieceSeamline->setVisible(false); + ui->groupBoxCurrentPieceGeometry->setVisible(false); + + if (not ui->checkBoxRelativeTranslation->isChecked()) + { + QRectF rect = PiecesBoundingRect(selectedPieces); + + ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue( + UnitConvertor(rect.topLeft().x(), Unit::Px, TranslateUnit())); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue( + UnitConvertor(rect.topLeft().y(), Unit::Px, TranslateUnit())); + } } } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::SetPropertyTabSheetData() { - // set name // TODO FIXME make it better - ui->lineEditSheetName->setText(m_layout->GetFocusedSheet()->GetName()); - - // set Width / Length - QSizeF size = m_layout->LayoutSettings().GetSheetSizeConverted(); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetWidth, size.width()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetLength, size.height()); - - // Set Orientation - if(m_layout->LayoutSettings().GetOrientation() == PageOrientation::Portrait) + if (not m_layout.isNull()) { - ui->radioButtonSheetPortrait->setChecked(true); + ui->groupBoxSheetInfos->setDisabled(false); + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + SetLineEditValue(ui->lineEditSheetName, not sheet.isNull() ? sheet->GetName() : QString()); + + ui->groupBoxPaperFormat->setDisabled(false); + const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(UnitsToStr(m_layout->LayoutSettings().GetUnit())); + if (indexUnit != -1) + { + ui->comboBoxLayoutUnit->blockSignals(true); + ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); + ui->comboBoxLayoutUnit->blockSignals(false); + } + else + { + ui->comboBoxLayoutUnit->setCurrentIndex(0); + } + + const QString suffix = " " + UnitsToStr(LayoutUnit(), true); + + ui->doubleSpinBoxSheetPaperWidth->setSuffix(suffix); + ui->doubleSpinBoxSheetPaperHeight->setSuffix(suffix); + + ui->doubleSpinBoxSheetMarginLeft->setSuffix(suffix); + ui->doubleSpinBoxSheetMarginRight->setSuffix(suffix); + ui->doubleSpinBoxSheetMarginTop->setSuffix(suffix); + ui->doubleSpinBoxSheetMarginBottom->setSuffix(suffix); + + // set Width / Length + QSizeF size = m_layout->LayoutSettings().GetSheetSizeConverted(); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, size.width()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, size.height()); + + SheetPaperSizeChanged(); + FindSheetTemplate(); + + // set margins + ui->groupBoxSheetMargin->setDisabled(false); + QMarginsF margins = m_layout->LayoutSettings().GetSheetMarginsConverted(); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, margins.bottom()); + + CorrectSheetMaxMargins(); + + const bool ignoreMargins = m_layout->LayoutSettings().IgnoreMargins(); + SetCheckBoxValue(ui->checkBoxLayoutIgnoreFileds, ignoreMargins); + + ui->doubleSpinBoxSheetMarginLeft->setDisabled(ignoreMargins); + ui->doubleSpinBoxSheetMarginRight->setDisabled(ignoreMargins); + ui->doubleSpinBoxSheetMarginTop->setDisabled(ignoreMargins); + ui->doubleSpinBoxSheetMarginBottom->setDisabled(ignoreMargins); + + // set placement grid + ui->groupBoxSheetGrid->setDisabled(false); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth, + m_layout->LayoutSettings().GetGridColWidthConverted()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridRowHeight, + m_layout->LayoutSettings().GetGridRowHeightConverted()); + + SetCheckBoxValue(ui->checkBoxSheetShowGrid, m_layout->LayoutSettings().GetShowGrid()); + + ui->groupBoxSheetExport->setDisabled(false); } else { - ui->radioButtonSheetLandscape->setChecked(true); + ui->groupBoxSheetInfos->setDisabled(true); + SetLineEditValue(ui->lineEditSheetName, QString()); + + ui->groupBoxPaperFormat->setDisabled(true); + + ui->comboBoxLayoutUnit->blockSignals(true); + ui->comboBoxLayoutUnit->setCurrentIndex(-1); + ui->comboBoxLayoutUnit->blockSignals(false); + + ui->comboBoxSheetTemplates->blockSignals(true); + ui->comboBoxSheetTemplates->setCurrentIndex(-1); + ui->comboBoxSheetTemplates->blockSignals(false); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, 0); + + ui->groupBoxSheetMargin->setDisabled(true); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, 0); + + SetCheckBoxValue(ui->checkBoxLayoutIgnoreFileds, false); + + ui->groupBoxSheetGrid->setDisabled(true); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridRowHeight, 0); + + SetCheckBoxValue(ui->checkBoxSheetShowGrid, false); + + ui->groupBoxSheetExport->setDisabled(true); } - - // set margins - QMarginsF margins = m_layout->LayoutSettings().GetSheetMarginsConverted(); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, margins.bottom()); - - // set placement grid - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth, m_layout->LayoutSettings().GetGridColWidthConverted()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridRowHeight, m_layout->LayoutSettings().GetGridRowHeightConverted()); - SetCheckBoxValue(ui->checkBoxSheetShowGrid, m_layout->LayoutSettings().GetShowGrid()); - - // set pieces gap - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, m_layout->LayoutSettings().GetPiecesGapConverted()); - - // set the checkboxes - SetCheckBoxValue(ui->checkBoxSheetStickyEdges, m_layout->LayoutSettings().GetStickyEdges()); } - //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::SetPropertyTabTilesData() { - // set Width / Length - QSizeF size = m_layout->LayoutSettings().GetTilesSizeConverted(); - SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesWidth, size.width()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesLength, size.height()); - - // Set Orientation - if(m_layout->LayoutSettings().GetTilesOrientation() == PageOrientation::Portrait) + if (not m_layout.isNull()) { - ui->radioButtonSheetPortrait->setChecked(true); + ui->groupBoxTilePaperFormat->setDisabled(false); + // set Width / Length + QSizeF size = m_layout->LayoutSettings().GetTilesSizeConverted(); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperWidth, size.width()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperHeight, size.height()); + + TilePaperSizeChanged(); + FindTileTemplate(); + + // set margins + ui->groupBoxTileMargins->setDisabled(false); + QMarginsF margins = m_layout->LayoutSettings().GetTilesMarginsConverted(); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginLeft, margins.left()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginTop, margins.top()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginRight, margins.right()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginBottom, margins.bottom()); + + CorrectTileMaxMargins(); + + const bool ignoreMargins = m_layout->LayoutSettings().IgnoreTilesMargins(); + SetCheckBoxValue(ui->checkBoxTileIgnoreFileds, ignoreMargins); + + ui->doubleSpinBoxTileMarginLeft->setDisabled(ignoreMargins); + ui->doubleSpinBoxTileMarginRight->setDisabled(ignoreMargins); + ui->doubleSpinBoxTileMarginTop->setDisabled(ignoreMargins); + ui->doubleSpinBoxTileMarginBottom->setDisabled(ignoreMargins); + + const QString suffix = " " + UnitsToStr(LayoutUnit(), true); + + ui->doubleSpinBoxTilePaperWidth->setSuffix(suffix); + ui->doubleSpinBoxTilePaperHeight->setSuffix(suffix); + + ui->doubleSpinBoxTileMarginLeft->setSuffix(suffix); + ui->doubleSpinBoxTileMarginRight->setSuffix(suffix); + ui->doubleSpinBoxTileMarginTop->setSuffix(suffix); + ui->doubleSpinBoxTileMarginBottom->setSuffix(suffix); + + ui->groupBoxTilesControl->setDisabled(false); + + SetCheckBoxValue(ui->checkBoxTilesShowTiles, m_layout->LayoutSettings().GetShowTiles()); + + ui->groupBoxTilesExport->setDisabled(false); } else { - ui->radioButtonSheetLandscape->setChecked(true); + ui->groupBoxTilePaperFormat->setDisabled(true); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperWidth, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperHeight, 0); + + ui->groupBoxTileMargins->setDisabled(true); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginLeft, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginTop, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginRight, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginBottom, 0); + + SetCheckBoxValue(ui->checkBoxTileIgnoreFileds, false); + + ui->groupBoxTilesControl->setDisabled(true); + + SetCheckBoxValue(ui->checkBoxTilesShowTiles, false); + + ui->groupBoxTilesExport->setDisabled(true); } - - // set margins - QMarginsF margins = m_layout->LayoutSettings().GetTilesMarginsConverted(); - SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginLeft, margins.left()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginTop, margins.top()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginRight, margins.right()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginBottom, margins.bottom()); - - // set "show tiles" checkbox - SetCheckBoxValue(ui->checkBoxTilesShowTiles, m_layout->LayoutSettings().GetShowTiles()); } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::SetPropertyTabLayoutData() { - // set the title and description - ui->lineEditLayoutName->setText(m_layout->LayoutSettings().GetTitle()); - ui->plainTextEditLayoutDescription->setPlainText(m_layout->LayoutSettings().GetDescription()); - - // set Unit - int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->LayoutSettings().GetUnit()))); - if(index != -1) + if (not m_layout.isNull()) { - ui->comboBoxLayoutUnit->blockSignals(true); // FIXME: is there a better way to block the signals? - ui->comboBoxLayoutUnit->setCurrentIndex(index); - ui->comboBoxLayoutUnit->blockSignals(false); - } + // set the title and description + ui->groupBoxLayoutInfos->setDisabled(false); + SetLineEditValue(ui->lineEditLayoutName, m_layout->LayoutSettings().GetTitle()); + SetPlainTextEditValue(ui->plainTextEditLayoutDescription, m_layout->LayoutSettings().GetDescription()); - // set controls - SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, - m_layout->LayoutSettings().GetWarningPiecesOutOfBound()); - SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, - m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()); + // set controls + ui->groupBoxLayoutControl->setDisabled(false); + SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, + m_layout->LayoutSettings().GetWarningPiecesOutOfBound()); + SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, + m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()); + SetCheckBoxValue(ui->checkBoxSheetStickyEdges, + m_layout->LayoutSettings().GetStickyEdges()); + SetCheckBoxValue(ui->checkBoxFollowGainline, + m_layout->LayoutSettings().GetFollowGrainline()); + + // set pieces gap + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, m_layout->LayoutSettings().GetPiecesGapConverted()); + + ui->doubleSpinBoxSheetPiecesGap->setSuffix(" " + UnitsToStr(LayoutUnit(), true)); + + ui->groupBoxLayoutExport->setDisabled(false); + } + else + { + ui->groupBoxLayoutInfos->setDisabled(true); + SetLineEditValue(ui->lineEditLayoutName, QString()); + SetPlainTextEditValue(ui->plainTextEditLayoutDescription, QString()); + + ui->groupBoxLayoutControl->setDisabled(true); + + ui->comboBoxLayoutUnit->blockSignals(true); + ui->comboBoxLayoutUnit->setCurrentIndex(-1); + ui->comboBoxLayoutUnit->blockSignals(false); + + // set controls + SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, false); + SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, false); + SetCheckBoxValue(ui->checkBoxSheetStickyEdges, false); + SetCheckBoxValue(ui->checkBoxFollowGainline, false); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, 0); + + ui->groupBoxLayoutExport->setDisabled(true); + } } @@ -830,22 +1280,6 @@ void VPMainWindow::InitScaleToolBar() ui->toolBarScale->addSeparator(); } -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value) -{ - spinBox->blockSignals(true); - spinBox->setValue(value); - spinBox->blockSignals(false); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value) -{ - checkbox->blockSignals(true); - checkbox->setChecked(value); - checkbox->blockSignals(false); -} - //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::UpdateWindowTitle() { @@ -957,7 +1391,7 @@ auto VPMainWindow::MaybeSave() -> bool if (this->isWindowModified()) { QScopedPointer messageBox(new QMessageBox(tr("Unsaved changes"), - tr("Measurements have been modified.\n" + tr("Layout has been modified.\n" "Do you want to save your changes?"), QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel, this, Qt::Sheet)); @@ -993,75 +1427,75 @@ auto VPMainWindow::MaybeSave() -> bool //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::generateTiledPdf(QString fileName) { - if(not fileName.isEmpty()) - { - m_graphicsView->PrepareForExport(); - m_tileFactory->refreshTileInfos(); +// if(not fileName.isEmpty()) +// { +// m_graphicsView->PrepareForExport(); +// m_tileFactory->refreshTileInfos(); - PageOrientation tilesOrientation = m_layout->LayoutSettings().GetTilesOrientation(); +// PageOrientation tilesOrientation = m_layout->LayoutSettings().GetTilesOrientation(); - // ------------- Set up the printer - QScopedPointer printer(new QPrinter()); +// // ------------- Set up the printer +// QScopedPointer printer(new QPrinter()); - printer->setCreator(QGuiApplication::applicationDisplayName()+QChar(QChar::Space)+ - QCoreApplication::applicationVersion()); - printer->setPageOrientation(QPageLayout::Portrait); // in the pdf file the pages should always be in portrait +// printer->setCreator(QGuiApplication::applicationDisplayName()+QChar(QChar::Space)+ +// QCoreApplication::applicationVersion()); +// printer->setPageOrientation(QPageLayout::Portrait); // in the pdf file the pages should always be in portrait - // here we might need to so some rounding for the size. - printer->setPageSize(QPageSize(m_layout->LayoutSettings().GetTilesSize(Unit::Mm), - QPageSize::Millimeter)); - printer->setFullPage(true); +// // here we might need to so some rounding for the size. +// printer->setPageSize(QPageSize(m_layout->LayoutSettings().GetTilesSize(Unit::Mm), +// QPageSize::Millimeter)); +// printer->setFullPage(true); - #ifdef Q_OS_MAC - printer->setOutputFormat(QPrinter::NativeFormat); - #else - printer->setOutputFormat(QPrinter::PdfFormat); - #endif +// #ifdef Q_OS_MAC +// printer->setOutputFormat(QPrinter::NativeFormat); +// #else +// printer->setOutputFormat(QPrinter::PdfFormat); +// #endif - printer->setOutputFileName(fileName); - printer->setResolution(static_cast(PrintDPI)); - printer->setDocName(m_layout->GetFocusedSheet()->GetName()); +// printer->setOutputFileName(fileName); +// printer->setResolution(static_cast(PrintDPI)); +// printer->setDocName(m_layout->GetFocusedSheet()->GetName()); - // ------------- Set up the painter - QPainter painter; - if (not painter.begin(printer.data())) - { // failed to open file - qCritical() << tr("Failed to open file, is it writable?"); - return; - } - painter.setFont( QFont( QStringLiteral("Arial"), 8, QFont::Normal ) ); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setBrush ( QBrush ( Qt::NoBrush ) ); +// // ------------- Set up the painter +// QPainter painter; +// if (not painter.begin(printer.data())) +// { // failed to open file +// qCritical() << tr("Failed to open file, is it writable?"); +// return; +// } +// painter.setFont( QFont( QStringLiteral("Arial"), 8, QFont::Normal ) ); +// painter.setRenderHint(QPainter::Antialiasing, true); +// painter.setBrush ( QBrush ( Qt::NoBrush ) ); - if(tilesOrientation == PageOrientation::Landscape) - { - // The landscape tiles have to be rotated, because the pages - // stay portrait in the pdf - painter.rotate(90); - painter.translate(0, -ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm)); - } +// if(tilesOrientation == PageOrientation::Landscape) +// { +// // The landscape tiles have to be rotated, because the pages +// // stay portrait in the pdf +// painter.rotate(90); +// painter.translate(0, -ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm)); +// } - for(int row=0;rowgetRowNb();row++) // for each row of the tiling grid - { - for(int col=0;colgetColNb();col++) // for each column of tiling grid - { - if(not (row == 0 && col == 0)) - { - if (not printer->newPage()) - { - qWarning("failed in flushing page to disk, disk full?"); - return; - } - } +// for(int row=0;rowgetRowNb();row++) // for each row of the tiling grid +// { +// for(int col=0;colgetColNb();col++) // for each column of tiling grid +// { +// if(not (row == 0 && col == 0)) +// { +// if (not printer->newPage()) +// { +// qWarning("failed in flushing page to disk, disk full?"); +// return; +// } +// } - m_tileFactory->drawTile(&painter, m_graphicsView, row, col); - } - } +// m_tileFactory->drawTile(&painter, m_graphicsView, row, col); +// } +// } - painter.end(); +// painter.end(); - m_graphicsView->CleanAfterExport(); - } +// m_graphicsView->CleanAfterExport(); +// } } //--------------------------------------------------------------------------------------------------------------------- @@ -1140,6 +1574,291 @@ void VPMainWindow::ConnectToPreferences(const QSharedPointer QList +{ + QList selectedPieces; + if (not m_layout.isNull()) + { + VPSheetPtr activeSheet = m_layout->GetFocusedSheet(); + if (not activeSheet.isNull()) + { + selectedPieces = activeSheet->GetSelectedPieces(); + } + } + + return selectedPieces; +} + +//--------------------------------------------------------------------------------------------------------------------- +Unit VPMainWindow::TranslateUnit() const +{ + return StrToUnits(ui->comboBoxTranslateUnit->currentData().toString()); +} + +//--------------------------------------------------------------------------------------------------------------------- +Unit VPMainWindow::LayoutUnit() const +{ + return StrToUnits(ui->comboBoxLayoutUnit->currentData().toString()); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VPMainWindow::Template(VAbstractLayoutDialog::PaperSizeTemplate t) const -> QSizeF +{ + const Unit layoutUnit = LayoutUnit(); + + switch (t) + { + case VAbstractLayoutDialog::PaperSizeTemplate::A0: + case VAbstractLayoutDialog::PaperSizeTemplate::A1: + case VAbstractLayoutDialog::PaperSizeTemplate::A2: + case VAbstractLayoutDialog::PaperSizeTemplate::A3: + case VAbstractLayoutDialog::PaperSizeTemplate::A4: + case VAbstractLayoutDialog::PaperSizeTemplate::Letter: + case VAbstractLayoutDialog::PaperSizeTemplate::Legal: + case VAbstractLayoutDialog::PaperSizeTemplate::Tabloid: + return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit); + case VAbstractLayoutDialog::PaperSizeTemplate::Roll24in: + case VAbstractLayoutDialog::PaperSizeTemplate::Roll30in: + case VAbstractLayoutDialog::PaperSizeTemplate::Roll36in: + case VAbstractLayoutDialog::PaperSizeTemplate::Roll42in: + case VAbstractLayoutDialog::PaperSizeTemplate::Roll44in: + case VAbstractLayoutDialog::PaperSizeTemplate::Roll48in: + case VAbstractLayoutDialog::PaperSizeTemplate::Roll62in: + case VAbstractLayoutDialog::PaperSizeTemplate::Roll72in: + return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit); + case VAbstractLayoutDialog::PaperSizeTemplate::Custom: + return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit); + default: + break; + } + return QSizeF(); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VPMainWindow::SheetTemplate() const -> QSizeF +{ + auto t = static_cast(ui->comboBoxSheetTemplates->currentData().toInt()); + return Template(t); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VPMainWindow::TileTemplate() const -> QSizeF +{ + auto t = static_cast(ui->comboBoxTileTemplates->currentData().toInt()); + return Template(t); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::SheetSize(const QSizeF &size) +{ + m_oldLayoutUnit = LayoutUnit(); + ui->doubleSpinBoxSheetPaperWidth->setMaximum(FromPixel(QIMAGE_MAX, m_oldLayoutUnit)); + ui->doubleSpinBoxSheetPaperHeight->setMaximum(FromPixel(QIMAGE_MAX, m_oldLayoutUnit)); + + ui->doubleSpinBoxSheetPaperWidth->setValue(size.width()); + ui->doubleSpinBoxSheetPaperHeight->setValue(size.height()); + + CorrectPaperDecimals(); + SheetPaperSizeChanged(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::TileSize(const QSizeF &size) +{ + m_oldLayoutUnit = LayoutUnit(); + ui->doubleSpinBoxTilePaperWidth->setMaximum(FromPixel(QIMAGE_MAX, m_oldLayoutUnit)); + ui->doubleSpinBoxTilePaperHeight->setMaximum(FromPixel(QIMAGE_MAX, m_oldLayoutUnit)); + + ui->doubleSpinBoxTilePaperWidth->setValue(size.width()); + ui->doubleSpinBoxTilePaperHeight->setValue(size.height()); + + CorrectPaperDecimals(); + TilePaperSizeChanged(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::CorrectPaperDecimals() +{ + switch (m_oldLayoutUnit) + { + case Unit::Cm: + case Unit::Mm: + case Unit::Px: + ui->doubleSpinBoxSheetPaperWidth->setDecimals(2); + ui->doubleSpinBoxSheetPaperHeight->setDecimals(2); + + ui->doubleSpinBoxTilePaperWidth->setDecimals(2); + ui->doubleSpinBoxTilePaperHeight->setDecimals(2); + + ui->doubleSpinBoxSheetMarginLeft->setDecimals(4); + ui->doubleSpinBoxSheetMarginRight->setDecimals(4); + ui->doubleSpinBoxSheetMarginTop->setDecimals(4); + ui->doubleSpinBoxSheetMarginBottom->setDecimals(4); + + ui->doubleSpinBoxTileMarginLeft->setDecimals(4); + ui->doubleSpinBoxTileMarginRight->setDecimals(4); + ui->doubleSpinBoxTileMarginTop->setDecimals(4); + ui->doubleSpinBoxTileMarginBottom->setDecimals(4); + + ui->doubleSpinBoxSheetPiecesGap->setDecimals(2); + break; + case Unit::Inch: + ui->doubleSpinBoxSheetPaperWidth->setDecimals(5); + ui->doubleSpinBoxSheetPaperHeight->setDecimals(5); + + ui->doubleSpinBoxTilePaperWidth->setDecimals(5); + ui->doubleSpinBoxTilePaperHeight->setDecimals(5); + + ui->doubleSpinBoxSheetMarginLeft->setDecimals(5); + ui->doubleSpinBoxSheetMarginRight->setDecimals(5); + ui->doubleSpinBoxSheetMarginTop->setDecimals(5); + ui->doubleSpinBoxSheetMarginBottom->setDecimals(5); + + ui->doubleSpinBoxTileMarginLeft->setDecimals(5); + ui->doubleSpinBoxTileMarginRight->setDecimals(5); + ui->doubleSpinBoxTileMarginTop->setDecimals(5); + ui->doubleSpinBoxTileMarginBottom->setDecimals(5); + + ui->doubleSpinBoxSheetPiecesGap->setDecimals(5); + break; + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::SheetPaperSizeChanged() +{ + bool portrait = ui->doubleSpinBoxSheetPaperHeight->value() >= ui->doubleSpinBoxSheetPaperWidth->value(); + + ui->toolButtonSheetPortraitOritation->blockSignals(true); + ui->toolButtonSheetPortraitOritation->setChecked(portrait); + ui->toolButtonSheetPortraitOritation->blockSignals(false); + + ui->toolButtonSheetLandscapeOrientation->blockSignals(true); + ui->toolButtonSheetLandscapeOrientation->setChecked(not portrait); + ui->toolButtonSheetLandscapeOrientation->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::TilePaperSizeChanged() +{ + bool portrait = ui->doubleSpinBoxTilePaperHeight->value() >= ui->doubleSpinBoxTilePaperWidth->value(); + + ui->toolButtonTilePortraitOrientation->blockSignals(true); + ui->toolButtonTilePortraitOrientation->setChecked(portrait); + ui->toolButtonTilePortraitOrientation->blockSignals(false); + + ui->toolButtonTileLandscapeOrientation->blockSignals(true); + ui->toolButtonTileLandscapeOrientation->setChecked(not portrait); + ui->toolButtonTileLandscapeOrientation->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::MinimumSheetPaperSize() +{ + const qreal value = UnitConvertor(1, Unit::Px, m_oldLayoutUnit); + ui->doubleSpinBoxSheetPaperWidth->setMinimum(value); + ui->doubleSpinBoxSheetPaperHeight->setMinimum(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::MinimumTilePaperSize() +{ + const qreal value = UnitConvertor(1, Unit::Px, m_oldLayoutUnit); + ui->doubleSpinBoxTilePaperWidth->setMinimum(value); + ui->doubleSpinBoxTilePaperHeight->setMinimum(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::FindTemplate(QComboBox *box, qreal width, qreal height) +{ + SCASSERT(box != nullptr) + const Unit paperUnit = LayoutUnit(); + + const int max = static_cast(VAbstractLayoutDialog::PaperSizeTemplate::Custom); + for (int i=0; i < max; ++i) + { + const QSizeF tmplSize = VAbstractLayoutDialog::GetTemplateSize( + static_cast(i), paperUnit); + if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize) + { + box->blockSignals(true); + const int index = box->findData(i); + if (index != -1) + { + box->setCurrentIndex(index); + } + box->blockSignals(false); + return; + } + } + + box->blockSignals(true); + const int index = box->findData(max); + if (index != -1) + { + box->setCurrentIndex(index); + } + box->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::FindSheetTemplate() +{ + const qreal width = ui->doubleSpinBoxSheetPaperWidth->value(); + const qreal height = ui->doubleSpinBoxSheetPaperHeight->value(); + FindTemplate(ui->comboBoxSheetTemplates, width, height); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::FindTileTemplate() +{ + const qreal width = ui->doubleSpinBoxTilePaperWidth->value(); + const qreal height = ui->doubleSpinBoxTilePaperHeight->value(); + FindTemplate(ui->comboBoxTileTemplates, width, height); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::CorrectTileMaxMargins() +{ + const qreal tileWidth = ui->doubleSpinBoxTilePaperWidth->value(); + const qreal tileHeight = ui->doubleSpinBoxTilePaperHeight->value(); + + // 80%/2 of paper size for each field + const qreal tileWidthMargin = (tileWidth*80.0/100.0)/2.0; + const qreal tileHeightMargin = (tileHeight*80.0/100.0)/2.0; + + ui->doubleSpinBoxTileMarginLeft->setMaximum(tileWidthMargin); + ui->doubleSpinBoxTileMarginRight->setMaximum(tileWidthMargin); + ui->doubleSpinBoxTileMarginTop->setMaximum(tileHeightMargin); + ui->doubleSpinBoxTileMarginBottom->setMaximum(tileHeightMargin); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::CorrectSheetMaxMargins() +{ + const qreal sheetWidth = ui->doubleSpinBoxSheetPaperWidth->value(); + const qreal sheetHeight = ui->doubleSpinBoxSheetPaperHeight->value(); + + // 80%/2 of paper size for each field + const qreal sheetWidthMargin = (sheetWidth*80.0/100.0)/2.0; + const qreal sheetHeightMargin = (sheetHeight*80.0/100.0)/2.0; + + ui->doubleSpinBoxSheetMarginLeft->setMaximum(sheetWidthMargin); + ui->doubleSpinBoxSheetMarginRight->setMaximum(sheetWidthMargin); + ui->doubleSpinBoxSheetMarginTop->setMaximum(sheetHeightMargin); + ui->doubleSpinBoxSheetMarginBottom->setMaximum(sheetHeightMargin); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::CorrectMaxMargins() +{ + CorrectSheetMaxMargins(); + CorrectTileMaxMargins(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_actionNew_triggered() { @@ -1393,23 +2112,11 @@ void VPMainWindow::on_actionAboutPuzzle_triggered() } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index) +void VPMainWindow::on_LayoutUnitChanged(int index) { Q_UNUSED(index); QVariant comboBoxValue = ui->comboBoxLayoutUnit->currentData(); - - if(comboBoxValue == QVariant(UnitsToStr(Unit::Cm))) - { - m_layout->LayoutSettings().SetUnit(Unit::Cm); - } - else if(comboBoxValue == QVariant(UnitsToStr(Unit::Mm))) - { - m_layout->LayoutSettings().SetUnit(Unit::Mm); - } - else if(comboBoxValue == QVariant(UnitsToStr(Unit::Inch))) - { - m_layout->LayoutSettings().SetUnit(Unit::Inch); - } + m_layout->LayoutSettings().SetUnit(StrToUnits(comboBoxValue.toString())); SetPropertyTabCurrentPieceData(); SetPropertyTabSheetData(); @@ -1417,87 +2124,44 @@ void VPMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index) } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_lineEditSheetName_textChanged(const QString &text) +void VPMainWindow::on_SheetSizeChanged() { - m_layout->GetFocusedSheet()->SetName(text); - - if(m_carrousel != nullptr) + if (not m_layout.isNull()) { - m_carrousel->RefreshSheetNames(); + m_layout->LayoutSettings().SetSheetSizeConverted( + ui->doubleSpinBoxSheetPaperWidth->value(), + ui->doubleSpinBoxSheetPaperHeight->value()); + FindSheetTemplate(); + SheetPaperSizeChanged(); + CorrectMaxMargins(); + LayoutWasSaved(false); + + m_tileFactory->refreshTileInfos(); + m_graphicsView->RefreshLayout(); } } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_comboBoxSheetTemplate_currentIndexChanged(int index) +void VPMainWindow::on_SheetOrientationChanged(bool checked) { - PaperSizeTemplate tmpl = static_cast( - ui->comboBoxSheetTemplate->itemData(index).toInt() - ); - - QSizeF tmplSize = VPLayoutSettings::GetTemplateSize(tmpl); - if(!tmplSize.isEmpty()) + if (checked && not m_layout.isNull()) { - ui->doubleSpinBoxSheetWidth->blockSignals(true); - ui->doubleSpinBoxSheetLength->blockSignals(true); + const qreal width = ui->doubleSpinBoxSheetPaperWidth->value(); + const qreal height = ui->doubleSpinBoxSheetPaperHeight->value(); - ui->doubleSpinBoxSheetWidth->setValue(UnitConvertor(tmplSize.width(), Unit::Px, - m_layout->LayoutSettings().GetUnit())); - ui->doubleSpinBoxSheetLength->setValue(UnitConvertor(tmplSize.height(), Unit::Px, - m_layout->LayoutSettings().GetUnit())); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, height); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, width); - on_SheetSizeChanged(false); + m_layout->LayoutSettings().SetSheetSizeConverted(height, width); - ui->doubleSpinBoxSheetWidth->blockSignals(false); - ui->doubleSpinBoxSheetLength->blockSignals(false); + SheetPaperSizeChanged(); + CorrectMaxMargins(); + LayoutWasSaved(false); + m_tileFactory->refreshTileInfos(); + m_graphicsView->RefreshLayout(); } } -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_SheetSizeChanged(bool changedViaSizeCombobox) -{ - m_layout->LayoutSettings().SetSheetSizeConverted( - ui->doubleSpinBoxSheetWidth->value(), - ui->doubleSpinBoxSheetLength->value() - ); - - if(changedViaSizeCombobox) - { - ui->comboBoxSheetTemplate->blockSignals(true); - - // we don't try to get the right size, because it doesn't work well because of mm / inch conversion - int index = ui->comboBoxSheetTemplate->findData( - QVariant(static_cast(PaperSizeTemplate::Custom))); - - ui->comboBoxSheetTemplate->setCurrentIndex(index); - ui->comboBoxSheetTemplate->blockSignals(false); - } - - m_tileFactory->refreshTileInfos(); - - // TODO Undo / Redo - - m_graphicsView->RefreshLayout(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_SheetOrientationChanged() -{ - // Updates the orientation - if(ui->radioButtonSheetPortrait->isChecked()) - { - m_layout->LayoutSettings().SetOrientation(PageOrientation::Portrait); - } - else - { - m_layout->LayoutSettings().SetOrientation(PageOrientation::Landscape); - } - m_tileFactory->refreshTileInfos(); - - // TODO Undo / Redo - - m_graphicsView->RefreshLayout(); -} - //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked() { @@ -1515,16 +2179,17 @@ void VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_SheetMarginChanged() { - m_layout->LayoutSettings().SetSheetMarginsConverted( - ui->doubleSpinBoxSheetMarginLeft->value(), - ui->doubleSpinBoxSheetMarginTop->value(), - ui->doubleSpinBoxSheetMarginRight->value(), - ui->doubleSpinBoxSheetMarginBottom->value() - ); + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetSheetMarginsConverted( + ui->doubleSpinBoxSheetMarginLeft->value(), + ui->doubleSpinBoxSheetMarginTop->value(), + ui->doubleSpinBoxSheetMarginRight->value(), + ui->doubleSpinBoxSheetMarginBottom->value()); - // TODO Undo / Redo - - m_graphicsView->RefreshLayout(); + LayoutWasSaved(false); + m_graphicsView->RefreshLayout(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1549,93 +2214,58 @@ void VPMainWindow::on_doubleSpinBoxSheetGridRowHeight_valueChanged(double value) } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_comboBoxTilesTemplate_currentIndexChanged(int index) +void VPMainWindow::on_TilesSizeChanged() { - PaperSizeTemplate tmpl = static_cast( - ui->comboBoxTilesTemplate->itemData(index).toInt() - ); - - QSizeF tmplSize = VPLayoutSettings::GetTemplateSize(tmpl); - if(!tmplSize.isEmpty()) + if (not m_layout.isNull()) { - ui->doubleSpinBoxTilesWidth->blockSignals(true); - ui->doubleSpinBoxTilesLength->blockSignals(true); + m_layout->LayoutSettings().SetTilesSizeConverted( + ui->doubleSpinBoxTilePaperWidth->value(), + ui->doubleSpinBoxTilePaperHeight->value()); + FindTileTemplate(); + TilePaperSizeChanged(); + CorrectMaxMargins(); + LayoutWasSaved(false); - ui->doubleSpinBoxTilesWidth->setValue(UnitConvertor(tmplSize.width(), Unit::Px, - m_layout->LayoutSettings().GetUnit())); - ui->doubleSpinBoxTilesLength->setValue(UnitConvertor(tmplSize.height(), Unit::Px, - m_layout->LayoutSettings().GetUnit())); - - on_TilesSizeChanged(false); - - ui->doubleSpinBoxTilesWidth->blockSignals(false); - ui->doubleSpinBoxTilesLength->blockSignals(false); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_TilesSizeChanged(bool changedViaSizeCombobox) -{ - m_layout->LayoutSettings().SetTilesSizeConverted(ui->doubleSpinBoxTilesWidth->value(), - ui->doubleSpinBoxTilesLength->value()); - m_tileFactory->refreshTileInfos(); - - if(changedViaSizeCombobox) - { - ui->comboBoxTilesTemplate->blockSignals(true); - - // we don't try to get the right size, because it doesn't work well because of mm / inch conversion - int index = ui->comboBoxTilesTemplate->findData( - QVariant(static_cast(PaperSizeTemplate::Custom))); - - ui->comboBoxTilesTemplate->setCurrentIndex(index); - ui->comboBoxTilesTemplate->blockSignals(false); - } - - // TODO Undo / Redo - - if(m_graphicsView != nullptr) - { + m_tileFactory->refreshTileInfos(); m_graphicsView->RefreshLayout(); } } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_TilesOrientationChanged() +void VPMainWindow::on_TilesOrientationChanged(bool checked) { - // Updates the orientation - m_tileFactory->refreshTileInfos(); + if (checked && not m_layout.isNull()) + { + const qreal width = ui->doubleSpinBoxTilePaperWidth->value(); + const qreal height = ui->doubleSpinBoxTilePaperHeight->value(); - // TODO Undo / Redo + SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperWidth, height); + SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperHeight, width); - m_graphicsView->RefreshLayout(); + m_layout->LayoutSettings().SetTilesSizeConverted(height, width); + + TilePaperSizeChanged(); + CorrectMaxMargins(); + LayoutWasSaved(false); + m_tileFactory->refreshTileInfos(); + m_graphicsView->RefreshLayout(); + } } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_TilesMarginChanged() { - m_layout->LayoutSettings().SetTilesMarginsConverted( - ui->doubleSpinBoxTilesMarginLeft->value(), - ui->doubleSpinBoxTilesMarginTop->value(), - ui->doubleSpinBoxTilesMarginRight->value(), - ui->doubleSpinBoxTilesMarginBottom->value() - ); - m_tileFactory->refreshTileInfos(); - - // TODO Undo / Redo - - m_graphicsView->RefreshLayout(); -} - - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_checkBoxTilesShowTiles_toggled(bool checked) -{ - m_layout->LayoutSettings().SetShowTiles(checked); - - // TODO Undo / Redo - - m_graphicsView->RefreshLayout(); + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetTilesMarginsConverted( + ui->doubleSpinBoxTileMarginLeft->value(), + ui->doubleSpinBoxTileMarginTop->value(), + ui->doubleSpinBoxTileMarginRight->value(), + ui->doubleSpinBoxTileMarginBottom->value()); + LayoutWasSaved(false); + m_tileFactory->refreshTileInfos(); + m_graphicsView->RefreshLayout(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1654,146 +2284,44 @@ void VPMainWindow::on_pushButtonTilesExport_clicked() generateTiledPdf(fileName); } - - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_SheetFollowGrainlineChanged() -{ - // just for test purpuses, to be removed: - QMessageBox msgBox; - msgBox.setText("TODO VPMainWindow::on_SheetFollowGrainlineChanged"); - int ret = msgBox.exec(); - - Q_UNUSED(ret); - - // TODO -} - - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_doubleSpinBoxSheetPiecesGap_valueChanged(double value) -{ - m_layout->LayoutSettings().SetPiecesGapConverted(value); - - // TODO Undo / Redo - // TODO update the QGraphicView -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked) -{ - m_layout->LayoutSettings().SetWarningSuperpositionOfPieces(checked); - - // TODO Undo / Redo - // TODO update the QGraphicView -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked) -{ - m_layout->LayoutSettings().SetWarningPiecesOutOfBound(checked); - - // TODO Undo / Redo - // TODO update the QGraphicView -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_checkBoxSheetStickyEdges_toggled(bool checked) -{ - m_layout->LayoutSettings().SetStickyEdges(checked); - - // TODO Undo / Redo - // TODO update the QGraphicView -} - //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_pushButtonSheetExport_clicked() { - LayoutExportFormats format = static_cast(ui->comboBoxSheetExportFormat->currentData().toInt()); +// LayoutExportFormats format = static_cast(ui->comboBoxSheetExportFormat->currentData().toInt()); - VPExporter exporter; - exporter.Export(m_layout.get(), format, m_graphicsView); +// VPExporter exporter; +// exporter.Export(m_layout.get(), format, m_graphicsView); } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked) { - if(m_selectedPieces.count() == 1) - { +// if(m_selectedPieces.count() == 1) +// { // m_selectedPieces.first()->SetShowSeamLine(checked); - } +// } } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked) { - if(m_selectedPieces.count() == 1) - { - m_selectedPieces.first()->SetMirror(checked); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_pushButtonCurrentPieceRotate90Anticlockwise_clicked() -{ - if(m_selectedPieces.count() == 1) - { -// m_selectedPieces.first()->RotateBy(90); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_pushButtonCurrentPieceRotate90Clockwise_clicked() -{ - if(m_selectedPieces.count() == 1) - { -// m_selectedPieces.first()->RotateBy(-90); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_pushButtonCurrentPieceRotateGrainlineVertical_clicked() -{ - if(m_selectedPieces.count() == 1) - { -// m_selectedPieces.first()->RotateToGrainline(90, true); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_pushButtonCurrentPieceRotateGrainlineHorizontal_clicked() -{ - if(m_selectedPieces.count() == 1) - { -// m_selectedPieces.first()->RotateToGrainline(0, true); - } +// if(m_selectedPieces.count() == 1) +// { +// m_selectedPieces.first()->SetMirror(checked); +// } } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value) { - if(m_selectedPieces.count() == 1) - { +// if(m_selectedPieces.count() == 1) +// { // VPPiece *piece = m_selectedPieces.first(); // piece->SetRotation(value); - } +// } } -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_CurrentPiecePositionEdited() -{ - if(m_selectedPieces.count() == 1) - { - VPPiece *piece = m_selectedPieces.first(); - QPointF pos(UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), - m_layout->LayoutSettings().GetUnit(), Unit::Px), - UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), - m_layout->LayoutSettings().GetUnit(), Unit::Px)); - piece->SetPosition(pos); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_CarrouselLocationChanged(Qt::DockWidgetArea area) { @@ -1810,41 +2338,10 @@ void VPMainWindow::on_CarrouselLocationChanged(Qt::DockWidgetArea area) //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_PieceSelectionChanged() { -// m_selectedPieces = m_layout->GetSelectedPieces(); - // update the property of the piece currently selected SetPropertyTabCurrentPieceData(); } - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_PiecePositionChanged() -{ - if(m_selectedPieces.count() == 1) - { - VPPiece *piece = m_selectedPieces.first(); - QPointF pos = piece->GetPosition(); - - SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX, - UnitConvertor(pos.x(), Unit::Px, m_layout->LayoutSettings().GetUnit())); - SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY, - UnitConvertor(pos.y(), Unit::Px, m_layout->LayoutSettings().GetUnit())); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_PieceRotationChanged() -{ - if(m_selectedPieces.count() == 1) - { -// VPPiece *piece = m_selectedPieces.first(); -// qreal angle = piece->GetRotation(); - -// SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle); - } -} - - //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_ScaleChanged(qreal scale) { @@ -1934,10 +2431,293 @@ void VPMainWindow::ToolBarStyles() void VPMainWindow::on_actionAddSheet_triggered() { VPSheetPtr sheet(new VPSheet(m_layout)); - sheet->SetName(QObject::tr("Sheet %1").arg(m_layout->GetSheets().size()+1)); + sheet->SetName(tr("Sheet %1").arg(m_layout->GetSheets().size()+1)); m_layout->UndoStack()->push(new VPUndoAddSheet(sheet)); } +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::on_ApplyPieceTransformation() +{ + if (m_layout.isNull()) + { + return; + } + const int index = ui->tabWidgetPieceTransformation->currentIndex(); + if (ui->tabWidgetPieceTransformation->indexOf(ui->tabTranslate) == index) + { // translate + const qreal dx = UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), TranslateUnit(), Unit::Px); + const qreal dy = UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), TranslateUnit(), Unit::Px); + + QList selectedPieces = SelectedPieces(); + if (selectedPieces.isEmpty()) + { + return; + } + + if (ui->checkBoxRelativeTranslation->isChecked()) + { + if (ui->checkBoxTransformSeparately->isChecked()) + { + if (selectedPieces.size() > 1) + { + m_layout->UndoStack()->beginMacro(tr("translate pieces")); + } + + QRectF rect = PiecesBoundingRect(selectedPieces); + for (const auto& piece : selectedPieces) + { + if (not piece.isNull()) + { + const QRectF pieceRect = piece->MappedDetailBoundingRect(); + qreal pieceDx = dx; + qreal pieceDy = dy; + + if (not qFuzzyIsNull(rect.width())) + { + pieceDx += dx*((pieceRect.topLeft().x()-rect.topLeft().x())/rect.width())*2.; + } + + if (not qFuzzyIsNull(rect.height())) + { + pieceDy += dy*((pieceRect.topLeft().y()-rect.topLeft().y())/rect.height())*2.; + } + + auto *command = new VPUndoPieceMove(piece, pieceDx, pieceDy); + m_layout->UndoStack()->push(command); + } + } + + if (selectedPieces.size() > 1) + { + m_layout->UndoStack()->endMacro(); + } + } + else + { + auto *command = new VPUndoPiecesMove(selectedPieces, dx, dy); + m_layout->UndoStack()->push(command); + } + } + else + { + QRectF rect = PiecesBoundingRect(selectedPieces); + qreal pieceDx = dx - rect.topLeft().x(); + qreal pieceDy = dy - rect.topLeft().y(); + + if (selectedPieces.size() == 1) + { + auto *command = new VPUndoPieceMove(selectedPieces.first(), pieceDx, pieceDy); + m_layout->UndoStack()->push(command); + } + else + { + auto *command = new VPUndoPiecesMove(selectedPieces, pieceDx, pieceDy); + m_layout->UndoStack()->push(command); + } + } + } + else if (ui->tabWidgetPieceTransformation->indexOf(ui->tabRotate) == index) + { // rotate + qreal angle = ui->doubleSpinBoxCurrentPieceAngle->value(); + + if (ui->toolButtonCurrentPieceRotationClockwise->isChecked()) + { + angle *= -1; + } + + QList selectedPieces = SelectedPieces(); + if (selectedPieces.isEmpty()) + { + return; + } + + if (ui->checkBoxTransformSeparately->isChecked()) + { + m_layout->UndoStack()->beginMacro(tr("rotate pieces")); + for (const auto& piece : selectedPieces) + { + if (not piece.isNull()) + { + const QRectF rect = piece->MappedDetailBoundingRect(); + auto *command = new VPUndoPieceRotate(piece, rect.center(), angle); + m_layout->UndoStack()->push(command); + } + } + m_layout->UndoStack()->endMacro(); + } + else + { + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (sheet.isNull()) + { + return; + } + + VPTransformationOrigon origin = sheet->TransformationOrigin(); + auto *command = new VPUndoPiecesRotate(selectedPieces, origin.origin, angle); + m_layout->UndoStack()->push(command); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::on_ResetPieceTransformationSettings() +{ + const int index = ui->tabWidgetPieceTransformation->currentIndex(); + if (ui->tabWidgetPieceTransformation->indexOf(ui->tabTranslate) == index) + { // translate + if (ui->checkBoxRelativeTranslation->isChecked()) + { + ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue(0); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue(0); + } + else + { + int unitIndex = ui->comboBoxTranslateUnit->findData(QVariant(UnitsToStr(Unit::Px))); + if (unitIndex != -1) + { + ui->comboBoxTranslateUnit->setCurrentIndex(unitIndex); + } + } + } + else if (ui->tabWidgetPieceTransformation->indexOf(ui->tabRotate) == index) + { // rotate + ui->doubleSpinBoxCurrentPieceAngle->setValue(0); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::on_RelativeTranslationChanged(bool checked) +{ + if (checked) + { + ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue(0); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue(0); + } + else + { + QRectF rect = PiecesBoundingRect(SelectedPieces()); + + ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue( + UnitConvertor(rect.topLeft().x(), Unit::Px, TranslateUnit())); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue( + UnitConvertor(rect.topLeft().y(), Unit::Px, TranslateUnit())); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::on_ConvertPaperSize() +{ + const Unit layoutUnit = LayoutUnit(); + + const qreal sheetWidth = ui->doubleSpinBoxSheetPaperWidth->value(); + const qreal sheetHeight = ui->doubleSpinBoxSheetPaperHeight->value(); + + const qreal sheetLeftMargin = ui->doubleSpinBoxSheetMarginLeft->value(); + const qreal sheetRightMargin = ui->doubleSpinBoxSheetMarginRight->value(); + const qreal sheetTopMargin = ui->doubleSpinBoxSheetMarginTop->value(); + const qreal sheetBottomMargin = ui->doubleSpinBoxSheetMarginBottom->value(); + + ui->doubleSpinBoxSheetPaperWidth->blockSignals(true); + ui->doubleSpinBoxSheetPaperHeight->blockSignals(true); + ui->doubleSpinBoxSheetPaperWidth->setMaximum(FromPixel(QIMAGE_MAX, layoutUnit)); + ui->doubleSpinBoxSheetPaperHeight->setMaximum(FromPixel(QIMAGE_MAX, layoutUnit)); + ui->doubleSpinBoxSheetPaperWidth->blockSignals(false); + ui->doubleSpinBoxSheetPaperHeight->blockSignals(false); + + const qreal newSheetWidth = UnitConvertor(sheetWidth, m_oldLayoutUnit, layoutUnit); + const qreal newSheetHeight = UnitConvertor(sheetHeight, m_oldLayoutUnit, layoutUnit); + + const qreal newSheetLeftMargin = UnitConvertor(sheetLeftMargin, m_oldLayoutUnit, layoutUnit); + const qreal newSheetRightMargin = UnitConvertor(sheetRightMargin, m_oldLayoutUnit, layoutUnit); + const qreal newSheetTopMargin = UnitConvertor(sheetTopMargin, m_oldLayoutUnit, layoutUnit); + const qreal newSheetBottomMargin = UnitConvertor(sheetBottomMargin, m_oldLayoutUnit, layoutUnit); + + const qreal tileWidth = ui->doubleSpinBoxTilePaperWidth->value(); + const qreal tileHeight = ui->doubleSpinBoxTilePaperHeight->value(); + + const qreal tileLeftMargin = ui->doubleSpinBoxTileMarginLeft->value(); + const qreal tileRightMargin = ui->doubleSpinBoxTileMarginRight->value(); + const qreal tileTopMargin = ui->doubleSpinBoxTileMarginTop->value(); + const qreal tileBottomMargin = ui->doubleSpinBoxTileMarginBottom->value(); + + ui->doubleSpinBoxTilePaperWidth->blockSignals(true); + ui->doubleSpinBoxTilePaperHeight->blockSignals(true); + ui->doubleSpinBoxTilePaperWidth->setMaximum(FromPixel(QIMAGE_MAX, layoutUnit)); + ui->doubleSpinBoxTilePaperHeight->setMaximum(FromPixel(QIMAGE_MAX, layoutUnit)); + ui->doubleSpinBoxTilePaperWidth->blockSignals(false); + ui->doubleSpinBoxTilePaperHeight->blockSignals(false); + + const qreal newTileWidth = UnitConvertor(tileWidth, m_oldLayoutUnit, layoutUnit); + const qreal newTileHeight = UnitConvertor(tileHeight, m_oldLayoutUnit, layoutUnit); + + const qreal newTileLeftMargin = UnitConvertor(tileLeftMargin, m_oldLayoutUnit, layoutUnit); + const qreal newTileRightMargin = UnitConvertor(tileRightMargin, m_oldLayoutUnit, layoutUnit); + const qreal newTileTopMargin = UnitConvertor(tileTopMargin, m_oldLayoutUnit, layoutUnit); + const qreal newTileBottomMargin = UnitConvertor(tileBottomMargin, m_oldLayoutUnit, layoutUnit); + + qreal newGap = UnitConvertor(ui->doubleSpinBoxSheetPiecesGap->value(), m_oldLayoutUnit, layoutUnit); + + m_oldLayoutUnit = layoutUnit; + m_layout->LayoutSettings().SetUnit(layoutUnit); + CorrectPaperDecimals(); + MinimumSheetPaperSize(); + MinimumTilePaperSize(); + + const QString suffix = " " + UnitsToStr(layoutUnit, true); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, newSheetWidth); + ui->doubleSpinBoxSheetPaperWidth->setSuffix(suffix); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, newSheetHeight); + ui->doubleSpinBoxSheetPaperHeight->setSuffix(suffix); + + on_SheetSizeChanged(); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, newSheetLeftMargin); + ui->doubleSpinBoxSheetMarginLeft->setSuffix(suffix); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, newSheetRightMargin); + ui->doubleSpinBoxSheetMarginRight->setSuffix(suffix); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, newSheetTopMargin); + ui->doubleSpinBoxSheetMarginTop->setSuffix(suffix); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, newSheetBottomMargin); + ui->doubleSpinBoxSheetMarginBottom->setSuffix(suffix); + + on_SheetMarginChanged(); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperWidth, newTileWidth); + ui->doubleSpinBoxTilePaperWidth->setSuffix(suffix); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperHeight, newTileHeight); + ui->doubleSpinBoxTilePaperHeight->setSuffix(suffix); + + on_TilesSizeChanged(); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginLeft, newTileLeftMargin); + ui->doubleSpinBoxTileMarginLeft->setSuffix(suffix); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginRight, newTileRightMargin); + ui->doubleSpinBoxTileMarginRight->setSuffix(suffix); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginTop, newTileTopMargin); + ui->doubleSpinBoxTileMarginTop->setSuffix(suffix); + + SetDoubleSpinBoxValue(ui->doubleSpinBoxTileMarginBottom, newTileBottomMargin); + ui->doubleSpinBoxTileMarginBottom->setSuffix(suffix); + + on_TilesMarginChanged(); + + ui->doubleSpinBoxSheetPiecesGap->setMaximum( + UnitConvertor(VPSettings::GetMaxLayoutPieceGap(), Unit::Cm, layoutUnit)); + ui->doubleSpinBoxSheetPiecesGap->setValue(newGap); + ui->doubleSpinBoxSheetPiecesGap->setSuffix(suffix); + + CorrectMaxMargins(); +} + //--------------------------------------------------------------------------------------------------------------------- #if defined(Q_OS_MAC) void VPMainWindow::AboutToShowDockMenu() diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index 227f939e5..848ba6fb3 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -45,6 +45,7 @@ #include "../vlayout/vlayoutdef.h" #include "../vwidgets/vabstractmainwindow.h" #include "../vmisc/vlockguard.h" +#include "../vlayout/dialogs/vabstractlayoutdialog.h" namespace Ui { @@ -154,40 +155,24 @@ private slots: void on_actionAboutPuzzle_triggered(); /** - * @brief on_comboBoxLayoutUnit_currentIndexChanged When the unit is changed in + * @brief on_LayoutUnitChanged When the unit is changed in * the layout property tab. * The slot is automatically connected through name convention. * @param index the index of the selected unit */ - void on_comboBoxLayoutUnit_currentIndexChanged(int index); - - /** - * @brief on_lineEditSheetName_textChanged When the name of the sheet is changed - * in the sheet layout tab - * @param text name of the sheet - */ - void on_lineEditSheetName_textChanged(const QString &text); - - /** - * @brief on_comboBoxLayoutTemplate_currentIndexChanged When the template is - * changed in the sheet property tab. - * The slot is automatically connected through name convention. - * @param index the index of the selected templated - */ - void on_comboBoxSheetTemplate_currentIndexChanged(int index); + void on_LayoutUnitChanged(int index); /** * @brief on_SheetSizeChanged When the width or the length has been changed in * the sheet property tab - * @param changedViaSizeCombobox true if the change happened through the combobox */ - void on_SheetSizeChanged(bool changedViaSizeCombobox = true); + void on_SheetSizeChanged(); /** * @brief on_SheetOrientationChanged When one of the radio boxes for the sheet * orientation has been clicked */ - void on_SheetOrientationChanged(); + void on_SheetOrientationChanged(bool checked); /** * @brief on_pushButtonLayoutRemoveUnusedLength_clicked When the button @@ -225,40 +210,17 @@ private slots: */ void on_doubleSpinBoxSheetGridRowHeight_valueChanged(double value); - /** - * @brief LayoutFollowGrainlineChanged When one of the radio boxes for the - * "Follow grainline" has been clicked in the sheet property tab. - */ - void on_SheetFollowGrainlineChanged(); - - /** - * @brief on_doubleSpinBoxLayoutPiecesGap_valueChanged When the "pieces gap" - * value is changed in the layout property tab. - * The slot is automatically connected through name convention. - * @param value the new value of the pieces gap - */ - void on_doubleSpinBoxSheetPiecesGap_valueChanged(double value); - - /** - * @brief on_comboBoxTilesTemplate_currentIndexChanged When the template is - * changed in the tiles property tab. - * The slot is automatically connected through name convention. - * @param index the index of the selected templated - */ - void on_comboBoxTilesTemplate_currentIndexChanged(int index); - /** * @brief on_TilesSizeChanged When the width or the length has been changed in * the tiles property tab - * @param changedViaSizeCombobox true if the change happened through the combobox */ - void on_TilesSizeChanged(bool changedViaSizeCombobox = true); + void on_TilesSizeChanged(); /** * @brief on_TilesOrientationChanged When one of the radio boxes for the tiles * orientation has been clicked */ - void on_TilesOrientationChanged(); + void on_TilesOrientationChanged(bool checked); /** * @brief on_TilesMarginChanged When one of the margin values has been changed @@ -266,44 +228,11 @@ private slots: */ void on_TilesMarginChanged(); - /** - * @brief on_checkBoxTilesShowTiles_toggled When the checkbox "show tiles" is - * clicked - * @param checked show tiles - */ - void on_checkBoxTilesShowTiles_toggled(bool checked); - /** * @brief on_pushButtonTilesExport_clicked When the export tiles button is clicked */ void on_pushButtonTilesExport_clicked(); - /** - * @brief on_checkBoxLayoutWarningPiecesSuperposition_toggled When the - * "Warning when pieces superposition" checkbox value in the layout - * property tab is toggled. - * The slot is automatically connected through name convention. - * @param checked the new checked value - */ - void on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked); - - /** - * @brief on_checkBoxLayoutWarningPiecesOutOfBound_toggled When the - * "Warning when pieces out of bound" checkbox value in the layout property - * tab is toggled. - * The slot is automatically connected through name convention. - * @param checked the new checked value - */ - void on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked); - - /** - * @brief on_checkBoxLayoutStickyEdges_toggled When the "Sticky edges" - * checkbox value in the layout property tab is toggled. - * The slot is automatically connected through name convention. - * @param checked the new checked value - */ - void on_checkBoxSheetStickyEdges_toggled(bool checked); - /** * @brief on_pushButtonLayoutExport_clicked When the button * "Export layout" in the layout property is clicked. @@ -327,30 +256,6 @@ private slots: */ void on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked); - /** - * @brief on_pushButtonCurrentPieceRotate90Antilockwise_clicked When the 90 - * anticlockwise angle button is clicked - */ - void on_pushButtonCurrentPieceRotate90Anticlockwise_clicked(); - - /** - * @brief on_pushButtonCurrentPieceRotate90Clockwise_clicked When the 90 - * clockwise angle button is clicked - */ - void on_pushButtonCurrentPieceRotate90Clockwise_clicked(); - - /** - * @brief on_pushButtonCurrentPieceRotateGrainlineVertical_clicked - * When the grainline vertical angle button is clicked - */ - void on_pushButtonCurrentPieceRotateGrainlineVertical_clicked(); - - /** - * @brief on_pushButtonCurrentPieceRotateGrainlineHorizontal_clicked - * When the grainline horizontal angle button is clicked - */ - void on_pushButtonCurrentPieceRotateGrainlineHorizontal_clicked(); - /** * @brief on_doubleSpinBoxCurrentPieceAngle_valueChanged When the * "Current Piece Angle" value in the current piece property is changed @@ -359,12 +264,6 @@ private slots: */ void on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value); - /** - * @brief on_CurrentPiecePositionChanged When the positionX or the positionY - * is changed in the current piece tab - */ - void on_CurrentPiecePositionEdited(); - /** * @brief CarrouselLocationChanged When the piece carrousel's location * has been changed @@ -377,16 +276,6 @@ private slots: */ void on_PieceSelectionChanged(); - /** - * @brief on_PiecePositionChanged When the current piece position has changed - */ - void on_PiecePositionChanged(); - - /** - * @brief on_PieceRotationChanged When the current piece rotation has changed - */ - void on_PieceRotationChanged(); - /** * @brief on_ScaleChanged When the scale of the graphic view is changed */ @@ -406,6 +295,14 @@ private slots: void on_actionAddSheet_triggered(); + void on_ApplyPieceTransformation(); + + void on_ResetPieceTransformationSettings(); + + void on_RelativeTranslationChanged(bool checked); + + void on_ConvertPaperSize(); + #if defined(Q_OS_MAC) void AboutToShowDockMenu(); #endif //defined(Q_OS_MAC) @@ -422,7 +319,6 @@ private: QUndoStack *m_undoStack; VPLayoutPtr m_layout; - QListm_selectedPieces{QList()}; VPTileFactory *m_tileFactory{nullptr}; @@ -449,6 +345,9 @@ private: QAction *undoAction{nullptr}; QAction *redoAction{nullptr}; + Unit m_oldPieceTranslationUnit{Unit::Mm}; + Unit m_oldLayoutUnit{Unit::Mm}; + /** * @brief CreatePiece creates a piece from the given VLayoutPiece data * @param rawPiece the raw piece data @@ -535,22 +434,6 @@ private: */ void SetPropertyTabLayoutData(); - /** - * @brief SetDoubleSpinBoxValue sets the given spinbox to the given value. - * the signals are blocked before changing the value and unblocked after - * @param spinBox pointer to spinbox - * @param value spinbox value - */ - void SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value); - - /** - * @brief SetCheckBoxValue sets the given checkbox to the given value. - * the signals are blocked before changing the value and unblocked after - * @param checkbox pointer to checkbox - * @param value checkbox value - */ - void SetCheckBoxValue(QCheckBox *checkbox, bool value); - void ReadSettings(); void WriteSettings(); @@ -567,6 +450,34 @@ private: auto IsLayoutReadOnly() const -> bool; void ConnectToPreferences(const QSharedPointer &preferences); + + auto SelectedPieces() const -> QList; + + auto TranslateUnit() const -> Unit; + auto LayoutUnit() const -> Unit; + + QSizeF Template(VAbstractLayoutDialog::PaperSizeTemplate t) const; + QSizeF SheetTemplate() const; + QSizeF TileTemplate() const; + + void SheetSize(const QSizeF &size); + void TileSize(const QSizeF &size); + + void CorrectPaperDecimals(); + + void SheetPaperSizeChanged(); + void TilePaperSizeChanged(); + + void MinimumSheetPaperSize(); + void MinimumTilePaperSize(); + + void FindTemplate(QComboBox *box, qreal width, qreal height); + void FindSheetTemplate(); + void FindTileTemplate(); + + void CorrectTileMaxMargins(); + void CorrectSheetMaxMargins(); + void CorrectMaxMargins(); }; #endif // VPMAINWINDOW_H diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index 46f18ca67..4e8403308 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -111,8 +111,8 @@ - 24 - 37 + 30 + 46 @@ -151,10 +151,10 @@ - + - 378 - 524287 + 140 + 153 @@ -180,22 +180,16 @@ true - + 0 0 - - - 360 - 0 - - QTabWidget::Rounded - 2 + 0 @@ -255,11 +249,11 @@ 0 0 - 342 - 1370 + 358 + 700 - + @@ -340,6 +334,223 @@ + + + + + 0 + 0 + + + + Transformation + + + + + + 0 + + + + Translate + + + + + + Placement + + + + + + + + Horizontal: + + + + + + + -10000.000000000000000 + + + 10000.000000000000000 + + + 0.100000000000000 + + + + + + + + + + Vertical: + + + + + + + -10000.000000000000000 + + + 10000.000000000000000 + + + 0.100000000000000 + + + + + + + + + Relative translation + + + true + + + + + + + + + + + Rotate + + + + + + Rotation + + + + + + + + + + .. + + + true + + + buttonGroupRotationDirection + + + + + + + 3 + + + -360.000000000000000 + + + 360.000000000000000 + + + 0.100000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + .. + + + true + + + true + + + buttonGroupRotationDirection + + + + + + + + 0 + 0 + + + + Angle: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + Apply to each piece separately + + + + + + + QDialogButtonBox::Apply|QDialogButtonBox::Reset + + + + + + @@ -375,237 +586,28 @@ - - - - Rotation - - - - - - Angle: - - - - - - - 360.000000000000000 - - - 1.000000000000000 - - - - - - - - - Rotate the piece by 90° clockwise - - - - - - - :/puzzleicon/64x64/iconRotate90Clockwise.png:/puzzleicon/64x64/iconRotate90Clockwise.png - - - - 32 - 32 - - - - - - - - Rotate the piece by 90° anti-clockwise - - - - - - - :/puzzleicon/64x64/iconRotate90Anticlockwise.png:/puzzleicon/64x64/iconRotate90Anticlockwise.png - - - - 32 - 32 - - - - - - - - Rotate the piece so that the grainline is vertical - - - - - - - :/puzzleicon/64x64/iconRotateGrainlineVertical.png:/puzzleicon/64x64/iconRotateGrainlineVertical.png - - - - 32 - 32 - - - - - - - - Rotate the piece so that the grainline is horizontal - - - - - - - :/puzzleicon/64x64/iconRotateGrainlineHorizontal.png:/puzzleicon/64x64/iconRotateGrainlineHorizontal.png - - - - 32 - 32 - - - - - - - - - - - - - Placement - - - - - - X: - - - - - - - -10000.000000000000000 - - - 10000.000000000000000 - - - 0.100000000000000 - - - - - - - Y: - - - - - - - -10000.000000000000000 - - - 10000.000000000000000 - - - 0.100000000000000 - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 400 - - - - No piece selected - - - Qt::AlignCenter - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 400 - - - - Multiple pieces selected - - - Qt::AlignCenter - - - - + + + + + 0 + 1 + + + + + 18 + + + + No piece selected + + + Qt::AlignCenter + @@ -669,12 +671,12 @@ 0 - -170 - 342 - 870 + 0 + 344 + 748 - + @@ -712,111 +714,173 @@ - + + + false + Format - + + false + + + false + + + false + + - + + + QFormLayout::ExpandingFieldsGrow + - + - Template + Unit: - + - + + + + 0 + 0 + + - Width + Templates: - - - 2 - - - 100000.000000000000000 - - + + + + + + + Qt::Horizontal + + + + + - - - Length - - - - - - - 2 - - - 100000.000000000000000 - - - - - - - Orientation - - - - - + - - - Portrait - + - + ... - - :/puzzleicon/64x64/iconPortrait.png:/puzzleicon/64x64/iconPortrait.png + + :/icon/16x16/portrait.png:/icon/16x16/portrait.png - - - 32 - 32 - + + true true + + true + + + buttonGroupSheetOrientation + - - - Landscape - + - + ... - - :/puzzleicon/64x64/iconLandscape.png:/puzzleicon/64x64/iconLandscape.png + + :/icon/16x16/landscape.png:/icon/16x16/landscape.png - - - 32 - 32 - + + true + + false + + + true + + + buttonGroupSheetOrientation + + + + + + 0 + 0 + + + + Width: + + + + + + + + 0 + 0 + + + + Length: + + + + + + + + 94 + 0 + + + + 2 + + + 99999.000000000000000 + + + + + + + + 94 + 0 + + + + 2 + + + 99999.990000000005239 + + + @@ -834,75 +898,92 @@ Margins - - - + + + + + + + Right: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 0.100000000000000 + + + + + + + Top: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0.100000000000000 + + + + + + + 0.100000000000000 + + + + + + + Left: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Bottom: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0.100000000000000 + + + + + + + + + + 0 + 0 + + - Right: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Top: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0.100000000000000 - - - - - - - 0.100000000000000 - - - - - - - Left: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0.100000000000000 - - - - - - - 0.100000000000000 - - - - - - - Bottom: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Ignore margins @@ -961,116 +1042,11 @@ - - - Control - - - - - - - - Follow grainline - - - - - - - - - No - - - true - - - - - - - Vertical grainline - - - - - - - :/puzzleicon/64x64/iconGrainlineVertical.png:/puzzleicon/64x64/iconGrainlineVertical.png - - - - 28 - 28 - - - - - - - - Horizontal grainline - - - - - - - :/puzzleicon/64x64/iconGrainlineHorizontal.png:/puzzleicon/64x64/iconGrainlineHorizontal.png - - - - 28 - 28 - - - - - - - - - - Pieces gap - - - - - - - - - - - - Sticky edges - - - - - - - - + Export - - - - - - Format - - - - - - - - @@ -1143,11 +1119,11 @@ 0 0 - 356 + 358 700 - + @@ -1162,98 +1138,162 @@ - + + + false + Format - + + false + + + false + + + false + + - - - + + + QFormLayout::ExpandingFieldsGrow + + + + + + 0 + 0 + + - Width + Templates: - - - - 100000.000000000000000 - - + + + + + + + + Qt::Horizontal + + + + + - - - Length - - - - - - - 100000.000000000000000 - - - - - - - Orientation - - - - - + - + - + ... - - :/puzzleicon/64x64/iconPortrait.png:/puzzleicon/64x64/iconPortrait.png + + :/icon/16x16/portrait.png:/icon/16x16/portrait.png - - - 32 - 32 - + + true true + + true + + + buttonGroupTileOrientation + - + - + ... - - :/puzzleicon/64x64/iconLandscape.png:/puzzleicon/64x64/iconLandscape.png + + :/icon/16x16/landscape.png:/icon/16x16/landscape.png - - - 32 - 32 - + + true + + false + + + true + + + buttonGroupTileOrientation + - + + + + 0 + 0 + + - Template + Width: + + + + + + + + 0 + 0 + + + + Height: + + + + + + + + 94 + 0 + + + + 2 + + + 99999.000000000000000 - + + + + 94 + 0 + + + + 2 + + + 99999.990000000005239 + + @@ -1261,76 +1301,96 @@ - + Margins - - - + + + + + + + Right: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 0.100000000000000 + + + + + + + Top: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0.100000000000000 + + + + + + + 0.100000000000000 + + + + + + + Left: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Bottom: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0.100000000000000 + + + + + + + + + + 0 + 0 + + - Right: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Left: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0.100000000000000 - - - - - - - 0.100000000000000 - - - - - - - Top: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0.100000000000000 - - - - - - - Bottom: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0.100000000000000 + Ignore margins @@ -1431,11 +1491,11 @@ 0 0 - 356 + 358 700 - + @@ -1460,7 +1520,7 @@ - Name + Name: @@ -1486,29 +1546,6 @@ - - - - Format - - - - - - - - Unit - - - - - - - - - - - @@ -1529,21 +1566,52 @@ + + + + Sticky edges + + + + + + + Follow grainline + + + + + + + + + Pieces gap: + + + + + + + + - - - Qt::Vertical + + + Export - - - 20 - 40 - - - + + + + + Export Layout + + + + + @@ -1781,11 +1849,9 @@ - tabWidgetProperties scrollAreaCurrentPiece scrollAreaSheet scrollAreaTiles - scrollAreaLayout lineEditCurrentPieceName plainTextEditCurrentPieceUUID checkBoxCurrentPieceShowSeamline @@ -1794,41 +1860,22 @@ doubleSpinBoxCurrentPieceBoxPositionX doubleSpinBoxCurrentPieceBoxPositionY lineEditSheetName - comboBoxSheetTemplate - doubleSpinBoxSheetWidth - doubleSpinBoxSheetLength - radioButtonSheetPortrait - radioButtonSheetLandscape - pushButtonSheetRemoveUnusedLength - doubleSpinBoxSheetMarginTop - doubleSpinBoxSheetMarginLeft - doubleSpinBoxSheetMarginRight - doubleSpinBoxSheetMarginBottom - radioButtonSheetFollowGrainlineNo - radioButtonSheetFollowGrainlineVertical - radioButtonSheetFollowGrainlineHorizontal - doubleSpinBoxSheetPiecesGap - checkBoxSheetStickyEdges - comboBoxSheetExportFormat pushButtonSheetExport - doubleSpinBoxTilesWidth - doubleSpinBoxTilesLength - radioButtonTilesPortrait - radioButtonTilesLandscape - doubleSpinBoxTilesMarginTop - doubleSpinBoxTilesMarginLeft - doubleSpinBoxTilesMarginRight - doubleSpinBoxTilesMarginBottom checkBoxTilesShowTiles pushButtonTilesExport lineEditLayoutName plainTextEditLayoutDescription - comboBoxLayoutUnit checkBoxLayoutWarningPiecesSuperposition checkBoxLayoutWarningPiecesOutOfBound + + + + + + diff --git a/src/app/puzzle/vpsettings.cpp b/src/app/puzzle/vpsettings.cpp index e93947ccf..b54d97648 100644 --- a/src/app/puzzle/vpsettings.cpp +++ b/src/app/puzzle/vpsettings.cpp @@ -273,6 +273,13 @@ auto VPSettings::GetLayoutFollowGrainline() const -> bool return value(*settingLayoutFollowGrainline, false).toBool(); } +//--------------------------------------------------------------------------------------------------------------------- +qreal VPSettings::GetMaxLayoutPieceGap() +{ + return UnitConvertor(50, Unit::Cm, Unit::Px); +} + +//--------------------------------------------------------------------------------------------------------------------- void VPSettings::SetLayoutPieceGap(qreal value) { setValue(*settingLayoutPieceGap, value); diff --git a/src/app/puzzle/vpsettings.h b/src/app/puzzle/vpsettings.h index 74d26178c..d4098db40 100644 --- a/src/app/puzzle/vpsettings.h +++ b/src/app/puzzle/vpsettings.h @@ -90,6 +90,7 @@ public: void SetLayoutFollowGrainline(bool value); auto GetLayoutFollowGrainline() const -> bool; + static auto GetMaxLayoutPieceGap() -> qreal; void SetLayoutPieceGap(qreal value); auto GetLayoutPieceGap() const -> qreal; diff --git a/src/app/puzzle/vptilefactory.cpp b/src/app/puzzle/vptilefactory.cpp index a0c321b3a..452f13592 100644 --- a/src/app/puzzle/vptilefactory.cpp +++ b/src/app/puzzle/vptilefactory.cpp @@ -22,44 +22,39 @@ void VPTileFactory::refreshTileInfos() VPLayoutPtr layout = m_layout.toStrongRef(); if(not layout.isNull()) { - PageOrientation tilesOrientation = layout->LayoutSettings().GetTilesOrientation(); - QSizeF tilesSize = layout->LayoutSettings().GetTilesSize(); + QSizeF tilesSize = layout->LayoutSettings().GetTilesSize(); QMarginsF tilesMargins = layout->LayoutSettings().GetTilesMargins(); // sets the drawing height - m_drawingAreaHeight = (tilesOrientation == PageOrientation::Portrait)? - tilesSize.height() : tilesSize.width(); - m_drawingAreaHeight -= - tilesMargins.top() + tilesMargins.bottom() + m_infoStripeWidth; + m_drawingAreaHeight = tilesSize.height(); - // sets the drawing width - m_drawingAreaWidth = (tilesOrientation == PageOrientation::Portrait)? - tilesSize.width() : tilesSize.height(); - m_drawingAreaWidth -= - tilesMargins.left() + tilesMargins.right() + m_infoStripeWidth; - - - QSizeF sheetSize = layout->LayoutSettings().GetSheetSize(); - qreal totalDrawingWidth = 0; - qreal totaldrawingHeight = 0; - - if(layout->LayoutSettings().GetOrientation() == PageOrientation::Portrait) + if (not layout->LayoutSettings().IgnoreTilesMargins()) { - totalDrawingWidth = sheetSize.width(); - totaldrawingHeight = sheetSize.height(); + m_drawingAreaHeight -= tilesMargins.top() + tilesMargins.bottom() + m_infoStripeWidth; } else { - totalDrawingWidth = sheetSize.height(); - totaldrawingHeight = sheetSize.width(); + m_drawingAreaHeight += m_infoStripeWidth; } - m_nbCol = qCeil(totalDrawingWidth/m_drawingAreaWidth); - m_nbRow = qCeil(totaldrawingHeight/m_drawingAreaHeight); + // sets the drawing width + m_drawingAreaWidth = tilesSize.width(); + + if (not layout->LayoutSettings().IgnoreTilesMargins()) + { + m_drawingAreaWidth -= tilesMargins.left() + tilesMargins.right() + m_infoStripeWidth; + } + else + { + m_drawingAreaWidth += m_infoStripeWidth; + } + + QSizeF sheetSize = layout->LayoutSettings().GetSheetSize(); + m_nbCol = qCeil(sheetSize.width()/m_drawingAreaWidth); + m_nbRow = qCeil(sheetSize.height()/m_drawingAreaHeight); } } - //--------------------------------------------------------------------------------------------------------------------- void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView, int row, int col) { diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index aee2b5e34..d6a2d7ee4 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -147,8 +147,6 @@ void VPLayoutFileWriter::WriteFile(const VPLayoutPtr &layout, QIODevice *file) .arg(APP_VERSION_STR)); WriteLayout(layout); writeEndDocument(); - - file->close(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 7bc84791f..fb3bd0f3f 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -149,7 +149,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName ui->lineEditPath->setText(VAbstractValApplication::VApp()->ValentinaSettings()->GetPathLayout()); - InitTemplates(ui->comboBoxTemplates); + InitTileTemplates(ui->comboBoxTemplates); connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, &DialogSaveLayout::ToggleScaleConnection); @@ -163,20 +163,6 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName ShowExample();//Show example for current format. } -//--------------------------------------------------------------------------------------------------------------------- -void DialogSaveLayout::InitTemplates(QComboBox *comboBoxTemplates) -{ - SCASSERT(comboBoxTemplates != nullptr) - VAbstractLayoutDialog::InitTemplates(comboBoxTemplates); - - // remove unused formats - for (int i = static_cast(PaperSizeTemplate::Roll24in); i <= static_cast(PaperSizeTemplate::Custom); ++i) - { - comboBoxTemplates->removeItem(comboBoxTemplates->findData(i)); - } -} - - //--------------------------------------------------------------------------------------------------------------------- void DialogSaveLayout::SelectFormat(LayoutExportFormats format) diff --git a/src/app/valentina/dialogs/dialogsavelayout.h b/src/app/valentina/dialogs/dialogsavelayout.h index 9c4950f17..3daee718f 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.h +++ b/src/app/valentina/dialogs/dialogsavelayout.h @@ -83,7 +83,6 @@ public: protected: virtual void showEvent(QShowEvent *event) override; - void InitTemplates(QComboBox *comboBoxTemplates); private slots: void Save(); diff --git a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp index 1df41c2cf..aa060591e 100644 --- a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp +++ b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp @@ -84,6 +84,23 @@ void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates) comboBoxTemplates->setCurrentIndex(-1); } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractLayoutDialog::InitTileTemplates(QComboBox *comboBoxTemplates, bool keepCustom) +{ + SCASSERT(comboBoxTemplates != nullptr) + InitTemplates(comboBoxTemplates); + + // remove unused formats + for (int i = static_cast(PaperSizeTemplate::Roll24in); i <= static_cast(PaperSizeTemplate::Custom); ++i) + { + if (keepCustom && i == static_cast(PaperSizeTemplate::Custom)) + { + continue; + } + comboBoxTemplates->removeItem(comboBoxTemplates->findData(i)); + } +} + //--------------------------------------------------------------------------------------------------------------------- auto VAbstractLayoutDialog::GetTemplateSize(PaperSizeTemplate tmpl, Unit unit) -> QSizeF { diff --git a/src/libs/vlayout/dialogs/vabstractlayoutdialog.h b/src/libs/vlayout/dialogs/vabstractlayoutdialog.h index 07323945f..6ba849af1 100644 --- a/src/libs/vlayout/dialogs/vabstractlayoutdialog.h +++ b/src/libs/vlayout/dialogs/vabstractlayoutdialog.h @@ -62,6 +62,7 @@ public: static auto GetTemplateSize(PaperSizeTemplate tmpl, Unit unit) -> QSizeF; static void InitTemplates(QComboBox *comboBoxTemplates); + static void InitTileTemplates(QComboBox *comboBoxTemplates, bool keepCustom = false); protected: typedef QStringList FormatsVector; diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/object-rotate-right.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/object-rotate-right.png new file mode 100644 index 000000000..0bf5159f6 Binary files /dev/null and b/src/libs/vmisc/share/resources/icons/win.icon.theme/16x16/actions/object-rotate-right.png differ diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/object-rotate-right.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/object-rotate-right.png new file mode 100644 index 000000000..e9d8f5bbc Binary files /dev/null and b/src/libs/vmisc/share/resources/icons/win.icon.theme/24x24/actions/object-rotate-right.png differ diff --git a/src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/object-rotate-right.png b/src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/object-rotate-right.png new file mode 100644 index 000000000..353989137 Binary files /dev/null and b/src/libs/vmisc/share/resources/icons/win.icon.theme/32x32/actions/object-rotate-right.png differ diff --git a/src/libs/vmisc/share/resources/theme.qrc b/src/libs/vmisc/share/resources/theme.qrc index 7d28e0b69..ce2d67a93 100644 --- a/src/libs/vmisc/share/resources/theme.qrc +++ b/src/libs/vmisc/share/resources/theme.qrc @@ -102,5 +102,8 @@ icons/win.icon.theme/16x16/actions/view-refresh.png icons/win.icon.theme/24x24/actions/view-refresh.png icons/win.icon.theme/32x32/actions/view-refresh.png + icons/win.icon.theme/16x16/actions/object-rotate-right.png + icons/win.icon.theme/24x24/actions/object-rotate-right.png + icons/win.icon.theme/32x32/actions/object-rotate-right.png