From 9a8fabc25e08392447f5a1524d009bd170acff99 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Fri, 1 May 2020 19:08:48 +0200 Subject: [PATCH] optimization current piece tab --- src/app/puzzle/puzzlemainwindow.cpp | 37 ++- src/app/puzzle/puzzlemainwindow.ui | 239 ++++++++++-------- src/app/puzzle/vpuzzlepiece.cpp | 26 ++ src/app/puzzle/vpuzzlepiece.h | 26 ++ src/app/puzzle/xml/layoutliterals.cpp | 1 + src/app/puzzle/xml/layoutliterals.h | 1 + .../puzzle/xml/vpuzzlelayoutfilereader.cpp | 6 + .../puzzle/xml/vpuzzlelayoutfilewriter.cpp | 3 +- 8 files changed, 214 insertions(+), 125 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index de5220dcb..208f8af8b 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -72,7 +72,6 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa InitProperties(); InitPieceCarrousel(); - SetPropertiesData(); } @@ -328,14 +327,22 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData() else { // TODO : update current piece data to show a "no current piece selected" + ui->containerCurrentPieceNoData->setVisible(true); + ui->containerCurrentPieceData->setVisible(false); } } else { + ui->containerCurrentPieceNoData->setVisible(false); + ui->containerCurrentPieceData->setVisible(true); + // set the value to the current piece ui->lineEditCurrentPieceName->setText(m_selectedPiece->GetName()); - // TODO: checkbox show seamline, mirror piece, rotation and placement; + ui->checkBoxCurrentPieceShowSeamline->setChecked(m_selectedPiece->GetShowSeamLine()); + ui->checkBoxCurrentPieceMirrorPiece->setChecked(m_selectedPiece->GetPieceMirrored()); + + // TODO:rotation and placement; } } @@ -752,29 +759,19 @@ void PuzzleMainWindow::on_pushButtonLayoutExport_clicked() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked) { - // just for test purpuses, to be removed: - QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::CurrentPieceShowSeamlineChanged"); - int ret = msgBox.exec(); - - Q_UNUSED(checked); - Q_UNUSED(ret); - - // TODO + if(m_selectedPiece != nullptr) + { + m_selectedPiece->SetShowSeamLine(checked); + } } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked) { - // just for test purpuses, to be removed: - QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::CurrentPieceMirrorPieceChanged"); - int ret = msgBox.exec(); - - Q_UNUSED(checked); - Q_UNUSED(ret); - - // TODO + if(m_selectedPiece != nullptr) + { + m_selectedPiece->SetPieceMirrored(checked); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/puzzlemainwindow.ui b/src/app/puzzle/puzzlemainwindow.ui index d2731a6e5..5f63f8644 100644 --- a/src/app/puzzle/puzzlemainwindow.ui +++ b/src/app/puzzle/puzzlemainwindow.ui @@ -175,7 +175,7 @@ QTabWidget::Rounded - 1 + 0 @@ -232,8 +232,8 @@ 0 0 - 356 - 760 + 342 + 894 @@ -254,44 +254,24 @@ - - - Infos - - - - - - DummyName - - - true - - - - - - - Name: - - - - - - - - - - Seamline - - + + + + 0 + - - - Show Seamline + + + + 0 + 400 + - - true + + No piece selected + + + Qt::AlignCenter @@ -299,85 +279,136 @@ - - - Geometry - - + + - - - Mirror piece + + + Infos + + + + + DummyName + + + true + + + + + + + Name: + + + + - - - - - - - Rotation - - - - - - Angle: + + + + Seamline + + + + + Show Seamline + + + true + + + + - - - - 360.000000000000000 - - - 0.100000000000000 + + + + Geometry + + + + + Mirror piece + + + + - - - - - - - Placement - - - - - - X: + + + + Rotation + + + + + Angle: + + + + + + + 360.000000000000000 + + + 0.100000000000000 + + + + - - - - 10000.000000000000000 - - - 0.100000000000000 - - - - - - - Y: - - - - - - - 10000.000000000000000 - - - 0.100000000000000 + + + + Placement + + + + + X: + + + + + + + 10000.000000000000000 + + + 0.100000000000000 + + + + + + + Y: + + + + + + + 10000.000000000000000 + + + 0.100000000000000 + + + + diff --git a/src/app/puzzle/vpuzzlepiece.cpp b/src/app/puzzle/vpuzzlepiece.cpp index e4c8558eb..21daa67a2 100644 --- a/src/app/puzzle/vpuzzlepiece.cpp +++ b/src/app/puzzle/vpuzzlepiece.cpp @@ -78,3 +78,29 @@ void VPuzzlePiece::SetCuttingLine(const QVector &cuttingLine) { m_cuttingLine = cuttingLine; } + + +//--------------------------------------------------------------------------------------------------------------------- +bool VPuzzlePiece::GetShowSeamLine() +{ + return m_showSeamline; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzlePiece::SetShowSeamLine(bool value) +{ + m_showSeamline = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPuzzlePiece::GetPieceMirrored() +{ + return m_mirrorPiece; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzlePiece::SetPieceMirrored(bool value) +{ + m_mirrorPiece = value; +} + diff --git a/src/app/puzzle/vpuzzlepiece.h b/src/app/puzzle/vpuzzlepiece.h index 42331232f..55d0f3fd8 100644 --- a/src/app/puzzle/vpuzzlepiece.h +++ b/src/app/puzzle/vpuzzlepiece.h @@ -65,11 +65,37 @@ public: void SetCuttingLine(const QVector &cuttingLine); + /** + * @brief GetShowSeamLine returns wether the seam line of the piece has to be shown or not + * @return true if the seamline has to be shown + */ + bool GetShowSeamLine(); + + /** + * @brief SetShowSeamLine sets wether the seam line of the piece has to be shown or not + * @param value true if the seamline has to be shown + */ + void SetShowSeamLine(bool value); + + /** + * @brief GetMirrorPiece returns wether the piece is mirrored or not + * @return true if the piece is mirrored + */ + bool GetPieceMirrored(); + + /** + * @brief SetMirrorPiece sets wether the piece is mirrored or not + * @param value true if the piece will be mirrored + */ + void SetPieceMirrored(bool value); + private: QUuid m_uuid{QUuid()}; QString m_name{QString()}; QVector m_cuttingLine{QVector()}; + bool m_showSeamline{true}; + bool m_mirrorPiece{false}; }; #endif // VPUZZLEPIECE_H diff --git a/src/app/puzzle/xml/layoutliterals.cpp b/src/app/puzzle/xml/layoutliterals.cpp index c3bdb6d6d..d73088fc8 100644 --- a/src/app/puzzle/xml/layoutliterals.cpp +++ b/src/app/puzzle/xml/layoutliterals.cpp @@ -60,4 +60,5 @@ const QString AttrFollowGrainLine = QStringLiteral("followGrainLine"); const QString AttrID = QStringLiteral("id"); const QString AttrMirrored = QStringLiteral("mirrored"); const QString AttrTransform = QStringLiteral("transform"); +const QString AttrShowSeamline = QStringLiteral("showSeamline"); } diff --git a/src/app/puzzle/xml/layoutliterals.h b/src/app/puzzle/xml/layoutliterals.h index 3f2577203..82157f9bf 100644 --- a/src/app/puzzle/xml/layoutliterals.h +++ b/src/app/puzzle/xml/layoutliterals.h @@ -65,6 +65,7 @@ extern const QString AttrFollowGrainLine; extern const QString AttrID; extern const QString AttrMirrored; extern const QString AttrTransform; +extern const QString AttrShowSeamline; } diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp index f622fd733..31ab72691 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp @@ -249,9 +249,15 @@ void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece) QXmlStreamAttributes attribs = attributes(); piece->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Piece"))); + QString uuidStr = ReadAttributeString(attribs, ML::AttrID, QUuid().toString());// FIXME: is that correct to have a default value here? piece->SetUuid(QUuid(uuidStr)); + bool showSeamline = ReadAttributeBool(attribs, ML::AttrShowSeamline, trueStr); + piece->SetShowSeamLine(showSeamline); + + bool pieceMirrored = ReadAttributeBool(attribs, ML::AttrMirrored, falseStr); + piece->SetPieceMirrored(pieceMirrored); // TODO read the further attributes diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp index f9d4ef1c7..6b8dced26 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp @@ -165,7 +165,8 @@ void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece) writeStartElement(ML::TagPiece); SetAttribute(ML::AttrID, piece->GetUuid().toString()); SetAttribute(ML::AttrName, piece->GetName()); - SetAttribute(ML::AttrMirrored, "false"); // TODO / Fixme get the right value + SetAttribute(ML::AttrMirrored, piece->GetPieceMirrored()); // TODO / Fixme get the right value + SetAttribute(ML::AttrShowSeamline, piece->GetShowSeamLine()); // TODO / Fixme get the right value SetAttribute(ML::AttrTransform, "string representation of the transformation"); // TODO / Fixme get the right value // TODO cuttingLine